use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class HelloWorldTest method setUp.
@Before
public void setUp() throws Exception {
SingletonAssembler assembly = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(HelloWorldComposite.class);
}
};
helloWorld = assembly.module().newTransientBuilder(HelloWorldComposite.class).newInstance();
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class HelloWorldTest method setUp.
@Before
public void setUp() throws Exception {
SingletonAssembler assembly = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(HelloWorldComposite.class);
}
};
helloWorld = assembly.module().newTransient(HelloWorldComposite.class);
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class HelloWorldTest method setUp.
@Before
public void setUp() throws Exception {
SingletonAssembler assembly = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.transients(HelloWorldComposite.class);
}
};
helloWorld = assembly.module().newTransientBuilder(HelloWorldComposite.class).newInstance();
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class Main method main.
public static void main(String[] args) throws Exception {
SingletonAssembler assembler = new // <1>
SingletonAssembler() {
@Override
public void assemble(ModuleAssembly assembly) throws AssemblyException {
// <2>
assembly.transients(Speaker.class);
}
};
// <3>
Speaker speaker = assembler.module().newTransient(Speaker.class);
System.out.println(speaker.sayHello());
}
use of org.qi4j.bootstrap.SingletonAssembler in project qi4j-sdk by Qi4j.
the class ActivationEventsTest method testSingleModuleSingleLazyService.
@Test
public void testSingleModuleSingleLazyService() throws Exception {
final List<ActivationEvent> events = new ArrayList<>();
SingletonAssembler assembler = new SingletonAssembler() {
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(TestServiceComposite.class);
}
@Override
protected void beforeActivation(Application application) {
application.registerActivationEventListener(new EventsRecorder(events));
}
};
Application application = assembler.application();
application.passivate();
Iterator<ActivationEvent> it = events.iterator();
// Activation
assertEvent(it.next(), ACTIVATING, "Application");
assertEvent(it.next(), ACTIVATING, "Layer");
assertEvent(it.next(), ACTIVATING, "Module");
// Lazy Service NOT activated
assertEvent(it.next(), ACTIVATED, "Module");
assertEvent(it.next(), ACTIVATED, "Layer");
assertEvent(it.next(), ACTIVATED, "Application");
// Passivation
assertEvent(it.next(), PASSIVATING, "Application");
assertEvent(it.next(), PASSIVATING, "Layer");
assertEvent(it.next(), PASSIVATING, "Module");
// Lazy Service NOT passivated
assertEvent(it.next(), PASSIVATED, "Module");
assertEvent(it.next(), PASSIVATED, "Layer");
assertEvent(it.next(), PASSIVATED, "Application");
assertFalse(it.hasNext());
events.clear();
application.activate();
Module module = assembler.module();
module.findService(TestService.class).get().test();
application.passivate();
for (ActivationEvent event : events) {
System.out.println(event);
}
it = events.iterator();
// Activation
assertEvent(it.next(), ACTIVATING, "Application");
assertEvent(it.next(), ACTIVATING, "Layer");
assertEvent(it.next(), ACTIVATING, "Module");
assertEvent(it.next(), ACTIVATED, "Module");
assertEvent(it.next(), ACTIVATED, "Layer");
assertEvent(it.next(), ACTIVATED, "Application");
// Lazy Service Activation
assertEvent(it.next(), ACTIVATING, "TestService");
assertEvent(it.next(), ACTIVATED, "TestService");
// Passivation
assertEvent(it.next(), PASSIVATING, "Application");
assertEvent(it.next(), PASSIVATING, "Layer");
assertEvent(it.next(), PASSIVATING, "Module");
assertEvent(it.next(), PASSIVATING, "TestService");
assertEvent(it.next(), PASSIVATED, "TestService");
assertEvent(it.next(), PASSIVATED, "Module");
assertEvent(it.next(), PASSIVATED, "Layer");
assertEvent(it.next(), PASSIVATED, "Application");
assertFalse(it.hasNext());
}
Aggregations