public ConversationReceiveListener acceptConnection ( Conversation cfConversation ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "acceptConnection" , cfConversation ) ; // Add this conversation to our active conversations list synchronized ( activeConversations ) { Object connectionReference = cfConversation . getConnectionReference ( ) ; ArrayList list = ( ArrayList ) activeConversations . get ( connectionReference ) ; if ( list == null ) { list = new ArrayList ( ) ; activeConversations . put ( connectionReference , list ) ; } else { // This is mank - but if TRM does a redirect it is possible that we may get a // connection but then they close the Conversation directly without sending us any // kind of close flow. As such, every time we connect we should have a check on all // the conversations to ensure they are not closed, and if they are remove them from // the list. ArrayList removeList = new ArrayList ( ) ; for ( int x = 0 ; x < list . size ( ) ; x ++ ) { Conversation conv = ( Conversation ) list . get ( x ) ; if ( conv . isClosed ( ) ) { removeList . add ( conv ) ; } } // Actually do the remove... for ( int x = 0 ; x < removeList . size ( ) ; x ++ ) { list . remove ( removeList . get ( x ) ) ; } } list . add ( cfConversation ) ; // At this point we have a look to see if the connection closed listener has been set. // If it has not been set then this is a new connection (or one with no active // Conversations on it. We must set ourselves as the listener in the event that the // socket terminates before any SI connections are established and so any cleanup // required. // Note that once a connection to the ME is established, this listener is overwritten // with one in ServerSideConnection. This also performs the same cleanup but also does // MFP cleanup as well (which is not appropriate if the connection goes down at this // stage). if ( cfConversation . getConnectionClosedListener ( ConversationUsageType . JFAP ) == null ) { cfConversation . addConnectionClosedListener ( this , ConversationUsageType . JFAP ) ; } } if ( cfConversation . getAttachment ( ) == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Creating conversation state" ) ; cfConversation . setAttachment ( new ConversationState ( ) ) ; } if ( cfConversation . getLinkLevelAttachment ( ) == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Creating link level state" ) ; cfConversation . setLinkLevelAttachment ( new ServerLinkLevelState ( ) ) ; } // Set a hint that this conversation is being used for ME to client communications. cfConversation . setConversationType ( Conversation . CLIENT ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "acceptConnection" , serverTransportReceiveListener ) ; return serverTransportReceiveListener ; }
Called when we are about to accept a connection from a peer .