use of org.qi4j.bootstrap.ModuleAssembly 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.ModuleAssembly in project qi4j-sdk by Qi4j.
the class DividendsMain method main.
public static void main(String[] args) throws Exception {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(ProjectedDividendsService.class).instantiateOnStartup();
module.values(DivStream.class, DivPoint.class);
new CxfAssembler().assemble(module);
}
};
final Application application = assembler.application();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
application.passivate();
} catch (Exception e) {
System.err.println("Problem shutting down Qi4j");
e.printStackTrace();
}
}
});
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class DomainEventSourceResourceSample method main.
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8080);
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
new EntityTestAssembler().assemble(module);
module.values(DomainEventValue.class, UnitOfWorkDomainEventsValue.class);
module.services(MemoryEventStoreService.class).taggedWith("domain");
module.services(DomainEventFactoryService.class);
module.importedServices(CurrentUserUoWPrincipal.class).importedBy(ImportedServiceDeclaration.NEW_OBJECT);
module.objects(CurrentUserUoWPrincipal.class);
module.objects(DomainEventSourceResource.class, PingResource.class);
module.entities(TestEntity.class).withConcerns(DomainEventCreationConcern.class);
}
};
component.getDefaultHost().attach("/events", new TestApplication(assembler));
component.getDefaultHost().attach("/ping", assembler.module().newObject(PingResource.class));
component.start();
generateTestData(assembler.module());
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class UnitOfWorkRouterTest method testData.
@Before
public void testData() throws ActivationException, AssemblyException {
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.values(UnitOfWorkDomainEventsValue.class, DomainEventValue.class);
}
};
list = new ArrayList<UnitOfWorkDomainEventsValue>();
{
ValueBuilder<UnitOfWorkDomainEventsValue> builder = assembler.module().newValueBuilder(UnitOfWorkDomainEventsValue.class);
builder.prototype().events().get().add(newDomainEvent(assembler, "Test1"));
builder.prototype().events().get().add(newDomainEvent(assembler, "Test2"));
builder.prototype().events().get().add(newDomainEvent(assembler, "Test3"));
builder.prototype().version().set("1.0");
builder.prototype().timestamp().set(System.currentTimeMillis());
builder.prototype().usecase().set("Test");
list.add(builder.newInstance());
}
{
ValueBuilder<UnitOfWorkDomainEventsValue> builder = assembler.module().newValueBuilder(UnitOfWorkDomainEventsValue.class);
builder.prototype().events().get().add(newDomainEvent(assembler, "Test4"));
builder.prototype().events().get().add(newDomainEvent(assembler, "Test5"));
builder.prototype().events().get().add(newDomainEvent(assembler, "Test6"));
builder.prototype().version().set("1.0");
builder.prototype().timestamp().set(System.currentTimeMillis());
builder.prototype().usecase().set("Test2");
list.add(builder.newInstance());
}
}
use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.
the class FileConfigurationTest method testFileConfigurationOverride.
@Test
public void testFileConfigurationOverride() throws IOException, ActivationException, AssemblyException {
File testFile = File.createTempFile(FileConfigurationTest.class.getName(), "" + System.currentTimeMillis());
final File confDir = testFile;
final File dataDir = testFile;
final File tempDir = testFile;
final File cacheDir = testFile;
final File logDir = testFile;
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
// START SNIPPET: override
FileConfigurationOverride override = new FileConfigurationOverride().withConfiguration(confDir).withData(dataDir).withTemporary(tempDir).withCache(cacheDir).withLog(logDir);
new FileConfigurationAssembler().withOverride(override).assemble(module);
// END SNIPPET: override
}
};
FileConfiguration config = assembler.module().findService(FileConfiguration.class).get();
assertEquals(testFile.getAbsolutePath(), config.configurationDirectory().getAbsolutePath());
}
Aggregations