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

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

The 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.ioclet.SingletonFactory;
import colesico.framework.ioc.key.ClassedKey;
import colesico.framework.ioc.key.TypeKey;
import colesico.framework.ioc.production.InstanceProducingException;
import colesico.framework.jdbi.JdbiConditions;
import colesico.framework.jdbi.JdbiConfigPrototype;
import colesico.framework.transaction.TransactionalShell;
import java.sql.Connection;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;

@Genstamp(
        generator = "colesico.framework.ioc.codegen.generator.IocletGenerator",
        timestamp = "2023-11-27T16:01:16.722Z",
        hashId = "0e3987a8-5905-4029-a9a4-e45cd7e53df3",
        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);
                }
            }
        };
    }

    /**
     * Factory to produce colesico.framework.transaction.TransactionalShell class instance
     * Scope: SINGLETON; Custom: null
     */
    public Factory getDefaultTransactionalShellFactory2() {
        return new SingletonFactory() {
            private Factory jdbiFac;

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

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

    /**
     * Factory to produce java.sql.Connection class instance
     * Scope: UNSCOPED; Custom: null
     */
    public Factory getDefaultConnectionFactory3() {
        return new Factory() {
            private Factory txShellFac;

            @Override
            public final void setup(final AdvancedIoc ioc) {
                // Initialize dependencies for: java.sql.Connection
                this.txShellFac = ioc.factory(new TypeKey("colesico.framework.transaction.TransactionalShell"));
            }

            @Override
            public final Connection get(final Object message) {
                try {
                    // Perform instance producing
                    Connection instance = producer.get().getDefaultConnection(this.txShellFac.get(message));
                    return instance;
                } catch (InstanceProducingException ipe) {
                    throw ipe;
                } catch (Throwable t) {
                    throw new InstanceProducingException(t, Connection.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());
        }

        if(catalog.accept(new TypeKey("colesico.framework.transaction.TransactionalShell"), new JdbiConditions.DefaultTransactionalShell(), null, false)){
            catalog.add(getDefaultTransactionalShellFactory2());
        }

        if(catalog.accept(new TypeKey("java.sql.Connection"), new JdbiConditions.DefaultConnection(), null, false)){
            catalog.add(getDefaultConnectionFactory3());
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy