Search in sources :

Example 11 with ServiceDeclaration

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);
}
Also used : ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration) ImportedServiceDeclaration(org.qi4j.bootstrap.ImportedServiceDeclaration)

Example 12 with ServiceDeclaration

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());
    }
}
Also used : Timeline(org.qi4j.library.scheduler.timeline.Timeline) SchedulerConfiguration(org.qi4j.library.scheduler.SchedulerConfiguration) EntityDeclaration(org.qi4j.bootstrap.EntityDeclaration) ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration) TimelineScheduleMixin(org.qi4j.library.scheduler.timeline.TimelineScheduleMixin) ValueDeclaration(org.qi4j.bootstrap.ValueDeclaration)

Example 13 with ServiceDeclaration

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);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) Test(org.junit.Test)

Example 14 with ServiceDeclaration

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);
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Test(org.junit.Test)

Example 15 with ServiceDeclaration

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());
    }
}
Also used : UuidIdentityGeneratorService(org.qi4j.spi.uuid.UuidIdentityGeneratorService) ServiceDeclaration(org.qi4j.bootstrap.ServiceDeclaration)

Aggregations

ServiceDeclaration (org.qi4j.bootstrap.ServiceDeclaration)20 UuidIdentityGeneratorService (org.qi4j.spi.uuid.UuidIdentityGeneratorService)11 Test (org.junit.Test)2 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)2 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)2 Preferences (java.util.prefs.Preferences)1 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)1 EntityDeclaration (org.qi4j.bootstrap.EntityDeclaration)1 ImportedServiceDeclaration (org.qi4j.bootstrap.ImportedServiceDeclaration)1 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)1 ValueDeclaration (org.qi4j.bootstrap.ValueDeclaration)1 FileEntityStoreConfiguration (org.qi4j.entitystore.file.FileEntityStoreConfiguration)1 FileEntityStoreService (org.qi4j.entitystore.file.FileEntityStoreService)1 HazelcastConfiguration (org.qi4j.entitystore.hazelcast.HazelcastConfiguration)1 JdbmConfiguration (org.qi4j.entitystore.jdbm.JdbmConfiguration)1 JdbmEntityStoreService (org.qi4j.entitystore.jdbm.JdbmEntityStoreService)1 MemoryEntityStoreService (org.qi4j.entitystore.memory.MemoryEntityStoreService)1 PreferencesEntityStoreInfo (org.qi4j.entitystore.prefs.PreferencesEntityStoreInfo)1 PreferencesEntityStoreService (org.qi4j.entitystore.prefs.PreferencesEntityStoreService)1 VoldemortConfiguration (org.qi4j.entitystore.voldemort.VoldemortConfiguration)1