cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r585324 - in /cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl: EHDefaultStore.java FilesystemStore.java MRUMemoryStore.java
Date Wed, 17 Oct 2007 02:01:07 GMT
Author: vgritsenko
Date: Tue Oct 16 19:01:06 2007
New Revision: 585324

URL: http://svn.apache.org/viewvc?rev=585324&view=rev
Log:
cleanup

Modified:
    cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
    cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
    cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/MRUMemoryStore.java

Modified: cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java?rev=585324&r1=585323&r2=585324&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
(original)
+++ cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/EHDefaultStore.java
Tue Oct 16 19:01:06 2007
@@ -124,9 +124,9 @@
     private boolean useCacheDirectory = USE_CACHE_DIRECTORY;
     private boolean useWorkDirectory = USE_WORK_DIRECTORY;
     private long diskExpiryThreadIntervalSeconds = DISK_EXPIRY_THREAD_INTERVAL_SECONDS; 
 
-    private MemoryStoreEvictionPolicy memoryStoreEvictionPolicy = null;
-    private RegisteredEventListeners registeredEventListeners = null;
-    private BootstrapCacheLoader bootstrapCacheLoader = null;
+    private MemoryStoreEvictionPolicy memoryStoreEvictionPolicy;
+    private RegisteredEventListeners registeredEventListeners;
+    private BootstrapCacheLoader bootstrapCacheLoader;
 
     private Settings settings;
     private StoreJanitor storeJanitor;
@@ -134,11 +134,12 @@
     private String directory;    
     private File workDir;
     private File cacheDir;
