void lifecycleAvailable ( Lifecycle lifecycle ) { LOG . debug ( "Lifecycle now available, draining queue" ) ; // First, make sure we will not let any more listeners be added once the lifecycle starts going. lifecycle . addListener ( LifecycleStage . CONFIGURE_STAGE , new LifecycleListener ( ) { @ Override public void onStage ( LifecycleStage lifecycleStage ) { LOG . debug ( "Lifecycle started, further injections disallowed" ) ; LifecycleAnnotationFinder . this . lifecycle = null ; // Now both lifecycle and foundInvocations are null, triggering ISE on further discoveries } } ) ; // Now direct further visits to the lifecycle directly this . lifecycle = lifecycle ; // Now drain out all the previous ones into the lifecycle and remove the list itself for ( LifecycleInvocation invocation : foundInvocations ) { addListener ( invocation ) ; } foundInvocations = null ; }
Called once Guice has created our Lifecycle so we can start registering callbacks