All Downloads are FREE. Search and download functionalities are using the official Maven repository.

colesico.framework.jdbi.internal.JdbiIoclet Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
// This is automatically generated file. Do not modify!
package colesico.framework.jdbi.internal;

import colesico.framework.assist.LazySingleton;
import colesico.framework.assist.codegen.Genstamp;
import colesico.framework.ioc.ioclet.AdvancedIoc;
import colesico.framework.ioc.ioclet.Catalog;
import colesico.framework.ioc.ioclet.Factory;
import colesico.framework.ioc.ioclet.Ioclet;
import colesico.framework.ioc.key.ClassedKey;
import colesico.framework.ioc.key.TypeKey;
import colesico.framework.ioc.production.InstanceProducingException;
import colesico.framework.jdbi.JdbiConfigPrototype;
import colesico.framework.transaction.TransactionalShell;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;

@Genstamp(
        generator = "colesico.framework.ioc.codegen.generator.IocletGenerator",
        timestamp = "2020-11-11T10:00:14.603Z",
        hashId = "94357e42-7f59-4a60-afad-27ad25a59a44",
        comments = "Producer: colesico.framework.jdbi.internal.JdbiProducer"
)
public final class JdbiIoclet implements Ioclet {
    private final LazySingleton producer = new LazySingleton() {
        @Override
        public final JdbiProducer create() {
            return new JdbiProducer();
        }
    };

    @Override
    public final String getId() {
        return "colesico.framework.jdbi.internal.JdbiProducer";
    }

    /**
     * Factory to produce org.jdbi.v3.core.Jdbi class instance
     * Scope: UNSCOPED; Custom: null
     * Classed: colesico.framework.jdbi.JdbiConfigPrototype
     */
    public Factory jdbiFactoryFactory0() {
        return new Factory() {
            @Override
            public final void setup(final AdvancedIoc ioc) {
                // Initialize dependencies for: org.jdbi.v3.core.Jdbi
            }

            @Override
            public final Jdbi get(final Object message) {
                try {
                    // Perform instance producing
                    Jdbi instance = producer.get().jdbiFactory((JdbiConfigPrototype)message);
                    return instance;
                } catch (InstanceProducingException ipe) {
                    throw ipe;
                } catch (Throwable t) {
                    throw new InstanceProducingException(t, Jdbi.class);
                }
            }
        };
    }

    /**
     * Factory to produce org.jdbi.v3.core.Handle class instance
     * Scope: UNSCOPED; Custom: null
     */
    public Factory getHandleFactory1() {
        return new Factory() {
            private Factory txShellFac;

            @Override
            public final void setup(final AdvancedIoc ioc) {
                // Initialize dependencies for: org.jdbi.v3.core.Handle
                this.txShellFac = ioc.factory(new TypeKey("colesico.framework.transaction.TransactionalShell"));
            }

            @Override
            public final Handle get(final Object message) {
                try {
                    // Perform instance producing
                    Handle instance = producer.get().getHandle(this.txShellFac.get(message));
                    return instance;
                } catch (InstanceProducingException ipe) {
                    throw ipe;
                } catch (Throwable t) {
                    throw new InstanceProducingException(t, Handle.class);
                }
            }
        };
    }

    @Override
    public final void addFactories(final Catalog catalog) {
        if(catalog.accept(new ClassedKey("org.jdbi.v3.core.Jdbi","colesico.framework.jdbi.JdbiConfigPrototype"), null, null, false)){
            catalog.add(jdbiFactoryFactory0());
        }

        if(catalog.accept(new TypeKey("org.jdbi.v3.core.Handle"), null, null, false)){
            catalog.add(getHandleFactory1());
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy