@Override @SafeVarargs public final ImportedServiceDeclaration withActivators( Class<? extends Activator<?>>... activators ) { for( ImportedServiceDeclaration declaration : declarations ) { declaration.withActivators( activators ); } 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 ); }
@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 ); }