private void processDestructionQueue ( HttpServletRequest request ) { Object contextsAttribute = request . getAttribute ( DESTRUCTION_QUEUE_ATTRIBUTE_NAME ) ; if ( contextsAttribute instanceof Map ) { Map < String , List < ContextualInstance < ? > > > contexts = cast ( contextsAttribute ) ; synchronized ( contexts ) { FastEvent < String > beforeDestroyedEvent = FastEvent . of ( String . class , beanManager , BeforeDestroyed . Literal . CONVERSATION ) ; FastEvent < String > destroyedEvent = FastEvent . of ( String . class , beanManager , Destroyed . Literal . CONVERSATION ) ; for ( Iterator < Entry < String , List < ContextualInstance < ? > > > > iterator = contexts . entrySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { Entry < String , List < ContextualInstance < ? > > > entry = iterator . next ( ) ; beforeDestroyedEvent . fire ( entry . getKey ( ) ) ; for ( ContextualInstance < ? > contextualInstance : entry . getValue ( ) ) { destroyContextualInstance ( contextualInstance ) ; } // Note that for the attached/current conversation we fire the destroyed event twice because we can't reliably identify such a conversation destroyedEvent . fire ( entry . getKey ( ) ) ; iterator . remove ( ) ; } } } }
If needed destroy the remaining conversation contexts after an HTTP session was invalidated within the current request .