@Override public ImportedServiceDeclaration importOnStartup() { for( ImportedServiceDeclaration declaration : declarations ) { declaration.importOnStartup(); } return this; }
@Override public void assemble( ModuleAssembly module ) throws AssemblyException { module.importedServices( TestService.class ). setMetaInfo( new TestServiceInstance() ). importOnStartup(); }
@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 ); }
@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 ); }