@ FFDCIgnore ( NamingException . class ) public void releaseDirContext ( TimedDirContext ctx ) throws WIMSystemException { final String METHODNAME = "releaseDirContext" ; if ( iContextPoolEnabled ) { //Get the lock for the current domain synchronized ( iLock ) { // If the DirContextTTL is 0, no need to put it back to pool // If the size of the pool is larger than minimum size or total dirContexts larger than max size // If context URL no longer matches active URL, then discard if ( iContexts . size ( ) >= iPrefPoolSize || ( iMaxPoolSize != 0 && iLiveContexts > iMaxPoolSize ) || ctx . getCreateTimestamp ( ) < iPoolCreateTimestampSeconds || ! getProviderURL ( ctx ) . equalsIgnoreCase ( getActiveURL ( ) ) ) { try { iLiveContexts -- ; //PM95697 ctx . close ( ) ; } catch ( NamingException e ) { String msg = Tr . formatMessage ( tc , WIMMessageKey . NAMING_EXCEPTION , WIMMessageHelper . generateMsgParms ( e . toString ( true ) ) ) ; throw new WIMSystemException ( WIMMessageKey . NAMING_EXCEPTION , msg , e ) ; } if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , METHODNAME + " Context is discarded." ) ; } } else { if ( iContexts != null && iContexts . size ( ) > 0 && iContexts . contains ( ctx ) ) { if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , METHODNAME + " Context already present in Context pool. No need to add it again to context pool. ContextPool: total=" + iLiveContexts + ", poolSize=" + iContexts . size ( ) ) ; } } else { if ( iContexts != null ) iContexts . add ( ctx ) ; if ( iPoolTimeOut > 0 ) { ctx . setPoolTimeStamp ( roundToSeconds ( System . currentTimeMillis ( ) ) ) ; } if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , METHODNAME + " Before Notifying the waiting threads and Context is back to pool. ContextPool: total=" + iLiveContexts + ", poolSize=" + iContexts . size ( ) ) ; } } iLock . notifyAll ( ) ; if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , METHODNAME + " Context is back to pool." ) ; } } } if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , METHODNAME + " ContextPool: total=" + iLiveContexts + ", poolSize=" + iContexts . size ( ) ) ; } } else { try { ctx . close ( ) ; } catch ( NamingException e ) { String msg = Tr . formatMessage ( tc , WIMMessageKey . NAMING_EXCEPTION , WIMMessageHelper . generateMsgParms ( e . toString ( true ) ) ) ; throw new WIMSystemException ( WIMMessageKey . NAMING_EXCEPTION , msg , e ) ; } } }
Release the given directory context .