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