Search in sources :

Example 6 with Assembler

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

the class MixinVisibilityTest method testMultipleMixinsInLayerWillFailDiffModule.

@Test(expected = AmbiguousTypeException.class)
public void testMultipleMixinsInLayerWillFailDiffModule() throws Exception {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer
    { // Module 1
    new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module A");
            module.objects(ObjectA.class);
        }
    } }, { // Module 2
    new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module B");
            module.transients(B1Composite.class).visibleIn(Visibility.layer);
        }
    } }, { // Module 3
    new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module C");
            module.transients(B2Composite.class).visibleIn(Visibility.layer);
        }
    } } } };
    Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    ObjectA object = app.findModule("Layer 1", "Module A").newObject(ObjectA.class);
    assertEquals("ok", object.test1());
    assertEquals("abc", object.test2());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Test(org.junit.Test)

Example 7 with Assembler

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

the class ObjectVisibilityTest method setup.

@Before
public void setup() throws Exception {
    qi4j = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer Above
    { new AboveAssembler() } }, { // Layer From
    { // From Module
    new FromAssembler() }, { // Beside Module
    new BesideAssembler() } }, { // Layer Below
    { new BelowAssembler() } } };
    app = qi4j.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    module = app.findModule("From Layer", "From");
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Before(org.junit.Before)

Example 8 with Assembler

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

the class RDFPerformanceTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    module.services(FileConfigurationService.class);
    ModuleAssembly prefModule = module.layer().module("PrefModule");
    prefModule.entities(NativeConfiguration.class).visibleIn(Visibility.application);
    prefModule.forMixin(NativeConfiguration.class).declareDefaults().tripleIndexes().set("spoc,cspo");
    prefModule.forMixin(NativeConfiguration.class).declareDefaults().dataDirectory().set(DATA_DIR.getAbsolutePath());
    new EntityTestAssembler().assemble(prefModule);
    module.entities(ExampleEntity.class);
    EntityTestAssembler testAss = new EntityTestAssembler();
    testAss.assemble(module);
    Assembler rdfAssembler = new RdfNativeSesameStoreAssembler();
    rdfAssembler.assemble(module);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) RdfNativeSesameStoreAssembler(org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) Assembler(org.qi4j.bootstrap.Assembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) RdfNativeSesameStoreAssembler(org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler) NativeConfiguration(org.qi4j.library.rdf.repository.NativeConfiguration)

Example 9 with Assembler

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

the class AbstractEntityStorePerformanceTest method warmup.

@Before
public void warmup() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(SimpleProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        for (int i = 0; i < 10000; i++) {
            try (UnitOfWork uow = module.newUnitOfWork(newUsecase("Warmup " + i))) {
                SimpleProduct product = uow.newEntity(SimpleProduct.class);
                String id = product.identity().get();
            }
        }
    } catch (Exception ex) {
        logger.error("Unable to warmup: {}", ex.getMessage(), ex);
        throw ex;
    } 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) Before(org.junit.Before)

Example 10 with Assembler

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

the class JdbmEntityStorePerformanceTest method createAssembler.

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

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new JdbmEntityStoreAssembler().assemble(module);
            new OrgJsonValueSerializationAssembler().assemble(module);
            ModuleAssembly configModule = module.layer().module("Config");
            configModule.entities(JdbmConfiguration.class).visibleIn(Visibility.layer);
            new EntityTestAssembler().assemble(configModule);
            module.services(EhCachePoolService.class);
            configModule.entities(EhCacheConfiguration.class).visibleIn(Visibility.layer);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) JdbmConfiguration(org.qi4j.entitystore.jdbm.JdbmConfiguration) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) EhCacheConfiguration(org.qi4j.cache.ehcache.EhCacheConfiguration) JdbmEntityStoreAssembler(org.qi4j.entitystore.jdbm.assembly.JdbmEntityStoreAssembler) Assembler(org.qi4j.bootstrap.Assembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) JdbmEntityStoreAssembler(org.qi4j.entitystore.jdbm.assembly.JdbmEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

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