Search in sources :

Example 6 with DataSourceAssembler

use of org.qi4j.library.sql.assembly.DataSourceAssembler in project qi4j-sdk by Qi4j.

the class DerbySQLEntityStorePerformanceTest method createAssembler.

private static Assembler createAssembler() {
    return new Assembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            ModuleAssembly config = module.layer().module("config");
            new EntityTestAssembler().assemble(config);
            new OrgJsonValueSerializationAssembler().assemble(module);
            // DataSourceService
            new DBCPDataSourceServiceAssembler().identifiedBy("derby-datasource-service").visibleIn(Visibility.module).withConfig(config, Visibility.layer).assemble(module);
            // DataSource
            new DataSourceAssembler().withDataSourceServiceIdentity("derby-datasource-service").identifiedBy("derby-datasource").withCircuitBreaker().assemble(module);
            // SQL EntityStore
            new DerbySQLEntityStoreAssembler().withConfig(config, Visibility.layer).assemble(module);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) DerbySQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler) Assembler(org.qi4j.bootstrap.Assembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) DerbySQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 7 with DataSourceAssembler

use of org.qi4j.library.sql.assembly.DataSourceAssembler in project qi4j-sdk by Qi4j.

the class PostgreSQLEntityStoreTest method assemble.

@Override
public // START SNIPPET: assembly
void assemble(ModuleAssembly module) throws AssemblyException {
    // END SNIPPET: assembly
    super.assemble(module);
    ModuleAssembly config = module.layer().module("config");
    new EntityTestAssembler().assemble(config);
    new OrgJsonValueSerializationAssembler().assemble(module);
    // START SNIPPET: assembly
    // DataSourceService
    new DBCPDataSourceServiceAssembler().identifiedBy("postgresql-datasource-service").visibleIn(Visibility.module).withConfig(config, Visibility.layer).assemble(module);
    // DataSource
    new DataSourceAssembler().withDataSourceServiceIdentity("postgresql-datasource-service").identifiedBy("postgresql-datasource").visibleIn(Visibility.module).withCircuitBreaker().assemble(module);
    // SQL EntityStore
    new PostgreSQLEntityStoreAssembler().visibleIn(Visibility.application).withConfig(config, Visibility.layer).assemble(module);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) PostgreSQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 8 with DataSourceAssembler

use of org.qi4j.library.sql.assembly.DataSourceAssembler in project qi4j-sdk by Qi4j.

the class MySQLEntityStoreTest method assemble.

@Override
public // START SNIPPET: assembly
void assemble(ModuleAssembly module) throws AssemblyException {
    // END SNIPPET: assembly
    super.assemble(module);
    ModuleAssembly config = module.layer().module("config");
    new EntityTestAssembler().assemble(config);
    new OrgJsonValueSerializationAssembler().assemble(module);
    // START SNIPPET: assembly
    // DataSourceService
    new DBCPDataSourceServiceAssembler().identifiedBy("mysql-datasource-service").visibleIn(Visibility.module).withConfig(config, Visibility.layer).assemble(module);
    // DataSource
    new DataSourceAssembler().withDataSourceServiceIdentity("mysql-datasource-service").identifiedBy("mysql-datasource").visibleIn(Visibility.module).withCircuitBreaker().assemble(module);
    // SQL EntityStore
    new MySQLEntityStoreAssembler().visibleIn(Visibility.application).withConfig(config, Visibility.layer).assemble(module);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) MySQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.MySQLEntityStoreAssembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 9 with DataSourceAssembler

use of org.qi4j.library.sql.assembly.DataSourceAssembler in project qi4j-sdk by Qi4j.

the class DataSourceConfigurationManagerServiceTest method testDataSources.

