protected NetworkConnection getNetworkConnectionInstance ( VirtualConnection vc ) { if ( tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "getNetworkConnectionInstance" , vc ) ; NetworkConnection retConn = null ; if ( vc != null ) { // Default to the connection that we were created from retConn = conn ; if ( vc != ( ( CFWNetworkConnection ) conn ) . getVirtualConnection ( ) ) { // The connection is different - nothing else to do but create a new instance retConn = new CFWNetworkConnection ( vc ) ; } } if ( tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "getNetworkConnectionInstance" , retConn ) ; return retConn ; }
This method tries to avoid creating a new instance of a CFWNetworkConnection object by seeing if the specified virtual connection is the one that we are wrapping in the CFWNetworkConnection instance that created this context . If it is we simply return that . Otherwise we must create a new instance .