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