Search in sources :

Example 16 with Energy4Java

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

the class QueryPerformanceTest method setup.

@Before
public void setup() throws Exception {
    Energy4Java qi4j = new Energy4Java();
    application = qi4j.newApplication(this);
    module = application.findModule(LAYER_DOMAIN, MODULE_DOMAIN);
    application.activate();
    indexingDataDir = module.findService(RdfIndexingService.class).get().dataDir();
}
Also used : RdfIndexingService(org.qi4j.index.rdf.indexing.RdfIndexingService) Energy4Java(org.qi4j.bootstrap.Energy4Java) Before(org.junit.Before)

Example 17 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java 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 18 with Energy4Java

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

the class VisitableDetailTest method visit.

@Test
public void visit() throws AssemblyException, ActivationException {
    ApplicationDescriptor application = new Energy4Java().newApplicationModel(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            ApplicationAssembly app = applicationFactory.newApplicationAssembly();
            app.setName("UnderTestApp");
            app.withActivators(ApplicationActivator.class);
            LayerAssembly layer = app.layer("LayerName");
            layer.withActivators(LayerActivator.class);
            ModuleAssembly module = layer.module("ModuleName");
            module.withActivators(ModuleActivator.class);
            return app;
        }
    });
    ApplicationDetailDescriptor detail = createApplicationDetailDescriptor(application);
    Visitor visitor = new Visitor();
    detail.accept(visitor);
    assertThat(visitor.events, equalTo(Arrays.asList(// Application
    "visitEnter( UnderTestApp )", "visit( " + ApplicationActivator.class.getName() + " )", // Layer
    "visitEnter( LayerName )", "visit( " + LayerActivator.class.getName() + " )", // Module
    "visitEnter( ModuleName )", "visit( " + ModuleActivator.class.getName() + " )", // Leaving Structure
    "visitLeave( ModuleName )", "visitLeave( LayerName )", "visitLeave( UnderTestApp )")));
}
Also used : ApplicationAssemblyFactory(org.qi4j.bootstrap.ApplicationAssemblyFactory) ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor) ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) HierarchicalVisitor(org.qi4j.functional.HierarchicalVisitor) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java) Test(org.junit.Test)

Example 19 with Energy4Java

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

the class EnvisageSchoolSample method main.

// START SNIPPET: envisage
public static void main(String[] args) throws Exception {
    Energy4Java energy4Java = new Energy4Java();
    ApplicationDescriptor applicationModel = energy4Java.newApplicationModel(new SchoolAssembler());
    new Envisage().run(applicationModel);
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) Envisage(org.qi4j.envisage.Envisage)

Example 20 with Energy4Java

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

the class DocumentationSupport method assembledWithValuesModuleSerialization.

// END SNIPPET: io
@Test
public // TODO Include in each ValueSerialization extensions documentation
void assembledWithValuesModuleSerialization() throws Exception {
    Application app = new Energy4Java().newApplication(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            Assembler[][][] pancakes = new Assembler[][][] { { { new Assembler() {

                @Override
                public void assemble(ModuleAssembly valuesModule) throws AssemblyException {
                    valuesModule.layer().setName("SINGLE-Layer");
                    valuesModule.setName("VALUES-Module");
                    valuesModule.values(SomeValue.class);
                }
            } }, { new Assembler() {

                @Override
                public void assemble(ModuleAssembly servicesModule) throws AssemblyException {
                    servicesModule.setName("SERVICES-Module");
                    Function<Application, Module> valuesModuleFinder = new Function<Application, Module>() {

                        @Override
                        public Module map(Application app) {
                            return app.findModule("SINGLE-Layer", "VALUES-Module");
                        }
                    };
                    new OrgJsonValueSerializationAssembler().withValuesModuleFinder(valuesModuleFinder).assemble(servicesModule);
                }
            } } } };
            return applicationFactory.newApplicationAssembly(pancakes);
        }
    });
    app.activate();
    try {
        Module valuesModule = app.findModule("SINGLE-Layer", "VALUES-Module");
        SomeValue someValue = someNewValueInstance(valuesModule);
        Module servicesModule = app.findModule("SINGLE-Layer", "SERVICES-Module");
        ValueSerialization valueSerialization = servicesModule.findService(ValueSerialization.class).get();
        String json = valueSerialization.serialize(someValue);
        assertThat(json, equalTo("{\"foo\":\"bar\"}"));
        SomeValue someNewValue = valueSerialization.deserialize(SomeValue.class, json);
        assertThat(someNewValue, equalTo(someValue));
    } finally {
        app.passivate();
    }
}
Also used : ApplicationAssemblyFactory(org.qi4j.bootstrap.ApplicationAssemblyFactory) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Function(org.qi4j.functional.Function) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Aggregations

Energy4Java (org.qi4j.bootstrap.Energy4Java)39 Assembler (org.qi4j.bootstrap.Assembler)19 Application (org.qi4j.api.structure.Application)18 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Test (org.junit.Test)15 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)12 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)11 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)8 AssemblyException (org.qi4j.bootstrap.AssemblyException)8 Before (org.junit.Before)7 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)7 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)7 Module (org.qi4j.api.structure.Module)6 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)6 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)4 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)3 Envisage (org.qi4j.envisage.Envisage)3 UnitOfWorkCompletionException (org.qi4j.api.unitofwork.UnitOfWorkCompletionException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1