Search in sources :

Example 1 with ModuleAssembly

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

the class LayerDeclaration method createLayer.

LayerAssembly createLayer(ApplicationAssembly application) {
    layer = application.layer(layerName);
    layer.setName(layerName);
    for (ModuleDeclaration module : modules.values()) {
        ModuleAssembly assembly = module.createModule(layer);
    }
    return layer;
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly)

Example 2 with ModuleAssembly

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

the class OperatorsTest method testOperators.

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

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new EntityTestAssembler().assemble(module);
            module.entities(TestEntity.class);
            module.values(TestValue.class);
            module.forMixin(TestEntity.class).declareDefaults().foo().set("Bar");
            module.forMixin(TestValue.class).declareDefaults().bar().set("Xyz");
        }
    };
    UnitOfWork uow = assembler.module().newUnitOfWork();
    try {
        EntityBuilder<TestEntity> entityBuilder = uow.newEntityBuilder(TestEntity.class, "123");
        entityBuilder.instance().value().set(assembler.module().newValue(TestValue.class));
        TestEntity testEntity = entityBuilder.newInstance();
        uow.complete();
        uow = assembler.module().newUnitOfWork();
        Iterable<TestEntity> entities = Iterables.iterable(testEntity = uow.get(testEntity));
        QueryBuilder<TestEntity> builder = assembler.module().newQueryBuilder(TestEntity.class);
        {
            Specification<Composite> where = QueryExpressions.eq(QueryExpressions.templateFor(TestEntity.class).foo(), "Bar");
            Assert.assertTrue(where.satisfiedBy(testEntity));
            System.out.println(where);
        }
        {
            Specification<Composite> where = QueryExpressions.eq(QueryExpressions.templateFor(TestEntity.class).value().get().bar(), "Xyz");
            Assert.assertTrue(where.satisfiedBy(testEntity));
            System.out.println(where);
            Assert.assertTrue(builder.where(where).newQuery(entities).find().equals(testEntity));
        }
    } finally {
        uow.discard();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) Specification(org.qi4j.functional.Specification) Test(org.junit.Test)

Example 3 with ModuleAssembly

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

the class ApplicationDocs method createWebServiceModule.

private static void createWebServiceModule(LayerAssembly layer) throws AssemblyException {
    ModuleAssembly assembly = layer.module("Web Service Module");
    // Someone has created an assembler for a Jetty Web Service.
    JettyAssembler jetty = new JettyAssembler(8080);
    jetty.assemble(assembly);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly)

Example 4 with ModuleAssembly

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

the class ApplicationDocs method createCustomerWebModule.

private static void createCustomerWebModule(LayerAssembly layer) {
    ModuleAssembly assembly = layer.module("Customer Web Module");
    assembly.transients(CustomerViewComposite.class);
    assembly.transients(CustomerEditComposite.class);
    assembly.transients(CustomerListViewComposite.class);
    assembly.transients(CustomerSearchComposite.class);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly)

Example 5 with ModuleAssembly

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

the class ApplicationActivationTest method testApplicationActivator.

@Test
public void testApplicationActivator() throws Exception {
    SingletonAssembler assembly = new SingletonAssembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.layer().application().withActivators(TestedActivator.class);
        }
    };
    // Activate
    Application application = assembly.application();
    // Assert activated
    Assert.assertEquals("Activation Level", 2, activationLevel);
    // Passivate
    application.passivate();
    // Assert passivated
    Assert.assertEquals("Passivation Level", 2, passivationLevel);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)191 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)87 Test (org.junit.Test)82 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)59 AssemblyException (org.qi4j.bootstrap.AssemblyException)27 Application (org.qi4j.api.structure.Application)26 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)24 Assembler (org.qi4j.bootstrap.Assembler)23 Module (org.qi4j.api.structure.Module)19 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)15 Before (org.junit.Before)12 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)12 Energy4Java (org.qi4j.bootstrap.Energy4Java)12 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)11 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)9 IOException (java.io.IOException)8 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)8 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)8 File (java.io.File)7 OrgJsonValueSerializationService (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService)7