@ Reference ( service = Application . class , cardinality = ReferenceCardinality . MULTIPLE , policy = ReferencePolicy . DYNAMIC , target = "(application.state=STARTED)" ) protected void addStartedApplication ( ServiceReference < Application > ref ) { ExecutorService executor ; String appName = ( String ) ref . getProperty ( NAME ) ; Set < Runnable > tasks ; lock . writeLock ( ) . lock ( ) ; try { executor = this . executor ; appStates . put ( appName , ApplicationState . STARTED ) ; tasks = deferredTasks . remove ( appName ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } if ( tasks != null ) for ( Runnable task : tasks ) executor . submit ( task ) ; }
Declarative Services method for setting a started Application instance