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();
}
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;
}
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 )")));
}
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);
}
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();
}
}
Aggregations