use of org.qi4j.bootstrap.ServiceDeclaration in project qi4j-sdk by Qi4j.
the class JettyServiceAssembler method assemble.
@Override
public final void assemble(ModuleAssembly module) throws AssemblyException {
ServiceDeclaration service = module.services(httpService()).visibleIn(visibility()).instantiateOnStartup();
if (hasIdentity()) {
service.identifiedBy(identity());
}
if (hasConfig()) {
configModule().entities(configurationEntity()).visibleIn(configVisibility());
}
assembleServer(module);
}
use of org.qi4j.bootstrap.ServiceDeclaration in project qi4j-sdk by Qi4j.
the class SchedulerAssembler method assemble.
@Override
public void assemble(ModuleAssembly assembly) throws AssemblyException {
assembly.services(ScheduleFactory.class);
assembly.entities(Schedules.class);
EntityDeclaration scheduleEntities = assembly.entities(CronSchedule.class, OnceSchedule.class);
ValueDeclaration scheduleValues = assembly.values(CronSchedule.class, OnceSchedule.class);
ServiceDeclaration schedulerDeclaration = assembly.services(SchedulerService.class).visibleIn(visibility()).instantiateOnStartup();
if (timeline) {
scheduleEntities.withTypes(Timeline.class).withMixins(TimelineScheduleMixin.class).withConcerns(TimelineForScheduleConcern.class);
scheduleValues.withTypes(Timeline.class).withMixins(TimelineScheduleMixin.class).withConcerns(TimelineForScheduleConcern.class);
// Internal
assembly.values(TimelineRecord.class);
schedulerDeclaration.withTypes(Timeline.class).withMixins(TimelineSchedulerServiceMixin.class);
}
if (hasConfig()) {
configModule().entities(SchedulerConfiguration.class).visibleIn(configVisibility());
}
}
use of org.qi4j.bootstrap.ServiceDeclaration in project qi4j-sdk by Qi4j.
the class ServiceInjectionTest method testInjectionServiceBetweenLayers.
@Test
public void testInjectionServiceBetweenLayers() throws ActivationException, AssemblyException {
SingletonAssembler assembly = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
module.services(StringService.class, LongService.class);
LayerAssembly layerAssembly = module.layer();
module.objects(ServiceUser.class);
ApplicationAssembly applicationAssembly = layerAssembly.application();
LayerAssembly layer2Assembly = applicationAssembly.layer("Other layer");
layerAssembly.uses(layer2Assembly);
ModuleAssembly module2 = layer2Assembly.module("Other module");
ServiceDeclaration service2Decl = module2.services(MyServiceComposite2.class);
service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(application);
}
};
testInjection(assembly);
}
use of org.qi4j.bootstrap.ServiceDeclaration in project qi4j-sdk by Qi4j.
the class ServiceInjectionTest method testInjectionServiceBetweenModules.
@Test
public void testInjectionServiceBetweenModules() throws ActivationException, AssemblyException {
SingletonAssembler assembly = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
module.services(StringService.class, LongService.class);
module.objects(ServiceUser.class);
ModuleAssembly module2 = module.layer().module("Other module");
ServiceDeclaration service2Decl = module2.services(MyServiceComposite.class);
service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(layer);
ServiceDeclaration service3Decl = module2.services(MyServiceComposite2.class);
service3Decl.identifiedBy("Boo").setMetaInfo(new ServiceName("Boo"));
}
};
testInjection(assembly);
}
use of org.qi4j.bootstrap.ServiceDeclaration in project qi4j-sdk by Qi4j.
the class MongoMapEntityStoreAssembler method assemble.
@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(UuidIdentityGeneratorService.class).visibleIn(visibility());
ServiceDeclaration service = module.services(MongoMapEntityStoreService.class).visibleIn(visibility());
if (hasIdentity()) {
service.identifiedBy(identity());
}
if (hasConfig()) {
configModule().entities(MongoEntityStoreConfiguration.class).visibleIn(configVisibility());
}
}
Aggregations