public final MobicentsSipSession getSipSession ( ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "getSipSession" ) ; } if ( sipSession == null && sessionKey == null ) { sessionKey = getSipSessionKey ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "sessionKey is " + sessionKey ) ; } if ( sessionKey == null ) { if ( sipSession == null ) { if ( transactionApplicationData != null ) { this . sessionKey = transactionApplicationData . getSipSessionKey ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "session Key is " + sessionKey + ", retrieved from the txAppData " + transactionApplicationData ) ; } } else if ( transaction != null && transaction . getApplicationData ( ) != null ) { this . sessionKey = ( ( TransactionApplicationData ) transaction . getApplicationData ( ) ) . getSipSessionKey ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "session Key is " + sessionKey + ", retrieved from the transaction txAppData " + ( TransactionApplicationData ) transaction . getApplicationData ( ) ) ; } } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "txAppData and transaction txAppData are both null, there is no wya to retrieve the sessionKey anymore" ) ; } } } else { this . sessionKey = sipSession . getKey ( ) ; } } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "sessionKey is " + sessionKey ) ; } } if ( sipSession == null && sessionKey != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "session is null, trying to load the session from the sessionKey " + sessionKey ) ; } final String applicationName = sessionKey . getApplicationName ( ) ; final SipContext sipContext = sipFactoryImpl . getSipApplicationDispatcher ( ) . findSipApplication ( applicationName ) ; SipApplicationSessionKey sipApplicationSessionKey = new SipApplicationSessionKey ( sessionKey . getApplicationSessionId ( ) , sessionKey . getApplicationName ( ) , null ) ; MobicentsSipApplicationSession sipApplicationSession = sipContext . getSipManager ( ) . getSipApplicationSession ( sipApplicationSessionKey , false ) ; sipSession = sipContext . getSipManager ( ) . getSipSession ( sessionKey , false , sipFactoryImpl , sipApplicationSession ) ; if ( logger . isDebugEnabled ( ) ) { if ( sipSession == null ) { logger . debug ( "couldn't find any session with sessionKey " + sessionKey ) ; } else { logger . debug ( "reloaded session session " + sipSession + " with sessionKey " + sessionKey ) ; } } } return sipSession ; }
Retrieve the sip session implementation