Search in sources :

Example 11 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class MemoryEntityStorePerformanceTest method createAssembler.

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

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new MemoryEntityStoreAssembler().assemble(module);
            new OrgJsonValueSerializationAssembler().assemble(module);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) MemoryEntityStoreAssembler(org.qi4j.entitystore.memory.MemoryEntityStoreAssembler) MemoryEntityStoreAssembler(org.qi4j.entitystore.memory.MemoryEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) Assembler(org.qi4j.bootstrap.Assembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 12 with Assembler

use of org.qi4j.bootstrap.Assembler 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 13 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class AbstractEntityStorePerformanceTest method createQi4jRuntime.

private void createQi4jRuntime(Assembler testSetup) throws Exception {
    Energy4Java qi4j = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { { infrastructure, testSetup } } };
    application = qi4j.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    application.activate();
    Module moduleInstance = application.findModule("Layer 1", "Module 1");
    module = moduleInstance;
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Module(org.qi4j.api.structure.Module) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter)

Example 14 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class AbstractEntityStorePerformanceTest method whenCreateEntityWithSinglePropertyThenRecordIterationsPerSecond.

@Test
public void whenCreateEntityWithSinglePropertyThenRecordIterationsPerSecond() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(SimpleProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        profile(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Report report = new Report(storeName);
                report.start("createEntityWithSingleProperty");
                for (int i = 0; i < ITERATIONS; i++) {
                    try (UnitOfWork uow = module.newUnitOfWork(newUsecase("createEntityWithSingleProperty " + i))) {
                        SimpleProduct product = uow.newEntity(SimpleProduct.class);
                        String id = product.identity().get();
                        uow.complete();
                    }
                    if (i % 1000 == 0) {
                        logger.info("Iteration {}", i);
                    }
                }
                report.stop(ITERATIONS);
                writeReport(report);
                return null;
            }
        });
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Test(org.junit.Test)

Example 15 with Assembler

use of org.qi4j.bootstrap.Assembler in project qi4j-sdk by Qi4j.

the class ApplicationAssemblyFactoryImpl method newApplicationAssembly.

@Override
public ApplicationAssembly newApplicationAssembly(Assembler[][][] assemblers) throws AssemblyException {
    ApplicationAssembly applicationAssembly = newApplicationAssembly();
    // Build all layers bottom-up
    LayerAssembly below = null;
    for (int layer = assemblers.length - 1; layer >= 0; layer--) {
        // Create Layer
        LayerAssembly layerAssembly = applicationAssembly.layer("Layer " + (layer + 1));
        for (int module = 0; module < assemblers[layer].length; module++) {
            // Create Module
            ModuleAssembly moduleAssembly = layerAssembly.module("Module " + (module + 1));
            for (Assembler assembler : assemblers[layer][module]) {
                // Register Assembler
                assembler.assemble(moduleAssembly);
            }
        }
        if (below != null) {
            // Link layers
            layerAssembly.uses(below);
        }
        below = layerAssembly;
    }
    return applicationAssembly;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) Assembler(org.qi4j.bootstrap.Assembler) LayerAssembly(org.qi4j.bootstrap.LayerAssembly)

Aggregations

Assembler (org.qi4j.bootstrap.Assembler)34 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)23 Energy4Java (org.qi4j.bootstrap.Energy4Java)19 Test (org.junit.Test)17 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Application (org.qi4j.api.structure.Application)13 AssemblyException (org.qi4j.bootstrap.AssemblyException)10 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)9 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)8 IOException (java.io.IOException)6 Before (org.junit.Before)6 Module (org.qi4j.api.structure.Module)5 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)4 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)4 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)3 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)3 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)3 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)3 PostgreSQLEntityStoreAssembler (org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler)2 Connection (java.sql.Connection)1