private CacheMap getStatementCache ( ) { int newSize = dsConfig . get ( ) . statementCacheSize ; // Check if statement cache is dynamically enabled if ( statementCache == null && newSize > 0 ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "enable statement cache with size" , newSize ) ; statementCache = new CacheMap ( newSize ) ; } // Check if statement cache is dynamically resized or disabled else if ( statementCache != null && statementCache . getMaxSize ( ) != newSize ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "resize statement cache to" , newSize ) ; CacheMap oldCache = statementCache ; statementCache = newSize > 0 ? new CacheMap ( newSize ) : null ; Object [ ] discards = newSize > 0 ? statementCache . addAll ( oldCache ) : oldCache . removeAll ( ) ; for ( Object stmt : discards ) destroyStatement ( stmt ) ; } return statementCache ; }
Processes any dynamic updates to the statement cache size and then returns the statement cache .