@Test
public void testDataSources() throws ActivationException, AssemblyException {
    SingletonAssembler assembler = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new JMXAssembler().assemble(module);
            // Create in-memory store for configurations
            new EntityTestAssembler().visibleIn(Visibility.layer).assemble(module);
            // Set up DataSource service that will manage the connection pools
            new C3P0DataSourceServiceAssembler().identifiedBy("datasource-service").visibleIn(Visibility.layer).assemble(module);
            {
                ModuleAssembly testModule = module.layer().module("TestDS");
                // Create a specific DataSource that uses the "datasource" service to do the main work
                new DataSourceAssembler().withDataSourceServiceIdentity("datasource-service").identifiedBy("testds").visibleIn(Visibility.module).withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(testModule);
                // Set up Liquibase service that will create the tables
                testModule.services(LiquibaseService.class).identifiedBy("liquibase1").instantiateOnStartup();
                testModule.entities(LiquibaseConfiguration.class);
                testModule.forMixin(LiquibaseConfiguration.class).declareDefaults().enabled().set(true);
                testModule.forMixin(LiquibaseConfiguration.class).declareDefaults().changeLog().set("changelog.xml");
            }
            {
                ModuleAssembly testModule2 = module.layer().module("TestDS2");
                // Create another specific DataSource that uses the "datasource" service to do the main work
                // Use DataSourceAssembler to assemble the DataSource.
                new DataSourceAssembler().withDataSourceServiceIdentity("datasource-service").identifiedBy("testds2").visibleIn(Visibility.module).withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(testModule2);
                // Set up Liquibase service that will create the tables
                testModule2.services(LiquibaseService.class).identifiedBy("liquibase2").instantiateOnStartup();
                testModule2.entities(LiquibaseConfiguration.class);
                testModule2.forMixin(LiquibaseConfiguration.class).declareDefaults().enabled().set(true);
                testModule2.forMixin(LiquibaseConfiguration.class).declareDefaults().changeLog().set("changelog.xml");
            }
            // START SNIPPET: jmx
            new DataSourceJMXAssembler().visibleIn(Visibility.module).assemble(module);
        // END SNIPPET: jmx
        }
    };
//        assembler.application().findModule( "Layer 1","Test" ).objectBuilderFactory().newObjectBuilder( DataSourceConfigurationManagerServiceTest.class ).injectTo( this );
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) C3P0DataSourceServiceAssembler(org.qi4j.library.sql.c3p0.C3P0DataSourceServiceAssembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) DataSourceJMXAssembler(org.qi4j.library.sql.assembly.DataSourceJMXAssembler) JMXAssembler(org.qi4j.library.jmx.JMXAssembler) DataSourceJMXAssembler(org.qi4j.library.sql.assembly.DataSourceJMXAssembler) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) LiquibaseConfiguration(org.qi4j.library.sql.liquibase.LiquibaseConfiguration) LiquibaseService(org.qi4j.library.sql.liquibase.LiquibaseService) Test(org.junit.Test)

Example 10 with DataSourceAssembler

use of org.qi4j.library.sql.assembly.DataSourceAssembler in project qi4j-sdk by Qi4j.

the class PostgreSQLEntityStorePerformanceTest method createAssembler.

private static Assembler createAssembler() {
    return new Assembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            ModuleAssembly config = module.layer().module("config");
            config.services(MemoryEntityStoreService.class);
            // DataSourceService
            new DBCPDataSourceServiceAssembler().identifiedBy("postgresql-datasource-service").visibleIn(Visibility.module).withConfig(config, Visibility.layer).assemble(module);
            // DataSource
            new DataSourceAssembler().withDataSourceServiceIdentity("postgresql-datasource-service").identifiedBy("postgresql-datasource").withCircuitBreaker().assemble(module);
            // SQL EntityStore
            new PostgreSQLEntityStoreAssembler().withConfig(config, Visibility.layer).assemble(module);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) PostgreSQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler) Assembler(org.qi4j.bootstrap.Assembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) PostgreSQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)11 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)11 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)9 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)9 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)6 PostgreSQLEntityStoreAssembler (org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler)3 Test (org.junit.Test)2 Assembler (org.qi4j.bootstrap.Assembler)2 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)2 DerbySQLEntityStoreAssembler (org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler)2 PostgreSQLIndexQueryAssembler (org.qi4j.index.sql.assembly.PostgreSQLIndexQueryAssembler)2 C3P0DataSourceServiceAssembler (org.qi4j.library.sql.c3p0.C3P0DataSourceServiceAssembler)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DataSource (javax.sql.DataSource)1 ActivationEvent (org.qi4j.api.activation.ActivationEvent)1 ActivationEventListener (org.qi4j.api.activation.ActivationEventListener)1 Application (org.qi4j.api.structure.Application)1 Module (org.qi4j.api.structure.Module)1