public static void dispatchEvent( HttpSession session, EventType eventType, HttpConnection connection, AsyncContext context )
    {
        for ( final SessionListener listener : listeners )
        {
            try
            {
                switch ( eventType )
                {
                    case connection_opened:
                        listener.connectionOpened( context, session, connection );
                        break;

                    case connection_closed:
                        listener.connectionClosed( context, session, connection );
                        break;

                    case pre_session_created:
                        listener.preSessionCreated( context );
                        break;

                    case post_session_created:
                        listener.postSessionCreated( context, session );
                        break;

                    case session_closed:
                        listener.sessionClosed( session );
                        break;

                    default:
                        throw new IllegalStateException( "An unexpected and unsupported event type was used: " + eventType );
                }
            }
            catch ( Exception e )
            {
                Log.warn( "An exception occurred while dispatching an event of type {}", eventType, e );
            }
        }
    }
Dispatches an event related to a particular BOSH session to all registered listeners.

@param session The session that relates to the event (can be null when the event type is 'pre_session_created').
@param eventType The type of the event (cannot be null).
@param connection The connection where the event originated.
@param context The servlet context of the event
xmppserver/src/main/java/org/jivesoftware/openfire/http/SessionEventDispatcher.java