Search in sources :

Example 1 with PostgreSQLEntityStoreAssembler

use of org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler 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 2 with PostgreSQLEntityStoreAssembler

use of org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler 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)

Example 3 with PostgreSQLEntityStoreAssembler

use of org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler in project qi4j-sdk by Qi4j.

the class AppAssembler method assemble.

@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
    ApplicationAssembly appAss = applicationFactory.newApplicationAssembly();
    appAss.setName("SQL Support Sample");
    // Config
    LayerAssembly configLayer = appAss.layer("config");
    ModuleAssembly configModule = configLayer.module("config");
    {
        configModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON);
        configModule.services(MemoryEntityStoreService.class).visibleIn(Visibility.module);
    // Use a PreferenceEntityStore instead if you want the configuration to be persistent
    // new PreferenceEntityStoreAssembler( Visibility.module ).assemble( configModule );
    }
    // Infra
    LayerAssembly infraLayer = appAss.layer("infra");
    ModuleAssembly persistenceModule = infraLayer.module("persistence");
    {
        persistenceModule.services(OrgJsonValueSerializationService.class).taggedWith(ValueSerialization.Formats.JSON);
        // SQL DataSource Service
        String dataSourceServiceIdentity = "postgresql-datasource-service";
        new DBCPDataSourceServiceAssembler().identifiedBy(dataSourceServiceIdentity).visibleIn(Visibility.module).withConfig(configModule, Visibility.application).assemble(persistenceModule);
        // SQL EntityStore DataSource and Service
        new DataSourceAssembler().withDataSourceServiceIdentity(dataSourceServiceIdentity).identifiedBy("postgresql-es-datasource").visibleIn(Visibility.module).withCircuitBreaker(DataSources.newDataSourceCircuitBreaker()).assemble(persistenceModule);
        new PostgreSQLEntityStoreAssembler().visibleIn(Visibility.application).withConfig(configModule, Visibility.application).assemble(persistenceModule);
        // SQL Index/Query DataSource and Service
        new DataSourceAssembler().withDataSourceServiceIdentity(dataSourceServiceIdentity).identifiedBy("postgresql-index-datasource").visibleIn(Visibility.module).withCircuitBreaker().assemble(persistenceModule);
        new PostgreSQLIndexQueryAssembler().visibleIn(Visibility.application).withConfig(configModule, Visibility.application).assemble(persistenceModule);
    }
    // App
    LayerAssembly appLayer = appAss.layer("app");
    ModuleAssembly domainModule = appLayer.module("domain");
    {
        domainModule.entities(PretextEntity.class);
    }
    // Uses
    infraLayer.uses(configLayer);
    appLayer.uses(infraLayer);
    return appAss;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) PostgreSQLIndexQueryAssembler(org.qi4j.index.sql.assembly.PostgreSQLIndexQueryAssembler) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) PostgreSQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)3 PostgreSQLEntityStoreAssembler (org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler)3 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)3 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)3 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)1 Assembler (org.qi4j.bootstrap.Assembler)1 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)1 PostgreSQLIndexQueryAssembler (org.qi4j.index.sql.assembly.PostgreSQLIndexQueryAssembler)1 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)1 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)1