use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class TypeToCompositeLookupTest method services.
@Test
public void services() throws ActivationException, AssemblyException {
Module module = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(SomeOtherFoo.class);
}
}.module();
assertEquals(CATHEDRAL, module.findService(SomeOtherFoo.class).get().bar());
assertEquals(CATHEDRAL, module.findService(BasicFoo.class).get().bar());
assertEquals(CATHEDRAL, module.findService(Foo.class).get().bar());
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class TransientBuilderFactoryTest method newInstanceForNullType.
/**
* Tests that a transient composite instance cannot be created for a 'null' type.
*
* @throws Exception expected
*/
@Test(expected = NullArgumentException.class)
public void newInstanceForNullType() throws Exception {
SingletonAssembler assembler = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
}
};
assembler.module().newTransient(null);
}
use of org.qi4j.bootstrap.SingletonAssembler 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.SingletonAssembler 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.SingletonAssembler 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());
}
}
Aggregations