You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2014/02/23 11:37:52 UTC
svn commit: r1570993 [3/24] - in /commons/proper/jcs/trunk/src: assembly/
changes/ conf/ java/org/apache/commons/jcs/access/
java/org/apache/commons/jcs/access/exception/
java/org/apache/commons/jcs/admin/ java/org/apache/commons/jcs/auxiliary/
java/or...
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCache.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCache.java Sun Feb 23 10:37:48 2014
@@ -1,570 +1,589 @@
-package org.apache.commons.jcs.auxiliary.disk.file;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.IElementSerializer;
-import org.apache.commons.jcs.engine.logging.behavior.ICacheEvent;
-import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
-import org.apache.commons.jcs.utils.timing.SleepUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This disk cache writes each item to a separate file. This is for regions with very few items,
- * perhaps big ones.
- * <p>
- * This is a fairly simple implementation. All the disk writing is handled right here. It's not
- * clear that anything more complicated is needed.
- */
-public class FileDiskCache<K extends Serializable, V extends Serializable>
- extends AbstractDiskCache<K, V>
-{
- /** Don't change */
- private static final long serialVersionUID = 1L;
-
- /** The logger. */
- private static final Log log = LogFactory.getLog( FileDiskCache.class );
-
- /** The name to prefix all log messages with. */
- private final String logCacheName;
-
- /** The config values. */
- private final FileDiskCacheAttributes diskFileCacheAttributes;
-
- /** The directory where the files are stored */
- private File directory;
-
- /**
- * Constructor for the DiskCache object.
- * <p>
- * @param cacheAttributes
- */
- public FileDiskCache( FileDiskCacheAttributes cacheAttributes )
- {
- this( cacheAttributes, null );
- }
-
- /**
- * Constructor for the DiskCache object. Will be marked alive if the directory cannot be
- * created.
- * <p>
- * @param cattr
- * @param elementSerializer used if supplied, the super's super will not set a null
- */
- public FileDiskCache( FileDiskCacheAttributes cattr, IElementSerializer elementSerializer )
- {
- super( cattr );
- setElementSerializer( elementSerializer );
- this.diskFileCacheAttributes = cattr;
- this.logCacheName = "Region [" + getCacheName() + "] ";
- alive = initializeFileSystem( cattr );
- }
-
- /**
- * Tries to create the root directory if it does not already exist.
- * <p>
- * @param cattr
- * @return does the directory exist.
- */
- private boolean initializeFileSystem( FileDiskCacheAttributes cattr )
- {
- // TODO, we might need to make this configurable
- String rootDirName = cattr.getDiskPath() + "/" + cattr.getCacheName();
- this.setDirectory( new File( rootDirName ) );
- boolean createdDirectories = getDirectory().mkdirs();
- if ( log.isInfoEnabled() )
- {
- log.info( logCacheName + "Cache file root directory: " + rootDirName );
- log.info( logCacheName + "Created root directory: " + createdDirectories );
- }
-
- // TODO consider throwing.
- boolean exists = getDirectory().exists();
- if ( !exists )
- {
- log.error( "Could not initialize File Disk Cache. The root directory does not exist." );
- }
- return exists;
- }
-
- /**
- * Creates the file for a key. Filenames and keys can be passed into this method. It must be
- * idempotent.
- * <p>
- * Protected for testing.
- * <p>
- * @param key
- * @return the file for the key
- */
- protected <KK extends Serializable> File file( KK key )
- {
- StringBuffer fileNameBuffer = new StringBuffer();
-
- // add key as filename in a file system safe way
- String keys = key.toString();
- int l = keys.length();
- for ( int i = 0; i < l; i++ )
- {
- char c = keys.charAt( i );
- if ( !Character.isLetterOrDigit( c ) )
- {
- c = '_';
- }
- fileNameBuffer.append( c );
- }
- String fileName = fileNameBuffer.toString();
-
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Creating file for name: [" + fileName + "] based on key: [" + key + "]" );
- }
-
- return new File( getDirectory().getAbsolutePath(), fileName );
- }
-
- /**
- * Return the keys in this cache.
- * <p>
- * @see org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache#getKeySet()
- */
- @Override
- public Set<K> getKeySet() throws IOException
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @return dir.list().length
- */
- @Override
- public int getSize()
- {
- if ( getDirectory().exists() )
- {
- return getDirectory().list().length;
- }
- return 0;
- }
-
- /**
- * @return AuxiliaryCacheAttributes
- */
- public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
- {
- return diskFileCacheAttributes;
- }
-
- /**
- * @return String the path to the directory
- */
- @Override
- protected String getDiskLocation()
- {
- return getDirectory().getAbsolutePath();
- }
-
- /**
- * Sets alive to false.
- * <p>
- * @throws IOException
- */
- @Override
- protected synchronized void processDispose()
- throws IOException
- {
- ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
- try
- {
- if ( !alive )
- {
- log.error( logCacheName + "Not alive and dispose was called, directgory: " + getDirectory() );
- return;
- }
-
- // Prevents any interaction with the cache while we're shutting down.
- alive = false;
-
- // TODO consider giving up the handle on the directory.
- if ( log.isInfoEnabled() )
- {
- log.info( logCacheName + "Shutdown complete." );
- }
- }
- finally
- {
- logICacheEvent( cacheEvent );
- }
- }
-
- /**
- * Looks for a file matching the key. If it exists, reads the file.
- * <p>
- * @param key
- * @return ICacheElement
- * @throws IOException
- */
- @Override
- protected ICacheElement<K, V> processGet( K key )
- throws IOException
- {
- File file = file( key );
-
- if ( !file.exists() )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( "File does not exist. Returning null from Get." + file );
- }
- return null;
- }
-
- ICacheElement<K, V> element = null;
-
- FileInputStream fis = null;
- try
- {
- fis = new FileInputStream( file );
-
- long length = file.length();
- // Create the byte array to hold the data
- byte[] bytes = new byte[(int) length];
-
- int offset = 0;
- int numRead = 0;
- while ( offset < bytes.length && ( numRead = fis.read( bytes, offset, bytes.length - offset ) ) >= 0 )
- {
- offset += numRead;
- }
-
- // Ensure all the bytes have been read in
- if ( offset < bytes.length )
- {
- throw new IOException( "Could not completely read file " + file.getName() );
- }
-
- element = getElementSerializer().deSerialize( bytes );
-
- // test that the retrieved object has equal key
- if ( element != null && !key.equals( element.getKey() ) )
- {
- if ( log.isInfoEnabled() )
- {
- log.info( logCacheName + "key: [" + key + "] point to cached object with key: [" + element.getKey()
- + "]" );
- }
- element = null;
- }
- }
- catch ( IOException e )
- {
- log.error( logCacheName + "Failure getting element, key: [" + key + "]", e );
- }
- catch ( ClassNotFoundException e )
- {
- log.error( logCacheName + "Failure getting element, key: [" + key + "]", e );
- }
- finally
- {
- silentClose( fis );
- }
-
- // If this is true and we have a max file size, the Least Recently Used file will be removed.
- if ( element != null && diskFileCacheAttributes.isTouchOnGet() )
- {
- touchWithRetry( file );
- }
- return element;
- }
-
- /**
- * @param pattern
- * @return Map
- * @throws IOException
- */
- @Override
- protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
- throws IOException
- {
- // TODO get a list of file and return those with matching keys.
- // the problem will be to handle the underscores.
- return null;
- }
-
- /**
- * Removes the file.
- * <p>
- * @param key
- * @return true if the item was removed
- * @throws IOException
- */
- @Override
- protected boolean processRemove( K key )
- throws IOException
- {
- return _processRemove(key);
- }
-
- /**
- * Removes the file.
- * <p>
- * @param key
- * @return true if the item was removed
- * @throws IOException
- */
- private <T extends Serializable> boolean _processRemove( T key )
- throws IOException
- {
- File file = file( key );
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Removing file " + file );
- }
- return deleteWithRetry( file );
- }
-
- /**
- * Remove all the files in the directory.
- * <p>
- * Assumes that this is the only region in the directory. We could add a region prefix to the
- * files and only delete those, but the region should create a directory.
- * <p>
- * @throws IOException
- */
- @Override
- protected void processRemoveAll()
- throws IOException
- {
- String[] fileNames = getDirectory().list();
- for ( int i = 0; i < fileNames.length; i++ )
- {
- _processRemove( fileNames[i] );
- }
- }
-
- /**
- * We create a temp file with the new contents, remove the old if it exists, and then rename the
- * temp.
- * <p>
- * @param element
- * @throws IOException
- */
- @Override
- protected void processUpdate( ICacheElement<K, V> element )
- throws IOException
- {
- removeIfLimitIsSetAndReached();
-
- File file = file( element.getKey() );
-
- File tmp = null;
- OutputStream os = null;
- try
- {
- byte[] bytes = getElementSerializer().serialize( element );
-
- tmp = File.createTempFile( "JCS_DiskFileCache", null, getDirectory() );
-
- FileOutputStream fos = new FileOutputStream( tmp );
- os = new BufferedOutputStream( fos );
-
- if ( bytes != null )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Wrote " + bytes.length + " bytes to file " + tmp );
- }
- os.write( bytes );
- os.close();
- }
- deleteWithRetry( file );
- tmp.renameTo( file );
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Renamed to: " + file );
- }
- }
- catch ( IOException e )
- {
- log.error( logCacheName + "Failure updating element, key: [" + element.getKey() + "]", e );
- }
- finally
- {
- silentClose( os );
- if ( ( tmp != null ) && tmp.exists() )
- {
- deleteWithRetry( tmp );
- }
- }
- }
-
- /**
- * If a limit has been set and we have reached it, remove the least recently modified file.
- * <p>
- * We will probably need to touch the files. If we touch, the LRM file will be based on age
- * (i.e. FIFO). If we touch, it will be based on access time (i.e. LRU).
- */
- private void removeIfLimitIsSetAndReached()
- {
- if ( diskFileCacheAttributes.getMaxNumberOfFiles() > 0 )
- {
- // TODO we might want to synchronize this block.
- if ( getSize() >= diskFileCacheAttributes.getMaxNumberOfFiles() )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Max reached, removing least recently modifed" );
- }
-
- long oldestLastModified = System.currentTimeMillis();
- File theLeastRecentlyModified = null;
- String[] fileNames = getDirectory().list();
- for ( int i = 0; i < fileNames.length; i++ )
- {
- File file = file( fileNames[i] );
- long lastModified = file.lastModified();
- if ( lastModified < oldestLastModified )
- {
- oldestLastModified = lastModified;
- theLeastRecentlyModified = file;
- }
- }
- if ( theLeastRecentlyModified != null )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Least recently modifed: " + theLeastRecentlyModified );
- }
- deleteWithRetry( theLeastRecentlyModified );
- }
- }
- }
- }
-
- /**
- * Tries to delete a file. If it fails, it tries several more times, pausing a few ms. each
- * time.
- * <p>
- * @param file
- * @return true if the file does not exist or if it was removed
- */
- private boolean deleteWithRetry( File file )
- {
- boolean success = file.delete();
-
- // TODO: The following should be identical to success == false, but it isn't
- if ( file.exists() )
- {
- int maxRetries = diskFileCacheAttributes.getMaxRetriesOnDelete();
- for ( int i = 0; i < maxRetries && !success; i++ )
- {
- SleepUtil.sleepAtLeast( 5 );
- success = file.delete();
- }
- }
- else
- {
- success = true;
- }
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "deleteWithRetry. success= " + success + " file: " + file );
- }
- return success;
- }
-
- /**
- * Tries to set the last access time to now.
- * <p>
- * @param file to touch
- * @return was it successful
- */
- private boolean touchWithRetry( File file )
- {
- boolean success = file.setLastModified( System.currentTimeMillis() );
- if ( !success )
- {
- int maxRetries = diskFileCacheAttributes.getMaxRetriesOnTouch();
- if ( file.exists() )
- {
- for ( int i = 0; i < maxRetries && !success; i++ )
- {
- SleepUtil.sleepAtLeast( 5 );
- success = file.delete();
- }
- }
- }
- if ( log.isDebugEnabled() )
- {
- log.debug( logCacheName + "Last modified, success: " + success );
- }
- return success;
- }
-
- /**
- * Closes a stream and swallows errors.
- * <p>
- * @param s the stream
- */
- private void silentClose( InputStream s )
- {
- if ( s != null )
- {
- try
- {
- s.close();
- }
- catch ( IOException e )
- {
- log.error( logCacheName + "Failure closing stream", e );
- }
- }
- }
-
- /**
- * Closes a stream and swallows errors.
- * <p>
- * @param s the stream
- */
- private void silentClose( OutputStream s )
- {
- if ( s != null )
- {
- try
- {
- s.close();
- }
- catch ( IOException e )
- {
- log.error( logCacheName + "Failure closing stream", e );
- }
- }
- }
-
- /**
- * @param directory the directory to set
- */
- protected void setDirectory( File directory )
- {
- this.directory = directory;
- }
-
- /**
- * @return the directory
- */
- protected File getDirectory()
- {
- return directory;
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
+import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+import org.apache.commons.jcs.engine.behavior.IElementSerializer;
+import org.apache.commons.jcs.engine.logging.behavior.ICacheEvent;
+import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
+import org.apache.commons.jcs.utils.timing.SleepUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This disk cache writes each item to a separate file. This is for regions with very few items,
+ * perhaps big ones.
+ * <p>
+ * This is a fairly simple implementation. All the disk writing is handled right here. It's not
+ * clear that anything more complicated is needed.
+ */
+public class FileDiskCache<K extends Serializable, V extends Serializable>
+ extends AbstractDiskCache<K, V>
+{
+ /** Don't change */
+ private static final long serialVersionUID = 1L;
+
+ /** The logger. */
+ private static final Log log = LogFactory.getLog( FileDiskCache.class );
+
+ /** The name to prefix all log messages with. */
+ private final String logCacheName;
+
+ /** The config values. */
+ private final FileDiskCacheAttributes diskFileCacheAttributes;
+
+ /** The directory where the files are stored */
+ private File directory;
+
+ /**
+ * Constructor for the DiskCache object.
+ * <p>
+ * @param cacheAttributes
+ */
+ public FileDiskCache( FileDiskCacheAttributes cacheAttributes )
+ {
+ this( cacheAttributes, null );
+ }
+
+ /**
+ * Constructor for the DiskCache object. Will be marked alive if the directory cannot be
+ * created.
+ * <p>
+ * @param cattr
+ * @param elementSerializer used if supplied, the super's super will not set a null
+ */
+ public FileDiskCache( FileDiskCacheAttributes cattr, IElementSerializer elementSerializer )
+ {
+ super( cattr );
+ setElementSerializer( elementSerializer );
+ this.diskFileCacheAttributes = cattr;
+ this.logCacheName = "Region [" + getCacheName() + "] ";
+ alive = initializeFileSystem( cattr );
+ }
+
+ /**
+ * Tries to create the root directory if it does not already exist.
+ * <p>
+ * @param cattr
+ * @return does the directory exist.
+ */
+ private boolean initializeFileSystem( FileDiskCacheAttributes cattr )
+ {
+ // TODO, we might need to make this configurable
+ String rootDirName = cattr.getDiskPath() + "/" + cattr.getCacheName();
+ this.setDirectory( new File( rootDirName ) );
+ boolean createdDirectories = getDirectory().mkdirs();
+ if ( log.isInfoEnabled() )
+ {
+ log.info( logCacheName + "Cache file root directory: " + rootDirName );
+ log.info( logCacheName + "Created root directory: " + createdDirectories );
+ }
+
+ // TODO consider throwing.
+ boolean exists = getDirectory().exists();
+ if ( !exists )
+ {
+ log.error( "Could not initialize File Disk Cache. The root directory does not exist." );
+ }
+ return exists;
+ }
+
+ /**
+ * Creates the file for a key. Filenames and keys can be passed into this method. It must be
+ * idempotent.
+ * <p>
+ * Protected for testing.
+ * <p>
+ * @param key
+ * @return the file for the key
+ */
+ protected <KK extends Serializable> File file( KK key )
+ {
+ StringBuffer fileNameBuffer = new StringBuffer();
+
+ // add key as filename in a file system safe way
+ String keys = key.toString();
+ int l = keys.length();
+ for ( int i = 0; i < l; i++ )
+ {
+ char c = keys.charAt( i );
+ if ( !Character.isLetterOrDigit( c ) )
+ {
+ c = '_';
+ }
+ fileNameBuffer.append( c );
+ }
+ String fileName = fileNameBuffer.toString();
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Creating file for name: [" + fileName + "] based on key: [" + key + "]" );
+ }
+
+ return new File( getDirectory().getAbsolutePath(), fileName );
+ }
+
+ /**
+ * Return the keys in this cache.
+ * <p>
+ * @see org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache#getKeySet()
+ */
+ @Override
+ public Set<K> getKeySet() throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @return dir.list().length
+ */
+ @Override
+ public int getSize()
+ {
+ if ( getDirectory().exists() )
+ {
+ return getDirectory().list().length;
+ }
+ return 0;
+ }
+
+ /**
+ * @return AuxiliaryCacheAttributes
+ */
+ public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
+ {
+ return diskFileCacheAttributes;
+ }
+
+ /**
+ * @return String the path to the directory
+ */
+ @Override
+ protected String getDiskLocation()
+ {
+ return getDirectory().getAbsolutePath();
+ }
+
+ /**
+ * Sets alive to false.
+ * <p>
+ * @throws IOException
+ */
+ @Override
+ protected synchronized void processDispose()
+ throws IOException
+ {
+ ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", ICacheEventLogger.DISPOSE_EVENT );
+ try
+ {
+ if ( !alive )
+ {
+ log.error( logCacheName + "Not alive and dispose was called, directgory: " + getDirectory() );
+ return;
+ }
+
+ // Prevents any interaction with the cache while we're shutting down.
+ alive = false;
+
+ // TODO consider giving up the handle on the directory.
+ if ( log.isInfoEnabled() )
+ {
+ log.info( logCacheName + "Shutdown complete." );
+ }
+ }
+ finally
+ {
+ logICacheEvent( cacheEvent );
+ }
+ }
+
+ /**
+ * Looks for a file matching the key. If it exists, reads the file.
+ * <p>
+ * @param key
+ * @return ICacheElement
+ * @throws IOException
+ */
+ @Override
+ protected ICacheElement<K, V> processGet( K key )
+ throws IOException
+ {
+ File file = file( key );
+
+ if ( !file.exists() )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "File does not exist. Returning null from Get." + file );
+ }
+ return null;
+ }
+
+ ICacheElement<K, V> element = null;
+
+ FileInputStream fis = null;
+ try
+ {
+ fis = new FileInputStream( file );
+
+ long length = file.length();
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int) length];
+
+ int offset = 0;
+ int numRead = 0;
+ while ( offset < bytes.length && ( numRead = fis.read( bytes, offset, bytes.length - offset ) ) >= 0 )
+ {
+ offset += numRead;
+ }
+
+ // Ensure all the bytes have been read in
+ if ( offset < bytes.length )
+ {
+ throw new IOException( "Could not completely read file " + file.getName() );
+ }
+
+ element = getElementSerializer().deSerialize( bytes );
+
+ // test that the retrieved object has equal key
+ if ( element != null && !key.equals( element.getKey() ) )
+ {
+ if ( log.isInfoEnabled() )
+ {
+ log.info( logCacheName + "key: [" + key + "] point to cached object with key: [" + element.getKey()
+ + "]" );
+ }
+ element = null;
+ }
+ }
+ catch ( IOException e )
+ {
+ log.error( logCacheName + "Failure getting element, key: [" + key + "]", e );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ log.error( logCacheName + "Failure getting element, key: [" + key + "]", e );
+ }
+ finally
+ {
+ silentClose( fis );
+ }
+
+ // If this is true and we have a max file size, the Least Recently Used file will be removed.
+ if ( element != null && diskFileCacheAttributes.isTouchOnGet() )
+ {
+ touchWithRetry( file );
+ }
+ return element;
+ }
+
+ /**
+ * @param pattern
+ * @return Map
+ * @throws IOException
+ */
+ @Override
+ protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
+ throws IOException
+ {
+ // TODO get a list of file and return those with matching keys.
+ // the problem will be to handle the underscores.
+ return null;
+ }
+
+ /**
+ * Removes the file.
+ * <p>
+ * @param key
+ * @return true if the item was removed
+ * @throws IOException
+ */
+ @Override
+ protected boolean processRemove( K key )
+ throws IOException
+ {
+ return _processRemove(key);
+ }
+
+ /**
+ * Removes the file.
+ * <p>
+ * @param key
+ * @return true if the item was removed
+ * @throws IOException
+ */
+ private <T extends Serializable> boolean _processRemove( T key )
+ throws IOException
+ {
+ File file = file( key );
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Removing file " + file );
+ }
+ return deleteWithRetry( file );
+ }
+
+ /**
+ * Remove all the files in the directory.
+ * <p>
+ * Assumes that this is the only region in the directory. We could add a region prefix to the
+ * files and only delete those, but the region should create a directory.
+ * <p>
+ * @throws IOException
+ */
+ @Override
+ protected void processRemoveAll()
+ throws IOException
+ {
+ String[] fileNames = getDirectory().list();
+ for ( int i = 0; i < fileNames.length; i++ )
+ {
+ _processRemove( fileNames[i] );
+ }
+ }
+
+ /**
+ * We create a temp file with the new contents, remove the old if it exists, and then rename the
+ * temp.
+ * <p>
+ * @param element
+ * @throws IOException
+ */
+ @Override
+ protected void processUpdate( ICacheElement<K, V> element )
+ throws IOException
+ {
+ removeIfLimitIsSetAndReached();
+
+ File file = file( element.getKey() );
+
+ File tmp = null;
+ OutputStream os = null;
+ try
+ {
+ byte[] bytes = getElementSerializer().serialize( element );
+
+ tmp = File.createTempFile( "JCS_DiskFileCache", null, getDirectory() );
+
+ FileOutputStream fos = new FileOutputStream( tmp );
+ os = new BufferedOutputStream( fos );
+
+ if ( bytes != null )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Wrote " + bytes.length + " bytes to file " + tmp );
+ }
+ os.write( bytes );
+ os.close();
+ }
+ deleteWithRetry( file );
+ tmp.renameTo( file );
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Renamed to: " + file );
+ }
+ }
+ catch ( IOException e )
+ {
+ log.error( logCacheName + "Failure updating element, key: [" + element.getKey() + "]", e );
+ }
+ finally
+ {
+ silentClose( os );
+ if ( ( tmp != null ) && tmp.exists() )
+ {
+ deleteWithRetry( tmp );
+ }
+ }
+ }
+
+ /**
+ * If a limit has been set and we have reached it, remove the least recently modified file.
+ * <p>
+ * We will probably need to touch the files. If we touch, the LRM file will be based on age
+ * (i.e. FIFO). If we touch, it will be based on access time (i.e. LRU).
+ */
+ private void removeIfLimitIsSetAndReached()
+ {
+ if ( diskFileCacheAttributes.getMaxNumberOfFiles() > 0 )
+ {
+ // TODO we might want to synchronize this block.
+ if ( getSize() >= diskFileCacheAttributes.getMaxNumberOfFiles() )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Max reached, removing least recently modifed" );
+ }
+
+ long oldestLastModified = System.currentTimeMillis();
+ File theLeastRecentlyModified = null;
+ String[] fileNames = getDirectory().list();
+ for ( int i = 0; i < fileNames.length; i++ )
+ {
+ File file = file( fileNames[i] );
+ long lastModified = file.lastModified();
+ if ( lastModified < oldestLastModified )
+ {
+ oldestLastModified = lastModified;
+ theLeastRecentlyModified = file;
+ }
+ }
+ if ( theLeastRecentlyModified != null )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Least recently modifed: " + theLeastRecentlyModified );
+ }
+ deleteWithRetry( theLeastRecentlyModified );
+ }
+ }
+ }
+ }
+
+ /**
+ * Tries to delete a file. If it fails, it tries several more times, pausing a few ms. each
+ * time.
+ * <p>
+ * @param file
+ * @return true if the file does not exist or if it was removed
+ */
+ private boolean deleteWithRetry( File file )
+ {
+ boolean success = file.delete();
+
+ // TODO: The following should be identical to success == false, but it isn't
+ if ( file.exists() )
+ {
+ int maxRetries = diskFileCacheAttributes.getMaxRetriesOnDelete();
+ for ( int i = 0; i < maxRetries && !success; i++ )
+ {
+ SleepUtil.sleepAtLeast( 5 );
+ success = file.delete();
+ }
+ }
+ else
+ {
+ success = true;
+ }
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "deleteWithRetry. success= " + success + " file: " + file );
+ }
+ return success;
+ }
+
+ /**
+ * Tries to set the last access time to now.
+ * <p>
+ * @param file to touch
+ * @return was it successful
+ */
+ private boolean touchWithRetry( File file )
+ {
+ boolean success = file.setLastModified( System.currentTimeMillis() );
+ if ( !success )
+ {
+ int maxRetries = diskFileCacheAttributes.getMaxRetriesOnTouch();
+ if ( file.exists() )
+ {
+ for ( int i = 0; i < maxRetries && !success; i++ )
+ {
+ SleepUtil.sleepAtLeast( 5 );
+ success = file.delete();
+ }
+ }
+ }
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( logCacheName + "Last modified, success: " + success );
+ }
+ return success;
+ }
+
+ /**
+ * Closes a stream and swallows errors.
+ * <p>
+ * @param s the stream
+ */
+ private void silentClose( InputStream s )
+ {
+ if ( s != null )
+ {
+ try
+ {
+ s.close();
+ }
+ catch ( IOException e )
+ {
+ log.error( logCacheName + "Failure closing stream", e );
+ }
+ }
+ }
+
+ /**
+ * Closes a stream and swallows errors.
+ * <p>
+ * @param s the stream
+ */
+ private void silentClose( OutputStream s )
+ {
+ if ( s != null )
+ {
+ try
+ {
+ s.close();
+ }
+ catch ( IOException e )
+ {
+ log.error( logCacheName + "Failure closing stream", e );
+ }
+ }
+ }
+
+ /**
+ * @param directory the directory to set
+ */
+ protected void setDirectory( File directory )
+ {
+ this.directory = directory;
+ }
+
+ /**
+ * @return the directory
+ */
+ protected File getDirectory()
+ {
+ return directory;
+ }
+}
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheAttributes.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheAttributes.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheAttributes.java Sun Feb 23 10:37:48 2014
@@ -1,141 +1,160 @@
-package org.apache.commons.jcs.auxiliary.disk.file;
-
-import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCacheAttributes;
-
-/**
- * Configuration values for the file disk cache.
- */
-public class FileDiskCacheAttributes
- extends AbstractDiskCacheAttributes
-{
- /** Don't change. */
- private static final long serialVersionUID = -7371586172678836062L;
-
- /** Default file count limit: -1 means no limit */
- public static final int DEFAULT_MAX_NUMBER_OF_FILES = -1;
-
- /** Max number of files */
- private int maxNumberOfFiles = DEFAULT_MAX_NUMBER_OF_FILES;
-
- /** Default limit on the number of times we will retry a delete. */
- public static final int DEFAULT_MAX_RETRIES_ON_DELETE = 10;
-
- /** Max number of retries on delete */
- private int maxRetriesOnDelete = DEFAULT_MAX_RETRIES_ON_DELETE;
-
- /** Default touch rule. */
- public static final boolean DEFAULT_TOUCH_ON_GET = false;
-
- /** Default limit on the number of times we will retry a delete. */
- public static final int DEFAULT_MAX_RETRIES_ON_TOUCH = 10;
-
- /** Max number of retries on touch */
- private int maxRetriesOnTouch = DEFAULT_MAX_RETRIES_ON_TOUCH;
-
- /**
- * Should we touch on get. If so, we will reset the last modified time. If you have a max file
- * size set, this will make the removal strategy LRU. If this is false, then the oldest will be
- * removed.
- */
- private boolean touchOnGet = DEFAULT_TOUCH_ON_GET;
-
- /**
- * Returns a copy of the attributes.
- * <p>
- * @return AuxiliaryCacheAttributes
- */
- @Override
- public AuxiliaryCacheAttributes copy()
- {
- try
- {
- return (AuxiliaryCacheAttributes) this.clone();
- }
- catch ( Exception e )
- {
- // swallow
- }
- return this;
- }
-
- /**
- * @param maxNumberOfFiles the maxNumberOfFiles to set
- */
- public void setMaxNumberOfFiles( int maxNumberOfFiles )
- {
- this.maxNumberOfFiles = maxNumberOfFiles;
- }
-
- /**
- * @return the maxNumberOfFiles
- */
- public int getMaxNumberOfFiles()
- {
- return maxNumberOfFiles;
- }
-
- /**
- * @param maxRetriesOnDelete the maxRetriesOnDelete to set
- */
- public void setMaxRetriesOnDelete( int maxRetriesOnDelete )
- {
- this.maxRetriesOnDelete = maxRetriesOnDelete;
- }
-
- /**
- * @return the maxRetriesOnDelete
- */
- public int getMaxRetriesOnDelete()
- {
- return maxRetriesOnDelete;
- }
-
- /**
- * @param touchOnGet the touchOnGet to set
- */
- public void setTouchOnGet( boolean touchOnGet )
- {
- this.touchOnGet = touchOnGet;
- }
-
- /**
- * @return the touchOnGet
- */
- public boolean isTouchOnGet()
- {
- return touchOnGet;
- }
-
- /**
- * @param maxRetriesOnTouch the maxRetriesOnTouch to set
- */
- public void setMaxRetriesOnTouch( int maxRetriesOnTouch )
- {
- this.maxRetriesOnTouch = maxRetriesOnTouch;
- }
-
- /**
- * @return the maxRetriesOnTouch
- */
- public int getMaxRetriesOnTouch()
- {
- return maxRetriesOnTouch;
- }
-
- /**
- * Write out the values for debugging purposes.
- * <p>
- * @return String
- */
- @Override
- public String toString()
- {
- StringBuffer str = new StringBuffer();
- str.append( "DiskFileCacheAttributes " );
- str.append( "\n diskPath = " + diskPath );
- str.append( "\n maxNumberOfFiles = " + getMaxNumberOfFiles() );
- str.append( "\n maxRetriesOnDelete = " + getMaxRetriesOnDelete() );
- return str.toString();
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
+import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCacheAttributes;
+
+/**
+ * Configuration values for the file disk cache.
+ */
+public class FileDiskCacheAttributes
+ extends AbstractDiskCacheAttributes
+{
+ /** Don't change. */
+ private static final long serialVersionUID = -7371586172678836062L;
+
+ /** Default file count limit: -1 means no limit */
+ public static final int DEFAULT_MAX_NUMBER_OF_FILES = -1;
+
+ /** Max number of files */
+ private int maxNumberOfFiles = DEFAULT_MAX_NUMBER_OF_FILES;
+
+ /** Default limit on the number of times we will retry a delete. */
+ public static final int DEFAULT_MAX_RETRIES_ON_DELETE = 10;
+
+ /** Max number of retries on delete */
+ private int maxRetriesOnDelete = DEFAULT_MAX_RETRIES_ON_DELETE;
+
+ /** Default touch rule. */
+ public static final boolean DEFAULT_TOUCH_ON_GET = false;
+
+ /** Default limit on the number of times we will retry a delete. */
+ public static final int DEFAULT_MAX_RETRIES_ON_TOUCH = 10;
+
+ /** Max number of retries on touch */
+ private int maxRetriesOnTouch = DEFAULT_MAX_RETRIES_ON_TOUCH;
+
+ /**
+ * Should we touch on get. If so, we will reset the last modified time. If you have a max file
+ * size set, this will make the removal strategy LRU. If this is false, then the oldest will be
+ * removed.
+ */
+ private boolean touchOnGet = DEFAULT_TOUCH_ON_GET;
+
+ /**
+ * Returns a copy of the attributes.
+ * <p>
+ * @return AuxiliaryCacheAttributes
+ */
+ @Override
+ public AuxiliaryCacheAttributes copy()
+ {
+ try
+ {
+ return (AuxiliaryCacheAttributes) this.clone();
+ }
+ catch ( Exception e )
+ {
+ // swallow
+ }
+ return this;
+ }
+
+ /**
+ * @param maxNumberOfFiles the maxNumberOfFiles to set
+ */
+ public void setMaxNumberOfFiles( int maxNumberOfFiles )
+ {
+ this.maxNumberOfFiles = maxNumberOfFiles;
+ }
+
+ /**
+ * @return the maxNumberOfFiles
+ */
+ public int getMaxNumberOfFiles()
+ {
+ return maxNumberOfFiles;
+ }
+
+ /**
+ * @param maxRetriesOnDelete the maxRetriesOnDelete to set
+ */
+ public void setMaxRetriesOnDelete( int maxRetriesOnDelete )
+ {
+ this.maxRetriesOnDelete = maxRetriesOnDelete;
+ }
+
+ /**
+ * @return the maxRetriesOnDelete
+ */
+ public int getMaxRetriesOnDelete()
+ {
+ return maxRetriesOnDelete;
+ }
+
+ /**
+ * @param touchOnGet the touchOnGet to set
+ */
+ public void setTouchOnGet( boolean touchOnGet )
+ {
+ this.touchOnGet = touchOnGet;
+ }
+
+ /**
+ * @return the touchOnGet
+ */
+ public boolean isTouchOnGet()
+ {
+ return touchOnGet;
+ }
+
+ /**
+ * @param maxRetriesOnTouch the maxRetriesOnTouch to set
+ */
+ public void setMaxRetriesOnTouch( int maxRetriesOnTouch )
+ {
+ this.maxRetriesOnTouch = maxRetriesOnTouch;
+ }
+
+ /**
+ * @return the maxRetriesOnTouch
+ */
+ public int getMaxRetriesOnTouch()
+ {
+ return maxRetriesOnTouch;
+ }
+
+ /**
+ * Write out the values for debugging purposes.
+ * <p>
+ * @return String
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append( "DiskFileCacheAttributes " );
+ str.append( "\n diskPath = " + diskPath );
+ str.append( "\n maxNumberOfFiles = " + getMaxNumberOfFiles() );
+ str.append( "\n maxRetriesOnDelete = " + getMaxRetriesOnDelete() );
+ return str.toString();
+ }
+}
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheFactory.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheFactory.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheFactory.java Sun Feb 23 10:37:48 2014
@@ -1,79 +1,98 @@
-package org.apache.commons.jcs.auxiliary.disk.file;
-
-import java.io.Serializable;
-
-import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.commons.jcs.auxiliary.AuxiliaryCacheFactory;
-import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
-import org.apache.commons.jcs.engine.behavior.IElementSerializer;
-import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/** Create Disk File Caches */
-public class FileDiskCacheFactory
- implements AuxiliaryCacheFactory
-{
- /** The logger. */
- private final static Log log = LogFactory.getLog( FileDiskCacheFactory.class );
-
- /** The auxiliary name. */
- private String name;
-
- /** The manager used by this factory instance */
- private FileDiskCacheManager diskFileCacheManager;
-
- /**
- * Creates a manager if we don't have one, and then uses the manager to create the cache. The
- * same factory will be called multiple times by the composite cache to create a cache for each
- * region.
- * <p>
- * @param attr config
- * @param cacheMgr the manager to use if needed
- * @param cacheEventLogger the event logger
- * @param elementSerializer the serializer
- * @return AuxiliaryCache
- */
- public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> createCache(
- AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
- {
- FileDiskCacheAttributes idfca = (FileDiskCacheAttributes) attr;
- if ( log.isDebugEnabled() )
- {
- log.debug( "Creating DiskFileCache for attributes = " + idfca );
- }
- synchronized( this )
- {
- if ( diskFileCacheManager == null )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( "Creating DiskFileCacheManager" );
- }
- diskFileCacheManager = new FileDiskCacheManager( idfca, cacheEventLogger, elementSerializer );
- }
- return diskFileCacheManager.getCache( idfca );
- }
- }
-
- /**
- * Gets the name attribute of the DiskCacheFactory object
- * <p>
- * @return The name value
- */
- public String getName()
- {
- return this.name;
- }
-
- /**
- * Sets the name attribute of the DiskCacheFactory object
- * <p>
- * @param name The new name value
- */
- public void setName( String name )
- {
- this.name = name;
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
+import org.apache.commons.jcs.auxiliary.AuxiliaryCacheFactory;
+import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.commons.jcs.engine.behavior.IElementSerializer;
+import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** Create Disk File Caches */
+public class FileDiskCacheFactory
+ implements AuxiliaryCacheFactory
+{
+ /** The logger. */
+ private final static Log log = LogFactory.getLog( FileDiskCacheFactory.class );
+
+ /** The auxiliary name. */
+ private String name;
+
+ /** The manager used by this factory instance */
+ private FileDiskCacheManager diskFileCacheManager;
+
+ /**
+ * Creates a manager if we don't have one, and then uses the manager to create the cache. The
+ * same factory will be called multiple times by the composite cache to create a cache for each
+ * region.
+ * <p>
+ * @param attr config
+ * @param cacheMgr the manager to use if needed
+ * @param cacheEventLogger the event logger
+ * @param elementSerializer the serializer
+ * @return AuxiliaryCache
+ */
+ public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> createCache(
+ AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
+ ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ {
+ FileDiskCacheAttributes idfca = (FileDiskCacheAttributes) attr;
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Creating DiskFileCache for attributes = " + idfca );
+ }
+ synchronized( this )
+ {
+ if ( diskFileCacheManager == null )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Creating DiskFileCacheManager" );
+ }
+ diskFileCacheManager = new FileDiskCacheManager( idfca, cacheEventLogger, elementSerializer );
+ }
+ return diskFileCacheManager.getCache( idfca );
+ }
+ }
+
+ /**
+ * Gets the name attribute of the DiskCacheFactory object
+ * <p>
+ * @return The name value
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * Sets the name attribute of the DiskCacheFactory object
+ * <p>
+ * @param name The new name value
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+}
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheManager.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheManager.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/file/FileDiskCacheManager.java Sun Feb 23 10:37:48 2014
@@ -1,98 +1,117 @@
-package org.apache.commons.jcs.auxiliary.disk.file;
-
-import java.io.Serializable;
-import java.util.Hashtable;
-
-import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCacheManager;
-import org.apache.commons.jcs.engine.behavior.IElementSerializer;
-import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This is a non singleton. It creates caches on a per region basis.
- */
-public class FileDiskCacheManager
- extends AbstractDiskCacheManager
-{
- /** Don't change */
- private static final long serialVersionUID = -4153287154512264626L;
-
- /** The logger */
- private final static Log log = LogFactory.getLog( FileDiskCacheManager.class );
-
- /** Each region has an entry here. */
- private final Hashtable<String, FileDiskCache<? extends Serializable, ? extends Serializable>> caches =
- new Hashtable<String, FileDiskCache<? extends Serializable, ? extends Serializable>>();
-
- /** User configurable attributes */
- private final FileDiskCacheAttributes defaultCacheAttributes;
-
- /**
- * Constructor for the DiskFileCacheManager object
- * <p>
- * @param defaultCacheAttributes Default attributes for caches managed by the instance.
- * @param cacheEventLogger
- * @param elementSerializer
- */
- protected FileDiskCacheManager( FileDiskCacheAttributes defaultCacheAttributes, ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer )
- {
- this.defaultCacheAttributes = defaultCacheAttributes;
- setElementSerializer( elementSerializer );
- setCacheEventLogger( cacheEventLogger );
- }
-
- /**
- * Gets an DiskFileCache for the supplied name using the default attributes.
- * <p>
- * @param cacheName Name that will be used when creating attributes.
- * @return A cache.
- */
- public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> getCache( String cacheName )
- {
- FileDiskCacheAttributes cacheAttributes = (FileDiskCacheAttributes) defaultCacheAttributes.copy();
-
- cacheAttributes.setCacheName( cacheName );
-
- return getCache( cacheAttributes );
- }
-
- /**
- * Get an DiskFileCache for the supplied attributes. Will provide an existing cache for the name
- * attribute if one has been created, or will create a new cache.
- * <p>
- * @param cacheAttributes Attributes the cache should have.
- * @return A cache, either from the existing set or newly created.
- */
- public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> getCache( FileDiskCacheAttributes cacheAttributes )
- {
- FileDiskCache<K, V> cache = null;
-
- String cacheName = cacheAttributes.getCacheName();
-
- log.debug( "Getting cache named: " + cacheName );
-
- synchronized ( caches )
- {
- // Try to load the cache from the set that have already been
- // created. This only looks at the name attribute.
-
- @SuppressWarnings("unchecked") // Need to cast because of common map for all caches
- FileDiskCache<K, V> fileDiskCache = (FileDiskCache<K, V>) caches.get( cacheName );
- cache = fileDiskCache;
-
- // If it was not found, create a new one using the supplied
- // attributes
-
- if ( cache == null )
- {
- cache = new FileDiskCache<K, V>( cacheAttributes, getElementSerializer() );
- cache.setCacheEventLogger( getCacheEventLogger() );
- caches.put( cacheName, cache );
- }
- }
-
- return cache;
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+import java.util.Hashtable;
+
+import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCacheManager;
+import org.apache.commons.jcs.engine.behavior.IElementSerializer;
+import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This is a non singleton. It creates caches on a per region basis.
+ */
+public class FileDiskCacheManager
+ extends AbstractDiskCacheManager
+{
+ /** Don't change */
+ private static final long serialVersionUID = -4153287154512264626L;
+
+ /** The logger */
+ private final static Log log = LogFactory.getLog( FileDiskCacheManager.class );
+
+ /** Each region has an entry here. */
+ private final Hashtable<String, FileDiskCache<? extends Serializable, ? extends Serializable>> caches =
+ new Hashtable<String, FileDiskCache<? extends Serializable, ? extends Serializable>>();
+
+ /** User configurable attributes */
+ private final FileDiskCacheAttributes defaultCacheAttributes;
+
+ /**
+ * Constructor for the DiskFileCacheManager object
+ * <p>
+ * @param defaultCacheAttributes Default attributes for caches managed by the instance.
+ * @param cacheEventLogger
+ * @param elementSerializer
+ */
+ protected FileDiskCacheManager( FileDiskCacheAttributes defaultCacheAttributes, ICacheEventLogger cacheEventLogger,
+ IElementSerializer elementSerializer )
+ {
+ this.defaultCacheAttributes = defaultCacheAttributes;
+ setElementSerializer( elementSerializer );
+ setCacheEventLogger( cacheEventLogger );
+ }
+
+ /**
+ * Gets an DiskFileCache for the supplied name using the default attributes.
+ * <p>
+ * @param cacheName Name that will be used when creating attributes.
+ * @return A cache.
+ */
+ public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> getCache( String cacheName )
+ {
+ FileDiskCacheAttributes cacheAttributes = (FileDiskCacheAttributes) defaultCacheAttributes.copy();
+
+ cacheAttributes.setCacheName( cacheName );
+
+ return getCache( cacheAttributes );
+ }
+
+ /**
+ * Get an DiskFileCache for the supplied attributes. Will provide an existing cache for the name
+ * attribute if one has been created, or will create a new cache.
+ * <p>
+ * @param cacheAttributes Attributes the cache should have.
+ * @return A cache, either from the existing set or newly created.
+ */
+ public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> getCache( FileDiskCacheAttributes cacheAttributes )
+ {
+ FileDiskCache<K, V> cache = null;
+
+ String cacheName = cacheAttributes.getCacheName();
+
+ log.debug( "Getting cache named: " + cacheName );
+
+ synchronized ( caches )
+ {
+ // Try to load the cache from the set that have already been
+ // created. This only looks at the name attribute.
+
+ @SuppressWarnings("unchecked") // Need to cast because of common map for all caches
+ FileDiskCache<K, V> fileDiskCache = (FileDiskCache<K, V>) caches.get( cacheName );
+ cache = fileDiskCache;
+
+ // If it was not found, create a new one using the supplied
+ // attributes
+
+ if ( cache == null )
+ {
+ cache = new FileDiskCache<K, V>( cacheAttributes, getElementSerializer() );
+ cache.setCacheEventLogger( getCacheEventLogger() );
+ caches.put( cacheName, cache );
+ }
+ }
+
+ return cache;
+ }
+}
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java Sun Feb 23 10:37:48 2014
@@ -1,7 +1,5 @@
package org.apache.commons.jcs.auxiliary.disk.indexed;
-import java.io.Serializable;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -21,6 +19,9 @@ import java.io.Serializable;
* under the License.
*/
+import java.io.Serializable;
+
+
/**
* Used to dump out a Disk cache from disk for debugging. This is meant to be
* run as a command line utility for
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java Sun Feb 23 10:37:48 2014
@@ -74,7 +74,7 @@ public class JDBCDiskCacheAttributes
/**
* If a pool name is supplied, the manager will attempt to load it. It should be configured in a
* separate section as follows. Assuming the name is "MyPool":
- *
+ *
* <pre>
* jcs.jdbcconnectionpool.MyPool.attributes.userName=MyUserName
* jcs.jdbcconnectionpool.MyPool.attributes.password=MyPassword
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessAttributes.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessAttributes.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessAttributes.java Sun Feb 23 10:37:48 2014
@@ -1,160 +1,179 @@
-package org.apache.commons.jcs.auxiliary.disk.jdbc;
-
-/** These are used to configure the JDBCDiskCachePoolAccess class. */
-public class JDBCDiskCachePoolAccessAttributes
-{
- /** The name of the pool. */
- private String poolName;
-
- /** URI to the db. */
- private String url;
-
- /** username for the db */
- private String userName;
-
- /** password for the database */
- private String password;
-
- /** This is the default limit on the maximum number of active connections. */
- public static final int DEFAULT_MAX_ACTIVE = 10;
-
- /** Max connections allowed */
- private int maxActive = DEFAULT_MAX_ACTIVE;
-
- /** The name of the database. */
- private String database = "";
-
- /** The driver */
- private String driverClassName;
-
- /**
- * @param poolName the poolName to set
- */
- public void setPoolName( String poolName )
- {
- this.poolName = poolName;
- }
-
- /**
- * @return the poolName
- */
- public String getPoolName()
- {
- return poolName;
- }
-
- /**
- * @param connectURI the connectURI to set
- */
- public void setUrl( String connectURI )
- {
- this.url = connectURI;
- }
-
- /**
- * @return the connectURI
- */
- public String getUrl()
- {
- return url;
- }
-
- /**
- * @param userName the userName to set
- */
- public void setUserName( String userName )
- {
- this.userName = userName;
- }
-
- /**
- * @return the userName
- */
- public String getUserName()
- {
- return userName;
- }
-
- /**
- * @param password the password to set
- */
- public void setPassword( String password )
- {
- this.password = password;
- }
-
- /**
- * @return the password
- */
- public String getPassword()
- {
- return password;
- }
-
- /**
- * @param maxActive the maxActive to set
- */
- public void setMaxActive( int maxActive )
- {
- this.maxActive = maxActive;
- }
-
- /**
- * @return the maxActive
- */
- public int getMaxActive()
- {
- return maxActive;
- }
-
- /**
- * @param database the database to set
- */
- public void setDatabase( String database )
- {
- this.database = database;
- }
-
- /**
- * @return the database
- */
- public String getDatabase()
- {
- return database;
- }
-
- /**
- * @param driverClassName the driverClassName to set
- */
- public void setDriverClassName( String driverClassName )
- {
- this.driverClassName = driverClassName;
- }
-
- /**
- * @return the driverClassName
- */
- public String getDriverClassName()
- {
- return driverClassName;
- }
-
- /**
- * For debugging.
- * <p>
- * @return debug string with most of the properties.
- */
- @Override
- public String toString()
- {
- StringBuffer buf = new StringBuffer();
- buf.append( "\nJDBCDiskCachePoolAccessAttributes" );
- buf.append( "\n UserName [" + getUserName() + "]" );
- buf.append( "\n Url [" + getUrl() + "]" );
- buf.append( "\n PoolName [" + getPoolName() + "]" );
- buf.append( "\n Database [" + getDatabase() + "]" );
- buf.append( "\n DriverClassName [" + getDriverClassName() + "]" );
- buf.append( "\n MaxActive [" + getMaxActive() + "]" );
- return buf.toString();
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.jdbc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/** These are used to configure the JDBCDiskCachePoolAccess class. */
+public class JDBCDiskCachePoolAccessAttributes
+{
+ /** The name of the pool. */
+ private String poolName;
+
+ /** URI to the db. */
+ private String url;
+
+ /** username for the db */
+ private String userName;
+
+ /** password for the database */
+ private String password;
+
+ /** This is the default limit on the maximum number of active connections. */
+ public static final int DEFAULT_MAX_ACTIVE = 10;
+
+ /** Max connections allowed */
+ private int maxActive = DEFAULT_MAX_ACTIVE;
+
+ /** The name of the database. */
+ private String database = "";
+
+ /** The driver */
+ private String driverClassName;
+
+ /**
+ * @param poolName the poolName to set
+ */
+ public void setPoolName( String poolName )
+ {
+ this.poolName = poolName;
+ }
+
+ /**
+ * @return the poolName
+ */
+ public String getPoolName()
+ {
+ return poolName;
+ }
+
+ /**
+ * @param connectURI the connectURI to set
+ */
+ public void setUrl( String connectURI )
+ {
+ this.url = connectURI;
+ }
+
+ /**
+ * @return the connectURI
+ */
+ public String getUrl()
+ {
+ return url;
+ }
+
+ /**
+ * @param userName the userName to set
+ */
+ public void setUserName( String userName )
+ {
+ this.userName = userName;
+ }
+
+ /**
+ * @return the userName
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword( String password )
+ {
+ this.password = password;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * @param maxActive the maxActive to set
+ */
+ public void setMaxActive( int maxActive )
+ {
+ this.maxActive = maxActive;
+ }
+
+ /**
+ * @return the maxActive
+ */
+ public int getMaxActive()
+ {
+ return maxActive;
+ }
+
+ /**
+ * @param database the database to set
+ */
+ public void setDatabase( String database )
+ {
+ this.database = database;
+ }
+
+ /**
+ * @return the database
+ */
+ public String getDatabase()
+ {
+ return database;
+ }
+
+ /**
+ * @param driverClassName the driverClassName to set
+ */
+ public void setDriverClassName( String driverClassName )
+ {
+ this.driverClassName = driverClassName;
+ }
+
+ /**
+ * @return the driverClassName
+ */
+ public String getDriverClassName()
+ {
+ return driverClassName;
+ }
+
+ /**
+ * For debugging.
+ * <p>
+ * @return debug string with most of the properties.
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append( "\nJDBCDiskCachePoolAccessAttributes" );
+ buf.append( "\n UserName [" + getUserName() + "]" );
+ buf.append( "\n Url [" + getUrl() + "]" );
+ buf.append( "\n PoolName [" + getPoolName() + "]" );
+ buf.append( "\n Database [" + getDatabase() + "]" );
+ buf.append( "\n DriverClassName [" + getDriverClassName() + "]" );
+ buf.append( "\n MaxActive [" + getMaxActive() + "]" );
+ return buf.toString();
+ }
+}
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessFactory.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessFactory.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessFactory.java Sun Feb 23 10:37:48 2014
@@ -1,85 +1,104 @@
-package org.apache.commons.jcs.auxiliary.disk.jdbc;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/** This is just a helper util. */
-public class JDBCDiskCachePoolAccessFactory
-{
- /** The local logger. */
- private final static Log log = LogFactory.getLog( JDBCDiskCachePoolAccessFactory.class );
-
- /**
- * Creates a JDBCDiskCachePoolAccess object from the JDBCDiskCachePoolAccessAttributes. This is
- * used by the connection pool manager.
- * <p>
- * @param poolAttributes
- * @return JDBCDiskCachePoolAccess
- * @throws Exception
- */
- public static JDBCDiskCachePoolAccess createPoolAccess( JDBCDiskCachePoolAccessAttributes poolAttributes )
- throws Exception
- {
- return createPoolAccess( poolAttributes.getDriverClassName(), poolAttributes.getPoolName(), poolAttributes
- .getUrl()
- + poolAttributes.getDatabase(), poolAttributes.getUserName(), poolAttributes.getPassword(), poolAttributes
- .getMaxActive() );
- }
-
- /**
- * Creates a JDBCDiskCachePoolAccess object from the JDBCDiskCacheAttributes. Use this when not
- * using the connection pool manager.
- * <p>
- * @param cattr
- * @return JDBCDiskCachePoolAccess
- * @throws Exception
- */
- public static JDBCDiskCachePoolAccess createPoolAccess( JDBCDiskCacheAttributes cattr )
- throws Exception
- {
- return createPoolAccess( cattr.getDriverClassName(), cattr.getName(), cattr.getUrl() + cattr.getDatabase(),
- cattr.getUserName(), cattr.getPassword(), cattr.getMaxActive() );
- }
-
- /**
- * Creates a pool access object and registers the driver.
- * <p>
- * @param driverClassName
- * @param poolName
- * @param fullURL = (url + database)
- * @param userName
- * @param password
- * @param maxActive
- * @return JDBCDiskCachePoolAccess
- * @throws Exception
- */
- public static JDBCDiskCachePoolAccess createPoolAccess( String driverClassName, String poolName, String fullURL,
- String userName, String password, int maxActive )
- throws Exception
- {
- JDBCDiskCachePoolAccess poolAccess = null;
-
- try
- {
- // org.gjt.mm.mysql.Driver
- Class.forName( driverClassName );
- }
- catch ( ClassNotFoundException e )
- {
- log.error( "Couldn't find class for driver [" + driverClassName + "]", e );
- }
-
- poolAccess = new JDBCDiskCachePoolAccess( poolName );
-
- poolAccess.setupDriver( fullURL, userName, password, maxActive );
-
- poolAccess.logDriverStats();
-
- if ( log.isInfoEnabled() )
- {
- log.info( "Created: " + poolAccess );
- }
-
- return poolAccess;
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.jdbc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** This is just a helper util. */
+public class JDBCDiskCachePoolAccessFactory
+{
+ /** The local logger. */
+ private final static Log log = LogFactory.getLog( JDBCDiskCachePoolAccessFactory.class );
+
+ /**
+ * Creates a JDBCDiskCachePoolAccess object from the JDBCDiskCachePoolAccessAttributes. This is
+ * used by the connection pool manager.
+ * <p>
+ * @param poolAttributes
+ * @return JDBCDiskCachePoolAccess
+ * @throws Exception
+ */
+ public static JDBCDiskCachePoolAccess createPoolAccess( JDBCDiskCachePoolAccessAttributes poolAttributes )
+ throws Exception
+ {
+ return createPoolAccess( poolAttributes.getDriverClassName(), poolAttributes.getPoolName(), poolAttributes
+ .getUrl()
+ + poolAttributes.getDatabase(), poolAttributes.getUserName(), poolAttributes.getPassword(), poolAttributes
+ .getMaxActive() );
+ }
+
+ /**
+ * Creates a JDBCDiskCachePoolAccess object from the JDBCDiskCacheAttributes. Use this when not
+ * using the connection pool manager.
+ * <p>
+ * @param cattr
+ * @return JDBCDiskCachePoolAccess
+ * @throws Exception
+ */
+ public static JDBCDiskCachePoolAccess createPoolAccess( JDBCDiskCacheAttributes cattr )
+ throws Exception
+ {
+ return createPoolAccess( cattr.getDriverClassName(), cattr.getName(), cattr.getUrl() + cattr.getDatabase(),
+ cattr.getUserName(), cattr.getPassword(), cattr.getMaxActive() );
+ }
+
+ /**
+ * Creates a pool access object and registers the driver.
+ * <p>
+ * @param driverClassName
+ * @param poolName
+ * @param fullURL = (url + database)
+ * @param userName
+ * @param password
+ * @param maxActive
+ * @return JDBCDiskCachePoolAccess
+ * @throws Exception
+ */
+ public static JDBCDiskCachePoolAccess createPoolAccess( String driverClassName, String poolName, String fullURL,
+ String userName, String password, int maxActive )
+ throws Exception
+ {
+ JDBCDiskCachePoolAccess poolAccess = null;
+
+ try
+ {
+ // org.gjt.mm.mysql.Driver
+ Class.forName( driverClassName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ log.error( "Couldn't find class for driver [" + driverClassName + "]", e );
+ }
+
+ poolAccess = new JDBCDiskCachePoolAccess( poolName );
+
+ poolAccess.setupDriver( fullURL, userName, password, maxActive );
+
+ poolAccess.logDriverStats();
+
+ if ( log.isInfoEnabled() )
+ {
+ log.info( "Created: " + poolAccess );
+ }
+
+ return poolAccess;
+ }
+}