protected final void assembleServer( ModuleAssembly module ) { serverModule = serverModule != null ? serverModule : module; ImportedServiceDeclaration server = serverModule.importedServices( Server.class ). importedBy( InstanceImporter.class ). setMetaInfo( new Server() ). visibleIn( serverVisibility ); if( serverIdentity != null ) { server.identifiedBy( serverIdentity ); } }
@Override public ImportedServiceDeclaration importOnStartup() { for( ImportedServiceDeclaration declaration : declarations ) { declaration.importOnStartup(); } return this; }
public void assemble( ModuleAssembly module ) throws AssemblyException { module.objects( ServiceConsumer.class ); module.importedServices( TestService.class ) .importedBy( SERVICE_SELECTOR ) .setMetaInfo( ServiceQualifier.withId( TestServiceComposite2.class.getSimpleName() ) ); ModuleAssembly module2 = module.layer().module( "Other module" ); module2.services( TestServiceComposite2.class, TestServiceComposite2.class ) .visibleIn( Visibility.layer ); } };
@Override public void assemble( ModuleAssembly module ) { super.assemble( module ); if( circuitBreaker != null ) { externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.identityOf( identity() ), externalDataSource, circuitBreaker ); } module.importedServices( DataSource.class ). identifiedBy( identity() ). visibleIn( visibility() ). setMetaInfo( externalDataSource ); } }
public void assemble( ModuleAssembly module ) throws AssemblyException { module.importedServices( TestService.class ). identifiedBy( "test" ). setMetaInfo( StringIdentity.identityOf( "testimporter" ) ). importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ); module.services( TestImporterService.class ).identifiedBy( "testimporter" ); module.objects( ServiceInstanceImporterTest.class ); }
@Override public ImportedServiceDeclaration importedBy( Class<? extends ServiceImporter> serviceImporterClass ) { for( ImportedServiceDeclaration declaration : declarations ) { declaration.importedBy( serviceImporterClass ); } return this; }
@Test public void testServiceImporterImportedServiceActivators() throws Exception { SingletonAssembler assembler = new SingletonAssembler( module -> { module.importedServices( TestedService.class ). importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ). setMetaInfo( StringIdentity.identityOf( "testimporter" ) ). withActivators( TestedActivator.class ). importOnStartup(); module.services( TestedServiceImporterService.class ).identifiedBy( "testimporter" ); } ); Application application = assembler.application(); assertEquals( "Activation Level", 2, activationLevel ); application.passivate(); assertEquals( "Passivation Level", 2, passivationLevel ); }
public void assemble( ModuleAssembly module ) throws AssemblyException { module.importedServices( TestService.class ). identifiedBy( "test" ). importedBy( ImportedServiceDeclaration.NEW_OBJECT ); module.objects( TestService.class, NewObjectImporterTest.class ); }
public void assemble( ModuleAssembly module ) throws AssemblyException { ModuleAssembly serviceModule = module.layer().module( "Service module" ); serviceModule.importedServices( TestInterface.class ) .setMetaInfo( new TestService() ) .visibleIn( Visibility.layer ); module.objects( InstanceImporterTest.class ); }
@Override public ImportedServiceDeclaration setMetaInfo( Object serviceAttribute ) { for( ImportedServiceDeclaration declaration : declarations ) { declaration.setMetaInfo( serviceAttribute ); } return this; }
@Test public void testNewObjectImportedServiceActivators() throws Exception { SingletonAssembler assembler = new SingletonAssembler( module -> { module.importedServices( TestedService.class ). importedBy( ImportedServiceDeclaration.NEW_OBJECT ). withActivators( TestedActivator.class ). importOnStartup(); module.objects( TestedServiceInstance.class ); } ); Application application = assembler.application(); assertEquals( "Activation Level", 2, activationLevel ); application.passivate(); assertEquals( "Passivation Level", 2, passivationLevel ); }
@Test public void testNewInstanceImportedServiceActivators() throws Exception { SingletonAssembler assembler = new SingletonAssembler( module -> module.importedServices( TestedService.class ) .withActivators( TestedActivator.class ) .setMetaInfo( new TestedServiceInstance() ) .importOnStartup() ); Application application = assembler.application(); assertEquals( "Activation Level", 2, activationLevel ); application.passivate(); assertEquals( "Passivation Level", 2, passivationLevel ); }
@Override public void assemble( ModuleAssembly module ) throws AssemblyException { module.importedServices( TestService.class ). setMetaInfo( new TestServiceInstance() ). importOnStartup(); }
@Override public ImportedServiceDeclaration visibleIn( Visibility visibility ) { for( ImportedServiceDeclaration declaration : declarations ) { declaration.visibleIn( visibility ); } return this; }
@Override public ImportedServiceDeclaration identifiedBy( String identity ) { for( ImportedServiceDeclaration declaration : declarations ) { declaration.identifiedBy( identity ); } return this; }
public void assemble( ModuleAssembly module ) throws AssemblyException { module.objects( ServiceConsumer.class ); module.importedServices( TestService.class ) .importedBy( SERVICE_SELECTOR ) .setMetaInfo( ServiceQualifier.withId( "TestServiceComposite2_1" ) ); ModuleAssembly module2 = module.layer().module( "Other module" ); module2.addServices( TestServiceComposite2.class, TestServiceComposite2.class ) .visibleIn( Visibility.layer ); } };
@Override public void assemble( ModuleAssembly module ) { super.assemble( module ); if( circuitBreaker != null ) { externalDataSource = DataSources.wrapWithCircuitBreaker( StringIdentity.identityOf( identity() ), externalDataSource, circuitBreaker ); } module.importedServices( DataSource.class ). identifiedBy( identity() ). visibleIn( visibility() ). setMetaInfo( externalDataSource ); } }
@Override public void assemble( ModuleAssembly module ) { module.importedServices( MBeanServer.class ).importedBy( MBeanServerImporter.class ); module.services( ApplicationManagerService.class ).instantiateOnStartup(); module.services( ConfigurationManagerService.class ).instantiateOnStartup(); } }
public final void assemble( ApplicationAssembly applicationAssembly ) throws AssemblyException { LayerAssembly layerAssembly = applicationAssembly.layer( LAYER ); ModuleAssembly moduleAssembly = layerAssembly.module( MODULE ); moduleAssembly.services( CommentServiceComposite.class ).identifiedBy( COMMENT_SERVICE_ID ); // inject Spring bean as a service moduleAssembly.importedServices( TextProcessingService.class ) .setMetaInfo( this.applicationContext.getBean( TO_UPPERCASE_SERVICE_ID ) ); }
protected final void assembleServer( ModuleAssembly module ) { serverModule = serverModule != null ? serverModule : module; ImportedServiceDeclaration server = serverModule.importedServices( Server.class ). importedBy( InstanceImporter.class ). setMetaInfo( new Server() ). visibleIn( serverVisibility ); if( serverIdentity != null ) { server.identifiedBy( serverIdentity ); } }