-    private String diskStorePath;  // The directory to be used a disk store path. Uses java.io.tmpdir
if the argument is null.
+    /** The directory to be used a disk store path. Uses java.io.tmpdir if the argument is
null. */
+    private String diskStorePath;
 
     /**
-     *  <li><code>directory</code> - Specify an alternative location of
the disk store.
-     * @param directory
+     * <li><code>directory</code> Specify an alternative location of the
disk store.
+     * @param directory Specify an alternative location of the disk store.
      */
     public void setDirectory(String directory) {
         this.directory = directory;
@@ -166,7 +167,7 @@
 
     /**
      * <code>maxMemobjects</code> (10000) - The maximum number of in-memory objects.
-     * @param maxMemobjects
+     * @param maxMemObjects
      */
     public void setMaxMemObjects(int maxMemObjects) {
         this.maxMemObjects = maxMemObjects;
@@ -325,8 +326,7 @@
     private static String getFullFilename(File file) {
         try {
             return file.getCanonicalPath();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return file.getAbsolutePath();
         }
     }
@@ -340,18 +340,18 @@
 
         try {
             if (this.useCacheDirectory) {
-                if (this.getLogger().isDebugEnabled()) {
+                if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Using cache directory: " + cacheDir);
                 }
                 setDirectory(cacheDir);
             } else if (this.useWorkDirectory) {
-                if (this.getLogger().isDebugEnabled()) {
+                if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Using work directory: " + workDir);
                 }
                 setDirectory(workDir);
             } else if (this.directory != null) {
                 this.directory = IOUtils.getContextFilePath(workDir.getPath(), this.directory);
-                if (this.getLogger().isDebugEnabled()) {
+                if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Using directory: " + this.directory);
                 }
                 setDirectory(new File(this.directory));
@@ -370,7 +370,7 @@
         String config = org.apache.commons.io.IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream(CONFIG_FILE));
         config = StringUtils.replace(config, "${diskstorepath}", this.diskStorePath);   
    
         this.cacheManager = CacheManager.create(new ByteArrayInputStream(config.getBytes("utf-8")));
       
-        if(this.cacheManager.getCache(DEFAULT_CACHE_NAME) != null) {
+        if (this.cacheManager.getCache(DEFAULT_CACHE_NAME) != null) {
             instanceCount++;
             this.cacheName = DEFAULT_CACHE_NAME + "-" + instanceCount;
         } else {
@@ -396,17 +396,17 @@
                         this.maxDiskObjects);
         
         this.cacheManager.addCache(this.cache);
-        if(this.storeJanitor != null) {
+        if (this.storeJanitor != null) {
             storeJanitor.register(this);
         }
-        getLogger().info("EHCache cache \"" + this.cacheName + "\" initialized");
+        getLogger().info("EHCache cache '" + this.cacheName + "' initialized");
     }
 
     /**
      * Shutdown the CacheManager.
      */
     public void destroy() {
-        if(this.storeJanitor != null) {
+        if (this.storeJanitor != null) {
             storeJanitor.unregister(this);
         }        
         /*
@@ -423,13 +423,13 @@
         synchronized (this.cache) {
             if (Status.STATUS_ALIVE == this.cache.getStatus()) {
                 try {
-                    getLogger().info("Disposing EHCache cache \"" + this.cacheName + "\".");
+                    getLogger().info("Disposing EHCache cache '" + this.cacheName + "'.");
                     this.cacheManager.shutdown();
                 } catch (IllegalStateException e) {
-                    getLogger().error("Error disposing EHCache cache \"" + this.cacheName
+ "\".", e);
+                    getLogger().error("Error disposing EHCache cache '" + this.cacheName
+ "'.", e);
                 }
             } else {
-                getLogger().info("EHCache cache \"" + this.cacheName + "\" already disposed.");
+                getLogger().info("EHCache cache '" + this.cacheName + "' already disposed.");
             }
         }
     }
@@ -542,7 +542,7 @@
      * @see org.apache.excalibur.store.Store#keys()
      */
     public Enumeration keys() {
-        List keys = null;
+        List keys;
         try {
             keys = this.cache.getKeys();
         } catch (CacheException e) {

Modified: cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java?rev=585324&r1=585323&r2=585324&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
(original)
+++ cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/FilesystemStore.java
Tue Oct 16 19:01:06 2007
@@ -32,24 +32,23 @@
  *
  * @version $Id$
  */
-public final class FilesystemStore
-    extends AbstractFilesystemStore {
+public final class FilesystemStore extends AbstractFilesystemStore {
 
     private static final boolean USE_CACHE_DIRECTORY = false;
     private static final boolean USE_WORK_DIRECTORY = false;
     
+    /** The default logger for this class. */
+    private Log logger = LogFactory.getLog(getClass());
+
+    private Settings settings;
     private boolean useCacheDirectory = USE_CACHE_DIRECTORY;
     private boolean useWorkDirectory = USE_WORK_DIRECTORY;
     private String directory;
 
     protected File workDir;
     protected File cacheDir;
-    
-    /** The default logger for this class. */
-    private Log logger = LogFactory.getLog(getClass());
-
-    private Settings settings;
 
+    
     /**
      * @param settings
      */
@@ -72,23 +71,26 @@
     }
 
     public void init() throws Exception {
-        this.enableLogging(new CLLoggerWrapper(this.logger));
+        enableLogging(new CLLoggerWrapper(this.logger));
         this.workDir = new File(settings.getWorkDirectory());
         this.cacheDir = new File(settings.getCacheDirectory());
         
         try {
             if (this.useCacheDirectory) {
-                if (this.getLogger().isDebugEnabled())
+                if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Using cache directory: " + cacheDir);
+                }
                 setDirectory(cacheDir);
             } else if (this.useWorkDirectory) {
-                if (this.getLogger().isDebugEnabled())
+                if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Using work directory: " + workDir);
+                }
                 setDirectory(workDir);
             } else if (this.directory != null) {
                 this.directory = IOUtils.getContextFilePath(workDir.getPath(), this.directory);
-                if (this.getLogger().isDebugEnabled())
+                if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Using directory: " + this.directory);
+                }
                 setDirectory(new File(this.directory));
             } else {
                 try {

Modified: cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/MRUMemoryStore.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/MRUMemoryStore.java?rev=585324&r1=585323&r2=585324&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/MRUMemoryStore.java
(original)
+++ cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/java/org/apache/cocoon/components/store/impl/MRUMemoryStore.java
Tue Oct 16 19:01:06 2007
@@ -47,7 +47,7 @@
 
     private int maxObjects = MAX_OBJECTS;
 
-    protected boolean persistent = false;
+    protected boolean persistent;
 
     private Store persistentStore;
 
@@ -57,6 +57,7 @@
 
     private LinkedList mrulist;
 
+
     public Log getLogger() {
         return this.logger;
     }
@@ -106,18 +107,19 @@
      * @exception ParameterException
      */
     public void init() throws Exception {
-        if ((this.maxObjects < 1))
+        if (this.maxObjects < 1) {
             throw new Exception("MRUMemoryStore maxobjects must be at least 1!");
+        }
 
-        if (this.persistent == true && this.persistentStore == null)
-            throw new Exception(
-                    "The persistent store must be set if usePersistentStore is required");
+        if (this.persistent && this.persistentStore == null) {
+            throw new Exception("The persistent store must be set if usePersistentStore is
required");
+        }
 
         this.persistent = this.persistentStore != null;
 
         this.cache = new Hashtable((int) (this.maxObjects * 1.2));
         this.mrulist = new LinkedList();
-        if(this.storeJanitor != null) {
+        if (this.storeJanitor != null) {
             this.storeJanitor.register(this);
         }
     }
@@ -276,8 +278,7 @@
      */
     public synchronized boolean containsKey(Object key) {
         if (this.persistent) {
-            return (this.cache.containsKey(key) || this.persistentStore
-                    .containsKey(key));
+            return this.cache.containsKey(key) || this.persistentStore.containsKey(key);
         } else {
             return this.cache.containsKey(key);
         }
@@ -339,17 +340,13 @@
     }
 
     /**
-     * This method checks if an object is seriazable.
+     * This method checks if an object is serializable.
      * 
      * @param object
      *            The object to be checked
      * @return true if the object is storeable
      */
     private boolean checkSerializable(Object object) {
-
-        if (object == null)
-            return false;
-
-        return (object instanceof java.io.Serializable);
+        return object instanceof java.io.Serializable;
     }
 }



Mime
View raw message