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

colesico.framework.jdbi.DefaultJdbiConfigIoclet Maven / Gradle / Ivy

The newest version!
// This is automatically generated file. Do not modify!
package colesico.framework.jdbi;

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.DefaultPolysupplier;
import colesico.framework.ioc.ioclet.Factory;
import colesico.framework.ioc.ioclet.Ioclet;
import colesico.framework.ioc.ioclet.SingletonFactory;
import colesico.framework.ioc.key.ClassedKey;
import colesico.framework.ioc.key.TypeKey;
import colesico.framework.ioc.production.InstanceProducingException;
import javax.sql.DataSource;
import org.jdbi.v3.core.Jdbi;

@Genstamp(
        generator = "colesico.framework.ioc.codegen.generator.IocletGenerator",
        timestamp = "2023-11-27T16:01:16.735Z",
        hashId = "53e406bf-c1bd-4927-af91-fecf85b70fd0",
        comments = "Producer: colesico.framework.jdbi.DefaultJdbiConfigProducer"
)
public final class DefaultJdbiConfigIoclet implements Ioclet {
    private final LazySingleton producer = new LazySingleton() {
        @Override
        public final DefaultJdbiConfigProducer create() {
            return new DefaultJdbiConfigProducer();
        }
    };

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

    /**
     * Factory to produce org.jdbi.v3.core.Jdbi class instance
     * Scope: UNSCOPED; Custom: null
     * Classed: colesico.framework.jdbi.DefaultJdbiConfig
     */
    public Factory getJdbiWithDefaultJdbiConfigFactory0() {
        return new Factory() {
            private Factory factoryFac;

            private Factory configFac;

            @Override
            public final void setup(final AdvancedIoc ioc) {
                // Initialize dependencies for: org.jdbi.v3.core.Jdbi
                this.factoryFac = ioc.factory(new ClassedKey("org.jdbi.v3.core.Jdbi","colesico.framework.jdbi.JdbiConfigPrototype"));
                this.configFac = ioc.factory(new TypeKey("colesico.framework.jdbi.DefaultJdbiConfig"));
            }

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

    /**
     * Factory to produce colesico.framework.jdbi.DefaultJdbiConfig class instance
     * Scope: SINGLETON; Custom: null
     */
    public Factory getDefaultJdbiConfigFactory1() {
        return new SingletonFactory() {
            private Factory dataSourceFac;

            private Factory optionsFac;

            @Override
            public final void setup(final AdvancedIoc ioc) {
                // Initialize dependencies for: colesico.framework.jdbi.DefaultJdbiConfig
                this.dataSourceFac = ioc.factory(new TypeKey("javax.sql.DataSource"));
                this.optionsFac = ioc.factoryOrNull(new TypeKey("colesico.framework.jdbi.JdbiOptionsPrototype"));
            }

            @Override
            public final DefaultJdbiConfig create(final Object message) {
                try {
                    // Perform instance producing
                    DefaultJdbiConfig instance = new DefaultJdbiConfig(this.dataSourceFac.get(message),new DefaultPolysupplier(this.optionsFac));
                    // Post construct listeners invocations:
                    return instance;
                } catch (InstanceProducingException ipe) {
                    throw ipe;
                } catch (Throwable t) {
                    throw new InstanceProducingException(t, DefaultJdbiConfig.class);
                }
            }
        };
    }

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

        if(catalog.accept(new TypeKey("colesico.framework.jdbi.DefaultJdbiConfig"), new JdbiConditions.DefaultConfig(), null, false)){
            catalog.add(getDefaultJdbiConfigFactory1());
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy