jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r685702 [3/5] - in /jakarta/jcs/trunk: ./ src/java/org/apache/jcs/auxiliary/ src/java/org/apache/jcs/auxiliary/disk/ src/java/org/apache/jcs/auxiliary/disk/block/ src/java/org/apache/jcs/auxiliary/disk/indexed/ src/java/org/apache/jcs/auxil...
Date Wed, 13 Aug 2008 22:14:48 GMT
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java Wed Aug 13 15:14:46 2008
@@ -1,22 +1,18 @@
 package org.apache.jcs.auxiliary.remote.server;
 
 /*
- * 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.
+ * 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.IOException;
@@ -43,32 +39,29 @@
 import org.apache.jcs.engine.CacheEventQueueFactory;
 import org.apache.jcs.engine.CacheListeners;
 import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheEventLogger;
 import org.apache.jcs.engine.behavior.ICacheEventQueue;
 import org.apache.jcs.engine.behavior.ICacheListener;
 import org.apache.jcs.engine.control.CompositeCache;
 import org.apache.jcs.engine.control.CompositeCacheManager;
 
-/**
- * This class provides remote cache services. The remote cache server propagates
- * events from local caches to other local caches. It can also store cached
- * data, making it available to new clients.
- * <p>
- * Remote cache servers can be clustered. If the cache used by this remote cache
- * is configured to use a remote cache of type cluster, the two remote caches
- * will communicate with each other. Remote and put requests can be sent from
- * one remote to another. If they are configured to broadcast such event to
- * their client, then remove an puts can be sent to all locals in the cluster.
- * <p>
- * Get requests are made between clustered servers if AllowClusterGet is true. You can setup
- * several clients to use one remote server and several to use another. The get
- * locad will be distributed between the two servers. Since caches are usually
- * high get and low put, this should allow you to scale.
+/*
+ * This class provides remote cache services. The remote cache server propagates events from local
+ * caches to other local caches. It can also store cached data, making it available to new clients.
+ * <p> Remote cache servers can be clustered. If the cache used by this remote cache is configured
+ * to use a remote cache of type cluster, the two remote caches will communicate with each other.
+ * Remote and put requests can be sent from one remote to another. If they are configured to
+ * broadcast such event to their client, then remove an puts can be sent to all locals in the
+ * cluster. <p> Get requests are made between clustered servers if AllowClusterGet is true. You can
+ * setup several clients to use one remote server and several to use another. The get locad will be
+ * distributed between the two servers. Since caches are usually high get and low put, this should
+ * allow you to scale.
  */
 class RemoteCacheServer
     extends UnicastRemoteObject
     implements IRemoteCacheService, IRemoteCacheObserver, IRemoteCacheServiceAdmin, Unreferenced
 {
-    /** For serialization. Don't change.*/
+    /** For serialization. Don't change. */
     private static final long serialVersionUID = -8072345435941473116L;
 
     /** log instance */
@@ -90,6 +83,9 @@
     /** relates listener id with a type */
     private final Hashtable idTypeMap = new Hashtable();
 
+    /** relates listener id with an ip address */
+    private final Hashtable idIPMap = new Hashtable();
+
     private int[] listenerId = new int[1];
 
     /** Configuration settings. */
@@ -98,9 +94,12 @@
     /** The interval at which we will log updates. */
     private int logInterval = 100;
 
+    /** An optional event logger */
+    private ICacheEventLogger cacheEventLogger;
+
     /**
-     * Constructor for the RemoteCacheServer object. Thiks initializes the
-     * server with the values from the config file.
+     * Constructor for the RemoteCacheServer object. Thiks initializes the server with the values
+     * from the config file.
      * <p>
      * @param rcsa
      * @throws RemoteException
@@ -135,8 +134,7 @@
     /**
      * Subclass can override this method to create the specific cache manager.
      * <p>
-     * @param prop
-     *            The anem of the configuration file.
+     * @param prop The name of the configuration file.
      * @return The cache hub configured with this configuration file.
      */
     private CompositeCacheManager createCacheManager( String prop )
@@ -155,62 +153,10 @@
     }
 
     /**
-     * Returns the cache listener for the specified cache. Creates the cache and
-     * the cache descriptor if they do not already exist.
-     * <p>
-     * @param cacheName
-     * @return The cacheListeners value
-     */
-    protected CacheListeners getCacheListeners( String cacheName )
-    {
-        CacheListeners cacheListeners = (CacheListeners) cacheListenersMap.get( cacheName );
-        synchronized ( cacheListenersMap )
-        {
-            if ( cacheListeners == null )
-            {
-                cacheListeners = (CacheListeners) cacheListenersMap.get( cacheName );
-                if ( cacheListeners == null )
-                {
-                    cacheListeners = new CacheListeners( cacheManager.getCache( cacheName ) );
-                    cacheListenersMap.put( cacheName, cacheListeners );
-                }
-            }
-        }
-        return cacheListeners;
-    }
-
-    /**
-     * Gets the clusterListeners attribute of the RemoteCacheServer object.
-     * <p>
-     * @todo may be able to remove this
-     *
-     * @param cacheName
-     * @return The clusterListeners value
-     */
-    protected CacheListeners getClusterListeners( String cacheName )
-    {
-        CacheListeners cacheListeners = (CacheListeners) clusterListenersMap.get( cacheName );
-        synchronized ( clusterListenersMap )
-        {
-            if ( cacheListeners == null )
-            {
-                cacheListeners = (CacheListeners) clusterListenersMap.get( cacheName );
-                if ( cacheListeners == null )
-                {
-                    cacheListeners = new CacheListeners( cacheManager.getCache( cacheName ) );
-                    clusterListenersMap.put( cacheName, cacheListeners );
-                }
-            }
-        }
-        return cacheListeners;
-    }
-
-    /**
-     * Puts a cache bean to the remote cache and notifies all listeners which
-     * <br>
+     * Puts a cache bean to the remote cache and notifies all listeners which <br>
      * <ol>
-     * <li>have a different listener id than the originating host;
-     * <li>are currently subscribed to the related cache.
+     * <li>have a different listener id than the originating host; <li>are currently subscribed to
+     * the related cache.
      * </ol>
      * <p>
      * @param item
@@ -223,8 +169,8 @@
     }
 
     /**
-     * @param item 
-     * @throws IOException 
+     * @param item
+     * @throws IOException
      */
     public void update( ICacheElement item )
         throws IOException
@@ -233,29 +179,7 @@
     }
 
     /**
-     * An update can come from either a local cache's remote auxiliary, or it
-     * can come from a remote server. A remote server is considered a a source
-     * of type cluster.
-     * <p>
-     * If the update came from a cluster, then we should tell the cache manager
-     * that this was a remote put. This way, any lateral and remote auxiliaries
-     * configured for the region will not be updated. This is basically how a
-     * remote listener works when plugged into a local cache.
-     * <p>
-     * If the cluster is configured to keep local cluster consistency, then all
-     * listeners will be updated. This allows cluster server A to update cluster
-     * server B and then B to update its clients if it is told to keep local
-     * cluster consistency. Otherwise, server A will update server B and B will
-     * not tell its clients. If you cluster using lateral caches for instance,
-     * this is how it will work. Updates to a cluster node, will never get to
-     * the leavess. The remote cluster, with local cluster consistency, allows
-     * you to update leaves. This basically allows you to have a failover remote
-     * server.
-     * <p>
-     * Since currently a cluster will not try to get from other cluster servers,
-     * you can scale a bit with a cluster configuration. Puts and removes will
-     * be broadcasted to all clients, but the get load on a remote server can be
-     * reduced.
+     * The internal processing is wrapped in event logging calls.
      * <p>
      * @param item
      * @param requesterId
@@ -264,27 +188,51 @@
     public void update( ICacheElement item, long requesterId )
         throws IOException
     {
-        long start = 0;
-        if ( timing )
+        logEventStart( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
+        try
         {
-            start = System.currentTimeMillis();
+            processUpdate( item, requesterId );
         }
-
-        if ( log.isInfoEnabled() )
+        finally
         {
-            // not thread safe, but it doesn't have to be accurate
-            puts++;
-            if ( puts % logInterval == 0 )
-            {
-                log.info( "puts = " + puts );
-            }
+            logEventFinish( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
         }
+    }
 
-        if ( log.isDebugEnabled() )
+    /**
+     * An update can come from either a local cache's remote auxiliary, or it can come from a remote
+     * server. A remote server is considered a a source of type cluster.
+     * <p>
+     * If the update came from a cluster, then we should tell the cache manager that this was a
+     * remote put. This way, any lateral and remote auxiliaries configured for the region will not
+     * be updated. This is basically how a remote listener works when plugged into a local cache.
+     * <p>
+     * If the cluster is configured to keep local cluster consistency, then all listeners will be
+     * updated. This allows cluster server A to update cluster server B and then B to update its
+     * clients if it is told to keep local cluster consistency. Otherwise, server A will update
+     * server B and B will not tell its clients. If you cluster using lateral caches for instance,
+     * this is how it will work. Updates to a cluster node, will never get to the leaves. The remote
+     * cluster, with local cluster consistency, allows you to update leaves. This basically allows
+     * you to have a failover remote server.
+     * <p>
+     * Since currently a cluster will not try to get from other cluster servers, you can scale a bit
+     * with a cluster configuration. Puts and removes will be broadcasted to all clients, but the
+     * get load on a remote server can be reduced.
+     * <p>
+     * @param item
+     * @param requesterId
+     * @throws IOException
+     */
+    private void processUpdate( ICacheElement item, long requesterId )
+    {
+        long start = 0;
+        if ( timing )
         {
-            log.debug( "In update, put [" + item.getKey() + "] in [" + item.getCacheName() + "]" );
+            start = System.currentTimeMillis();
         }
 
+        logUpdateInfo( item );
+
         try
         {
             CacheListeners cacheDesc = getCacheListeners( item.getCacheName() );
@@ -380,6 +328,12 @@
         }
         catch ( Exception e )
         {
+            if ( cacheEventLogger != null )
+            {
+                cacheEventLogger.logError( "RemoteCacheServer", item.getCacheName(), ICacheEventLogger.UPDATE_EVENT, e
+                    .getMessage(), item );
+            }
+
             log.error( "Trouble in Update. requesterId [" + requesterId + "]", e );
         }
 
@@ -392,66 +346,34 @@
                 log.debug( "put took " + String.valueOf( end - start ) + " ms." );
             }
         }
-
-        return;
     }
 
     /**
-     * Gets the eventQList attribute of the RemoteCacheServer object. This
-     * returns the event queues stored in the cacheListeners object for a
-     * particuylar region, if the queue is not for this requester.
-     * <p>
-     * Basically, this makes sure that a request from a particular local cache,
-     * identified by its listener id, does not result in a call to that same
-     * listener.
+     * Log some details.
      * <p>
-     * @param cacheListeners
-     * @param requesterId
-     * @return The eventQList value
+     * @param item
      */
-    private ICacheEventQueue[] getEventQList( CacheListeners cacheListeners, long requesterId )
+    private void logUpdateInfo( ICacheElement item )
     {
-        ICacheEventQueue[] list = null;
-        synchronized ( cacheListeners.eventQMap )
-        {
-            list = (ICacheEventQueue[]) cacheListeners.eventQMap.values().toArray( new ICacheEventQueue[0] );
-        }
-        int count = 0;
-        // Set those not qualified to null; Count those qualified.
-        for ( int i = 0; i < list.length; i++ )
+        if ( log.isInfoEnabled() )
         {
-            ICacheEventQueue q = list[i];
-            if ( q.isWorking() && q.getListenerId() != requesterId )
-            {
-                count++;
-            }
-            else
+            // not thread safe, but it doesn't have to be accurate
+            puts++;
+            if ( puts % logInterval == 0 )
             {
-                list[i] = null;
+                log.info( "puts = " + puts );
             }
         }
-        if ( count == list.length )
-        {
-            // All qualified.
-            return list;
-        }
 
-        // Returns only the qualified.
-        ICacheEventQueue[] qq = new ICacheEventQueue[count];
-        count = 0;
-        for ( int i = 0; i < list.length; i++ )
+        if ( log.isDebugEnabled() )
         {
-            if ( list[i] != null )
-            {
-                qq[count++] = list[i];
-            }
+            log.debug( "In update, put [" + item.getKey() + "] in [" + item.getCacheName() + "]" );
         }
-        return qq;
     }
 
     /**
-     * Returns a cache value from the specified remote cache; or null if the
-     * cache or key does not exist.
+     * Returns a cache value from the specified remote cache; or null if the cache or key does not
+     * exist.
      * <p>
      * @param cacheName
      * @param key
@@ -465,11 +387,11 @@
     }
 
     /**
-     * Returns a cache bean from the specified cache; or null if the key does
-     * not exist.
+     * Returns a cache bean from the specified cache; or null if the key does not exist.
+     * <p>
+     * Adding the requestor id, allows the cache to determine the source of the get.
      * <p>
-     * Adding the requestor id, allows the cache to determine the sournce of the
-     * get.
+     * The internal processing is wrapped in event logging calls.
      * <p>
      * @param cacheName
      * @param key
@@ -480,6 +402,32 @@
     public ICacheElement get( String cacheName, Serializable key, long requesterId )
         throws IOException
     {
+        ICacheElement element = null;
+        logEventStart( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
+        try
+        {
+            element = processGet( cacheName, key, requesterId );
+        }
+        finally
+        {
+            logEventFinish( element, requesterId, ICacheEventLogger.GET_EVENT );
+        }
+        return element;
+    }
+
+    /**
+     * Returns a cache bean from the specified cache; or null if the key does not exist.
+     * <p>
+     * Adding the requestor id, allows the cache to determine the source of the get.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     * @return ICacheElement
+     * @throws IOException
+     */
+    private ICacheElement processGet( String cacheName, Serializable key, long requesterId )
+    {
         Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) );
 
         if ( log.isDebugEnabled() )
@@ -507,63 +455,84 @@
         catch ( Exception e )
         {
             log.error( "Problem getting listeners.", e );
-        }
 
-        if ( cacheDesc == null )
-        {
-            return null;
+            if ( cacheEventLogger != null )
+            {
+                cacheEventLogger.logError( "RemoteCacheServer", cacheName, ICacheEventLogger.GET_EVENT, e.getMessage(),
+                                           key );
+            }
         }
-        CompositeCache c = (CompositeCache) cacheDesc.cache;
 
         ICacheElement element = null;
 
-        // If we have a get come in from a client and we don't have the item
-        // locally, we will allow the cache to look in other non local sources,
-        // such as a remote cache or a lateral.
-        //
-        // Since remote servers never get from clients and clients never go
-        // remote from a remote call, this
-        // will not result in any loops.
-        //
-        // This is the only instance I can think of where we allow a remote get
-        // from a remote call. The purpose is to allow remote cache servers to
-        // talk to each other. If one goes down, you want it to be able to get
-        // data from those that were up when the failed server comes back o
-        // line.
+        element = getFromCacheListeners( key, fromCluster, cacheDesc, element );
+        return element;
+    }
 
-        if ( !fromCluster && this.rcsa.getAllowClusterGet() )
+    /**
+     * Gets the item from the associated cache listeners.
+     * <p>
+     * @param key
+     * @param fromCluster
+     * @param cacheDesc
+     * @param element
+     * @return
+     */
+    private ICacheElement getFromCacheListeners( Serializable key, boolean fromCluster, CacheListeners cacheDesc,
+                                                 ICacheElement element )
+    {
+        if ( cacheDesc != null )
         {
-            if ( log.isDebugEnabled() )
+            CompositeCache c = (CompositeCache) cacheDesc.cache;
+
+            // If we have a get come in from a client and we don't have the item
+            // locally, we will allow the cache to look in other non local sources,
+            // such as a remote cache or a lateral.
+            //
+            // Since remote servers never get from clients and clients never go
+            // remote from a remote call, this
+            // will not result in any loops.
+            //
+            // This is the only instance I can think of where we allow a remote get
+            // from a remote call. The purpose is to allow remote cache servers to
+            // talk to each other. If one goes down, you want it to be able to get
+            // data from those that were up when the failed server comes back o
+            // line.
+
+            if ( !fromCluster && this.rcsa.getAllowClusterGet() )
             {
-                log.debug( "NonLocalGet. fromCluster [" + fromCluster + "] AllowClusterGet ["
-                    + this.rcsa.getAllowClusterGet() + "]" );
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "NonLocalGet. fromCluster [" + fromCluster + "] AllowClusterGet ["
+                        + this.rcsa.getAllowClusterGet() + "]" );
+                }
+                element = c.get( key );
             }
-            element = c.get( key );
-        }
-        else
-        {
-            // Gets from cluster type remote will end up here.
-            // Gets from all clients will end up here if allow cluster get is
-            // false.
-
-            if ( log.isDebugEnabled() )
+            else
             {
-                log.debug( "LocalGet.  fromCluster [" + fromCluster + "] AllowClusterGet ["
-                    + this.rcsa.getAllowClusterGet() + "]" );
+                // Gets from cluster type remote will end up here.
+                // Gets from all clients will end up here if allow cluster get is
+                // false.
+
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "LocalGet.  fromCluster [" + fromCluster + "] AllowClusterGet ["
+                        + this.rcsa.getAllowClusterGet() + "]" );
+                }
+                element = c.localGet( key );
             }
-            element = c.localGet( key );
         }
-
         return element;
     }
 
     /**
      * Gets multiple items from the cache based on the given set of keys.
      * <p>
-     * @param cacheName 
+     * @param cacheName
      * @param keys
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
-     * @throws IOException 
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache for any of these keys
+     * @throws IOException
      */
     public Map getMultiple( String cacheName, Set keys )
         throws IOException
@@ -574,15 +543,43 @@
     /**
      * Gets multiple items from the cache based on the given set of keys.
      * <p>
-     * @param cacheName 
+     * The internal processing is wrapped in event logging calls.
+     * <p>
+     * @param cacheName
      * @param keys
-     * @param requesterId 
-     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
-     * @throws IOException 
+     * @param requesterId
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache for any of these keys
+     * @throws IOException
      */
     public Map getMultiple( String cacheName, Set keys, long requesterId )
         throws IOException
     {
+        logEventStart( cacheName, (Serializable) keys, requesterId, ICacheEventLogger.GETMULTIPLE_EVENT );
+        try
+        {
+            return processGetMultiple( cacheName, keys, requesterId );
+        }
+        finally
+        {
+            logEventEnd( cacheName, (Serializable) keys, requesterId, ICacheEventLogger.GETMULTIPLE_EVENT );
+        }
+    }
+
+    /**
+     * Gets multiple items from the cache based on the given set of keys.
+     * <p>
+     * @param cacheName
+     * @param keys
+     * @param requesterId
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no
+     *         data in cache for any of these keys
+     * @throws IOException
+     */
+    private Map processGetMultiple( String cacheName, Set keys, long requesterId )
+    {
+        Map elements = null;
+
         Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) );
 
         if ( log.isDebugEnabled() )
@@ -612,53 +609,64 @@
             log.error( "Problem getting listeners.", e );
         }
 
-        if ( cacheDesc == null )
-        {
-            return null;
-        }
-        CompositeCache c = (CompositeCache) cacheDesc.cache;
+        elements = getMultipleFromCacheListeners( keys, elements, fromCluster, cacheDesc );
+        return elements;
+    }
 
-        Map elements = null;
+    /**
+     * Gets the items from the associated cache listeners.
+     * <p>
+     * @param keys
+     * @param elements
+     * @param fromCluster
+     * @param cacheDesc
+     * @return
+     */
+    private Map getMultipleFromCacheListeners( Set keys, Map elements, boolean fromCluster, CacheListeners cacheDesc )
+    {
+        if ( cacheDesc != null )
+        {
+            CompositeCache c = (CompositeCache) cacheDesc.cache;
 
-        // If we have a getMultiple come in from a client and we don't have the item
-        // locally, we will allow the cache to look in other non local sources,
-        // such as a remote cache or a lateral.
-        //
-        // Since remote servers never get from clients and clients never go
-        // remote from a remote call, this
-        // will not result in any loops.
-        //
-        // This is the only instance I can think of where we allow a remote get
-        // from a remote call. The purpose is to allow remote cache servers to
-        // talk to each other. If one goes down, you want it to be able to get
-        // data from those that were up when the failed server comes back o
-        // line.
+            // If we have a getMultiple come in from a client and we don't have the item
+            // locally, we will allow the cache to look in other non local sources,
+            // such as a remote cache or a lateral.
+            //
+            // Since remote servers never get from clients and clients never go
+            // remote from a remote call, this
+            // will not result in any loops.
+            //
+            // This is the only instance I can think of where we allow a remote get
+            // from a remote call. The purpose is to allow remote cache servers to
+            // talk to each other. If one goes down, you want it to be able to get
+            // data from those that were up when the failed server comes back o
+            // line.
 
-        if ( !fromCluster && this.rcsa.getAllowClusterGet() )
-        {
-            if ( log.isDebugEnabled() )
+            if ( !fromCluster && this.rcsa.getAllowClusterGet() )
             {
-                log.debug( "NonLocalGetMultiple. fromCluster [" + fromCluster + "] AllowClusterGet ["
-                    + this.rcsa.getAllowClusterGet() + "]" );
-            }
-            
-            elements = c.getMultiple( keys );
-        }
-        else
-        {
-            // Gets from cluster type remote will end up here.
-            // Gets from all clients will end up here if allow cluster get is
-            // false.
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "NonLocalGetMultiple. fromCluster [" + fromCluster + "] AllowClusterGet ["
+                        + this.rcsa.getAllowClusterGet() + "]" );
+                }
 
-            if ( log.isDebugEnabled() )
+                elements = c.getMultiple( keys );
+            }
+            else
             {
-                log.debug( "LocalGetMultiple.  fromCluster [" + fromCluster + "] AllowClusterGet ["
-                    + this.rcsa.getAllowClusterGet() + "]" );
+                // Gets from cluster type remote will end up here.
+                // Gets from all clients will end up here if allow cluster get is
+                // false.
+
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "LocalGetMultiple.  fromCluster [" + fromCluster + "] AllowClusterGet ["
+                        + this.rcsa.getAllowClusterGet() + "]" );
+                }
+
+                elements = c.localGetMultiple( keys );
             }
-            
-            elements = c.localGetMultiple( keys );
         }
-
         return elements;
     }
 
@@ -685,14 +693,13 @@
         {
             return Collections.EMPTY_SET;
         }
-        
+
         CompositeCache c = (CompositeCache) cacheDesc.cache;
         return c.getGroupKeys( group );
     }
 
     /**
-     * Removes the given key from the specified remote cache. Defaults the
-     * listener id to 0.
+     * Removes the given key from the specified remote cache. Defaults the listener id to 0.
      * <p>
      * @param cacheName
      * @param key
@@ -705,8 +712,9 @@
     }
 
     /**
-     * Remove the key from the cache region and don't tell the source listener
-     * about it.
+     * Remove the key from the cache region and don't tell the source listener about it.
+     * <p>
+     * The internal processing is wrapped in event logging calls.
      * <p>
      * @param cacheName
      * @param key
@@ -716,10 +724,35 @@
     public void remove( String cacheName, Serializable key, long requesterId )
         throws IOException
     {
+        logEventStart( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
+        try
+        {
+            processRemove( cacheName, key, requesterId );
+        }
+        finally
+        {
+            logEventEnd( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
+        }
+
+        return;
+    }
+
+    /**
+     * Remove the key from the cache region and don't tell the source listener about it.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     * @throws IOException
+     */
+    private void processRemove( String cacheName, Serializable key, long requesterId )
+        throws IOException
+    {
         if ( log.isDebugEnabled() )
         {
             log.debug( "remove [" + key + "] from cache [" + cacheName + "]" );
         }
+
         CacheListeners cacheDesc = (CacheListeners) cacheListenersMap.get( cacheName );
 
         Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) );
@@ -776,11 +809,10 @@
                 }
             }
         }
-        return;
     }
 
     /**
-     * Remove all keys from the sepcified remote cache.
+     * Remove all keys from the specified remote cache.
      * <p>
      * @param cacheName
      * @throws IOException
@@ -794,6 +826,8 @@
     /**
      * Remove all keys from the specified remote cache.
      * <p>
+     * The internal processing is wrapped in event logging calls.
+     * <p>
      * @param cacheName
      * @param requesterId
      * @throws IOException
@@ -801,6 +835,28 @@
     public void removeAll( String cacheName, long requesterId )
         throws IOException
     {
+        logEventStart( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
+        try
+        {
+            processRemoveAll( cacheName, requesterId );
+        }
+        finally
+        {
+            logEventEnd( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
+        }
+        return;
+    }
+
+    /**
+     * Remove all keys from the specified remote cache.
+     * <p>
+     * @param cacheName
+     * @param requesterId
+     * @throws IOException
+     */
+    private void processRemoveAll( String cacheName, long requesterId )
+        throws IOException
+    {
         CacheListeners cacheDesc = (CacheListeners) cacheListenersMap.get( cacheName );
 
         Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) );
@@ -848,7 +904,6 @@
                 }
             }
         }
-        return;
     }
 
     /**
@@ -883,28 +938,36 @@
     public void dispose( String cacheName, long requesterId )
         throws IOException
     {
-        if ( log.isInfoEnabled() )
+        logEventStart( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
+        try
         {
-            log.info( "Dispose request received from listener [" + requesterId + "]" );
-        }
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Dispose request received from listener [" + requesterId + "]" );
+            }
 
-        CacheListeners cacheDesc = (CacheListeners) cacheListenersMap.get( cacheName );
+            CacheListeners cacheDesc = (CacheListeners) cacheListenersMap.get( cacheName );
 
-        // this is dangerous
-        if ( cacheDesc != null )
-        {
-            // best attempt to achieve ordered free-cache-op and notification.
-            synchronized ( cacheDesc )
+            // this is dangerous
+            if ( cacheDesc != null )
             {
-                ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
-
-                for ( int i = 0; i < qlist.length; i++ )
+                // best attempt to achieve ordered free-cache-op and notification.
+                synchronized ( cacheDesc )
                 {
-                    qlist[i].addDisposeEvent();
+                    ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
+
+                    for ( int i = 0; i < qlist.length; i++ )
+                    {
+                        qlist[i].addDisposeEvent();
+                    }
+                    cacheManager.freeCache( cacheName );
                 }
-                cacheManager.freeCache( cacheName );
             }
         }
+        finally
+        {
+            logEventEnd( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
+        }
         return;
     }
 
@@ -934,6 +997,108 @@
     }
 
     /**
+     * Returns the cache listener for the specified cache. Creates the cache and the cache
+     * descriptor if they do not already exist.
+     * <p>
+     * @param cacheName
+     * @return The cacheListeners value
+     */
+    protected CacheListeners getCacheListeners( String cacheName )
+    {
+        CacheListeners cacheListeners = (CacheListeners) cacheListenersMap.get( cacheName );
+        synchronized ( cacheListenersMap )
+        {
+            if ( cacheListeners == null )
+            {
+                cacheListeners = (CacheListeners) cacheListenersMap.get( cacheName );
+                if ( cacheListeners == null )
+                {
+                    cacheListeners = new CacheListeners( cacheManager.getCache( cacheName ) );
+                    cacheListenersMap.put( cacheName, cacheListeners );
+                }
+            }
+        }
+        return cacheListeners;
+    }
+
+    /**
+     * Gets the clusterListeners attribute of the RemoteCacheServer object.
+     * <p>
+     * TODO may be able to remove this
+     * @param cacheName
+     * @return The clusterListeners value
+     */
+    protected CacheListeners getClusterListeners( String cacheName )
+    {
+        CacheListeners cacheListeners = (CacheListeners) clusterListenersMap.get( cacheName );
+        synchronized ( clusterListenersMap )
+        {
+            if ( cacheListeners == null )
+            {
+                cacheListeners = (CacheListeners) clusterListenersMap.get( cacheName );
+                if ( cacheListeners == null )
+                {
+                    cacheListeners = new CacheListeners( cacheManager.getCache( cacheName ) );
+                    clusterListenersMap.put( cacheName, cacheListeners );
+                }
+            }
+        }
+        return cacheListeners;
+    }
+
+    /**
+     * Gets the eventQList attribute of the RemoteCacheServer object. This returns the event queues
+     * stored in the cacheListeners object for a particular region, if the queue is not for this
+     * requester.
+     * <p>
+     * Basically, this makes sure that a request from a particular local cache, identified by its
+     * listener id, does not result in a call to that same listener.
+     * <p>
+     * @param cacheListeners
+     * @param requesterId
+     * @return The eventQList value
+     */
+    private ICacheEventQueue[] getEventQList( CacheListeners cacheListeners, long requesterId )
+    {
+        ICacheEventQueue[] list = null;
+        synchronized ( cacheListeners.eventQMap )
+        {
+            list = (ICacheEventQueue[]) cacheListeners.eventQMap.values().toArray( new ICacheEventQueue[0] );
+        }
+        int count = 0;
+        // Set those not qualified to null; Count those qualified.
+        for ( int i = 0; i < list.length; i++ )
+        {
+            ICacheEventQueue q = list[i];
+            if ( q.isWorking() && q.getListenerId() != requesterId )
+            {
+                count++;
+            }
+            else
+            {
+                list[i] = null;
+            }
+        }
+        if ( count == list.length )
+        {
+            // All qualified.
+            return list;
+        }
+
+        // Returns only the qualified.
+        ICacheEventQueue[] qq = new ICacheEventQueue[count];
+        count = 0;
+        for ( int i = 0; i < list.length; i++ )
+        {
+            if ( list[i] != null )
+            {
+                qq[count++] = list[i];
+            }
+        }
+        return qq;
+    }
+
+    /**
      * Removes dead event queues. Should clean out deregistered listeners.
      * <p>
      * @param eventQMap
@@ -949,8 +1114,8 @@
 
                 // this does not care if the q is alive (i.e. if
                 // there are active threads; it cares if the queue
-                // is working -- if it has not encoutnered errors
-                // above the failure threshhold
+                // is working -- if it has not encountered errors
+                // above the failure threshold
                 if ( !q.isWorking() )
                 {
                     itr.remove();
@@ -963,14 +1128,12 @@
     /**
      * Subscribes to the specified remote cache.
      * <p>
-     * If the client id is 0, then the remote cache server will increment it's
-     * local count and assign an id to the client.
+     * If the client id is 0, then the remote cache server will increment it's local count and
+     * assign an id to the client.
      * <p>
-     * @param cacheName
-     *            the specified remote cache.
-     * @param listener
-     *            object to notify for cache changes. must be synchronized since
-     *            there are remote calls involved.
+     * @param cacheName the specified remote cache.
+     * @param listener object to notify for cache changes. must be synchronized since there are
+     *            remote calls involved.
      * @throws IOException
      */
     public void addCacheListener( String cacheName, ICacheListener listener )
@@ -1007,7 +1170,7 @@
             try
             {
                 id = listener.getListenerId();
-                // clients problably shouldn't do this.
+                // clients probably shouldn't do this.
                 if ( id == 0 )
                 {
                     // must start at one so the next gets recognized
@@ -1040,10 +1203,21 @@
 
                 // relate the type to an id
                 this.idTypeMap.put( new Long( id ), new Integer( remoteType ) );
+                if ( listenerAddress != null )
+                {
+                    this.idIPMap.put( new Long( id ), listenerAddress );
+                }
             }
             catch ( IOException ioe )
             {
-                log.error( "Problem setting listener id, listenerAddress [" + listenerAddress + "]", ioe );
+                String message = "Problem setting listener id, listenerAddress [" + listenerAddress + "]";
+                log.error( message, ioe );
+
+                if ( cacheEventLogger != null )
+                {
+                    cacheEventLogger.logError( "RemoteCacheServer", "addCacheListener", message + " - "
+                        + ioe.getMessage() );
+                }
             }
 
             CacheEventQueueFactory fact = new CacheEventQueueFactory();
@@ -1062,8 +1236,7 @@
     /**
      * Subscribes to all remote caches.
      * <p>
-     * @param listener
-     *            The feature to be added to the CacheListener attribute
+     * @param listener The feature to be added to the CacheListener attribute
      * @throws IOException
      */
     public void addCacheListener( ICacheListener listener )
@@ -1082,12 +1255,12 @@
     }
 
     /**
-     * Unsubscribe this listener from this region. If the listener is
-     * registered, it will be removed from the event queue map list.
+     * Unsubscribe this listener from this region. If the listener is registered, it will be removed
+     * from the event queue map list.
      * <p>
      * @param cacheName
      * @param listener
-     * @throws IOException 
+     * @throws IOException
      */
     public void removeCacheListener( String cacheName, ICacheListener listener )
         throws IOException
@@ -1096,8 +1269,8 @@
     }
 
     /**
-     * Unsubscribe this listener from this region. If the listener is
-     * registered, it will be removed from the event queue map list.
+     * Unsubscribe this listener from this region. If the listener is registered, it will be removed
+     * from the event queue map list.
      * <p>
      * @param cacheName
      * @param listenerId
@@ -1148,6 +1321,10 @@
             }
         }
 
+        // cleanup
+        idTypeMap.remove( new Long( listenerId ) );
+        idIPMap.remove( new Long( listenerId ) );
+        
         if ( log.isInfoEnabled() )
         {
             log.info( "After removing listener [" + listenerId + "] cache region " + cacheName + "'s listener size ["
@@ -1189,7 +1366,8 @@
     }
 
     /**
-     * Shuts down a server at a particular host and port.  Then it calls shutdown on the cache itself.
+     * Shuts down a server at a particular host and port. Then it calls shutdown on the cache
+     * itself.
      * <p>
      * @param host
      * @param port
@@ -1207,9 +1385,8 @@
     }
 
     /**
-     * Called by the RMI runtime sometime after the runtime determines that the
-     * reference list, the list of clients referencing the remote object,
-     * becomes empty.
+     * Called by the RMI runtime sometime after the runtime determines that the reference list, the
+     * list of clients referencing the remote object, becomes empty.
      */
     // TODO: test out the DGC.
     public void unreferenced()
@@ -1223,8 +1400,7 @@
     /**
      * Returns the next generated listener id [0,255].
      * <p>
-     * @return the listener id of a client. This should be unique for this
-     *         server.
+     * @return the listener id of a client. This should be unique for this server.
      */
     private long nextListenerId()
     {
@@ -1263,4 +1439,91 @@
     {
         return cacheManager.getStats();
     }
+
+    /**
+     * Logs an event if an event logger is configured.
+     * <p>
+     * @param item
+     * @param requesterId
+     */
+    private void logEventStart( ICacheElement item, long requesterId, String eventName )
+    {
+        if ( cacheEventLogger != null )
+        {
+            String ipAddress = getIPAddressForRequesterId( requesterId );
+            cacheEventLogger.logStartICacheEvent( "RemoteCacheServer", item.getCacheName(), eventName, ipAddress, item );
+        }
+    }
+
+    /**
+     * Logs an event if an event logger is configured.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     */
+    private void logEventStart( String cacheName, Serializable key, long requesterId, String eventName )
+    {
+        if ( cacheEventLogger != null )
+        {
+            String ipAddress = getIPAddressForRequesterId( requesterId );
+            cacheEventLogger.logStartICacheEvent( "RemoteCacheServer", cacheName, eventName, ipAddress, key );
+        }
+    }
+
+    /**
+     * Logs an event if an event logger is configured.
+     * <p>
+     * @param item
+     * @param requesterId
+     */
+    private void logEventFinish( ICacheElement item, long requesterId, String eventName )
+    {
+        if ( cacheEventLogger != null )
+        {
+            String ipAddress = getIPAddressForRequesterId( requesterId );
+            cacheEventLogger.logEndICacheEvent( "RemoteCacheServer", item.getCacheName(), eventName, ipAddress, item );
+        }
+    }
+
+    /**
+     * Logs an event if an event logger is configured.
+     * <p>
+     * @param cacheName
+     * @param key
+     * @param requesterId
+     */
+    private void logEventEnd( String cacheName, Serializable key, long requesterId, String eventName )
+    {
+        if ( cacheEventLogger != null )
+        {
+            String ipAddress = getIPAddressForRequesterId( requesterId );
+            cacheEventLogger.logEndICacheEvent( "RemoteCacheServer", cacheName, eventName,
+                                                ipAddress, key );
+        }
+    }
+
+    /**
+     * Ip address for the client, if one is stored.
+     * <p>
+     * Protected for testing.
+     * <p>
+     * @param requesterId
+     * @return String
+     */
+    protected String getIPAddressForRequesterId( long requesterId )
+    {
+        String ipAddress = (String)idIPMap.get( new Long( requesterId ) );
+        return ipAddress;
+    }
+    
+    /**
+     * Allows it to be injected.
+     * <p>
+     * @param cacheEventLogger
+     */
+    public void setCacheEventLogger( ICacheEventLogger cacheEventLogger )
+    {
+        this.cacheEventLogger = cacheEventLogger;
+    }
 }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java Wed Aug 13 15:14:46 2008
@@ -1,22 +1,18 @@
 package org.apache.jcs.auxiliary.remote.server;
 
 /*
- * 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.
+ * 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.jcs.auxiliary.AbstractAuxiliaryCacheAttributes;
@@ -69,6 +65,7 @@
     /**
      * Gets the remoteTypeName attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The remoteTypeName value
      */
     public String getRemoteTypeName()
@@ -87,6 +84,7 @@
     /**
      * Sets the remoteTypeName attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param s The new remoteTypeName value
      */
     public void setRemoteTypeName( String s )
@@ -104,6 +102,7 @@
     /**
      * Gets the remoteType attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The remoteType value
      */
     public int getRemoteType()
@@ -114,6 +113,7 @@
     /**
      * Sets the remoteType attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param p The new remoteType value
      */
     public void setRemoteType( int p )
@@ -124,6 +124,7 @@
     /**
      * clones
      * <p>
+     * 
      * @return AuxiliaryCacheAttributes clone
      */
     public AuxiliaryCacheAttributes copy()
@@ -142,6 +143,7 @@
     /**
      * Gets the remoteServiceName attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The remoteServiceName value
      */
     public String getRemoteServiceName()
@@ -152,6 +154,7 @@
     /**
      * Sets the remoteServiceName attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param s The new remoteServiceName value
      */
     public void setRemoteServiceName( String s )
@@ -162,6 +165,7 @@
     /**
      * Gets the remoteHost attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The remoteHost value
      */
     public String getRemoteHost()
@@ -172,6 +176,7 @@
     /**
      * Sets the remoteHost attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param s The new remoteHost value
      */
     public void setRemoteHost( String s )
@@ -182,6 +187,7 @@
     /**
      * Gets the remotePort attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The remotePort value
      */
     public int getRemotePort()
@@ -192,6 +198,7 @@
     /**
      * Sets the remotePort attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param p The new remotePort value
      */
     public void setRemotePort( int p )
@@ -202,6 +209,7 @@
     /**
      * Gets the clusterServers attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The clusterServers value
      */
     public String getClusterServers()
@@ -212,6 +220,7 @@
     /**
      * Sets the clusterServers attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param s The new clusterServers value
      */
     public void setClusterServers( String s )
@@ -222,6 +231,7 @@
     /**
      * Gets the localPort attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The localPort value
      */
     public int getServicePort()
@@ -232,6 +242,7 @@
     /**
      * Sets the localPort attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param p The new localPort value
      */
     public void setServicePort( int p )
@@ -242,6 +253,7 @@
     /**
      * Gets the removeUponRemotePut attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The removeUponRemotePut value
      */
     public boolean getRemoveUponRemotePut()
@@ -252,6 +264,7 @@
     /**
      * Sets the removeUponRemotePut attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param r The new removeUponRemotePut value
      */
     public void setRemoveUponRemotePut( boolean r )
@@ -262,6 +275,7 @@
     /**
      * Gets the getOnly attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @return The getOnly value
      */
     public boolean getGetOnly()
@@ -272,6 +286,7 @@
     /**
      * Sets the getOnly attribute of the RemoteCacheAttributes object
      * <p>
+     * 
      * @param r The new getOnly value
      */
     public void setGetOnly( boolean r )
@@ -280,8 +295,9 @@
     }
 
     /**
-     * Should cluster updates be propogated to the locals
+     * Should cluster updates be propagated to the locals
      * <p>
+     * 
      * @return The localClusterConsistency value
      */
     public boolean getLocalClusterConsistency()
@@ -290,8 +306,9 @@
     }
 
     /**
-     * Should cluster updates be propogated to the locals
+     * Should cluster updates be propagated to the locals
      * <p>
+     * 
      * @param r The new localClusterConsistency value
      */
     public void setLocalClusterConsistency( boolean r )
@@ -302,6 +319,7 @@
     /**
      * Should gets from non-cluster clients be allowed to get from other remote auxiliaries.
      * <p>
+     * 
      * @return The localClusterConsistency value
      */
     public boolean getAllowClusterGet()
@@ -312,6 +330,7 @@
     /**
      * Should we try to get from other cluster servers if we don't find the items locally.
      * <p>
+     * 
      * @param r The new localClusterConsistency value
      */
     public void setAllowClusterGet( boolean r )
@@ -322,6 +341,7 @@
     /**
      * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object
      * <p>
+     * 
      * @return The clusterServers value
      */
     public String getConfigFileName()
@@ -332,6 +352,7 @@
     /**
      * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object
      * <p>
+     * 
      * @param s The new clusterServers value
      */
     public void setConfigFileName( String s )
@@ -339,9 +360,8 @@
         configFileName = s;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see java.lang.Object#toString()
+    /**
+     * @return String details
      */
     public String toString()
     {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java Wed Aug 13 15:14:46 2008
@@ -42,13 +42,16 @@
 public class RemoteCacheServerFactory
     implements IRemoteCacheConstants
 {
+    /** The logger */
     private final static Log log = LogFactory.getLog( RemoteCacheServerFactory.class );
 
     /** The single instance of the RemoteCacheServer object. */
     private static RemoteCacheServer remoteCacheServer;
 
+    /** The name of the service. */
     private static String serviceName;
 
+    /** Factory socket time out. */
     private static int DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MS = 10000;
 
     /** Constructor for the RemoteCacheServerFactory object. */
@@ -60,7 +63,9 @@
     /**
      * This will allow you to get stats from the server, etc. Perhaps we should provide methods on
      * the factory to do this instead.
-     * A remote cache is either a local cache or a cluster cache
+     * <p>
+     * A remote cache is either a local cache or a cluster cache.
+     * <p.
      * @return Returns the remoteCacheServer.
      */
     public static RemoteCacheServer getRemoteCacheServer()
@@ -68,11 +73,13 @@
         return remoteCacheServer;
     }
 
-    // ///////////////////// Statup/shutdown methods. //////////////////
+    // ///////////////////// Startup/shutdown methods. //////////////////
     /**
      * Starts up the remote cache server on this JVM, and binds it to the registry on the given host
      * and port.
-     * A remote cache is either a local cache or a cluster cache
+     * <p>
+     * A remote cache is either a local cache or a cluster cache.
+     * <p>
      * @param host
      * @param port
      * @param propFile
@@ -247,7 +254,9 @@
     /**
      * Creates an local RMI registry on the default port, starts up the remote cache server, and
      * binds it to the registry.
-     * A remote cache is either a local cache or a cluster cache
+     * <p>
+     * A remote cache is either a local cache or a cluster cache.
+     * <p>
      * @param args The command line arguments
      * @throws Exception
      */

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java Wed Aug 13 15:14:46 2008
@@ -77,8 +77,10 @@
     /**
      * Starts the registry and then tries to bind to it.
      * <p>
-     * Gets the port from a props file. Uses the local host name for the rgistry
-     * host. Tries to start the registry, ignoreing failure. Starts the server.
+     * Gets the port from a props file. Uses the local host name for the registry
+     * host. Tries to start the registry, ignoring failure. Starts the server.
+     * <p>
+     * @throws ServletException 
      */
     public void init()
         throws ServletException
@@ -189,10 +191,8 @@
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see javax.servlet.Servlet#destroy()
+    /**
+     * shuts the cache down.
      */
     public void destroy()
     {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/CacheEventQueueFactory.java Wed Aug 13 15:14:46 2008
@@ -25,14 +25,13 @@
 import org.apache.jcs.engine.behavior.ICacheListener;
 
 /**
- * This class hands out event Queues. This allows us to change the
- * implementation more easily.
+ * This class hands out event Queues. This allows us to change the implementation more easily.
  * <p>
  * @author aaronsm
  */
 public class CacheEventQueueFactory
 {
-
+    /** The logger. */
     private static final Log log = LogFactory.getLog( CacheEventQueueFactory.class );
 
     /**
@@ -43,10 +42,10 @@
      * @param cacheName
      * @param threadPoolName
      * @param poolType
-     * @return
+     * @return ICacheEventQueue
      */
     public ICacheEventQueue createCacheEventQueue( ICacheListener listener, long listenerId, String cacheName,
-                                                  String threadPoolName, int poolType )
+                                                   String threadPoolName, int poolType )
     {
         return createCacheEventQueue( listener, listenerId, cacheName, 10, 500, threadPoolName, poolType );
     }
@@ -59,15 +58,13 @@
      * @param cacheName
      * @param maxFailure
      * @param waitBeforeRetry
-     * @param threadPoolName
-     *            null is ok, if not a pooled event queue this is ignored
-     * @param poolType
-     *            single or pooled
-     * @return
+     * @param threadPoolName null is OK, if not a pooled event queue this is ignored
+     * @param poolType single or pooled
+     * @return ICacheEventQueue
      */
     public ICacheEventQueue createCacheEventQueue( ICacheListener listener, long listenerId, String cacheName,
-                                                  int maxFailure, int waitBeforeRetry, String threadPoolName,
-                                                  int poolType )
+                                                   int maxFailure, int waitBeforeRetry, String threadPoolName,
+                                                   int poolType )
     {
         if ( log.isDebugEnabled() )
         {

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheElementSerialized.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheElementSerialized.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheElementSerialized.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheElementSerialized.java Wed Aug 13 15:14:46 2008
@@ -24,55 +24,50 @@
 /**
  * This interface defines the behavior of the serialized element wrapper.
  * <p>
- * The value is stored as a byte array. This should allow for a variety of
- * serialization mechanisms.
+ * The value is stored as a byte array. This should allow for a variety of serialization mechanisms.
  * <p>
  * This currently extends ICacheElement for backward compatibility.
- *
+ *<p>
  * @author Aaron Smuts
- *
  */
 public interface ICacheElementSerialized
     extends ICacheElement
 {
-
     /**
-     * Gets the cacheName attribute of the ICacheElement object. The cacheName
-     * is also known as the region name.
-     *
+     * Gets the cacheName attribute of the ICacheElement object. The cacheName is also known as the
+     * region name.
+     *<p>
      * @return The cacheName value
      */
     public String getCacheName();
 
     /**
-     * Gets the key attribute of the ICacheElementSerialized object. This is the
-     * standard key that the value can be reference by.
-     *
+     * Gets the key attribute of the ICacheElementSerialized object. This is the standard key that
+     * the value can be reference by.
+     *<p>
      * @return The key value
      */
     public Serializable getKey();
 
     /**
-     * Gets the value attribute of the ICacheElementSerialized object. This is
-     * the value the client cached seriailzed by some mechanism.
-     *
+     * Gets the value attribute of the ICacheElementSerialized object. This is the value the client
+     * cached serialized by some mechanism.
+     *<p>
      * @return The serialized value
      */
     public byte[] getSerializedValue();
 
     /**
      * Gets the attributes attribute of the ICacheElement object
-     *
+     *<p>
      * @return The attributes value
      */
     public IElementAttributes getElementAttributes();
 
     /**
      * Sets the attributes attribute of the ICacheElement object
-     *
-     * @param attr
-     *            The new attributes value
+     *<p>
+     * @param attr The new attributes value
      */
     public void setElementAttributes( IElementAttributes attr );
-
 }

Added: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventLogger.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventLogger.java?rev=685702&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventLogger.java (added)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/ICacheEventLogger.java Wed Aug 13 15:14:46 2008
@@ -0,0 +1,126 @@
+package org.apache.jcs.engine.behavior;
+
+import java.io.Serializable;
+
+/**
+ * This defines the behavior for event logging. Auxiliaries will send events to injected event
+ * loggers.
+ * <p>
+ * In general all ICache interface methods should call the logger if one is configured. This will be
+ * done on an ad hoc basis for now. Various auxiliaries may have additional events.
+ */
+public interface ICacheEventLogger
+{
+    /** ICache update */
+    static final String UPDATE_EVENT = "update";
+
+    /** ICache get */
+    static final String GET_EVENT = "get";
+
+    /** ICache getMultiple */
+    static final String GETMULTIPLE_EVENT = "getMultiple";
+
+    /** ICache remove */
+    static final String REMOVE_EVENT = "remove";
+
+    /** ICache removeAll */
+    static final String REMOVEALL_EVENT = "removeAll";
+
+    /** ICache dispose */
+    static final String DISPOSE_EVENT = "dispose";
+
+    /**
+     * Logs an event. These are internal application events that do not correspond to ICache calls.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param eventName - e.g. update, get, put, remove
+     * @param optionalDetails - any extra message
+     */
+    void logApplicationEvent( String source, String eventName, String optionalDetails );
+
+    /**
+     * Logs an event.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param optionalDetails - any extra message
+     * @param key - the cache key
+     */
+    void logStartICacheEvent( String source, String region, String eventName, String optionalDetails, Serializable key );
+
+    /**
+     * Logs an event.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param optionalDetails - any extra message
+     * @param item - the item being processed
+     */
+    void logStartICacheEvent( String source, String region, String eventName, String optionalDetails, ICacheElement item );
+
+    /**
+     * Logs an event.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param optionalDetails - any extra message
+     * @param key - the cache key
+     */
+    void logEndICacheEvent( String source, String region, String eventName, String optionalDetails, Serializable key );
+
+    /**
+     * Logs an event.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param optionalDetails - any extra message
+     * @param item - the item being processed
+     */
+    void logEndICacheEvent( String source, String region, String eventName, String optionalDetails, ICacheElement item );
+
+    /**
+     * Logs an error.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param errorMessage - any error message
+     */
+    void logError( String source, String eventName, String errorMessage );
+
+    /**
+     * Logs an error.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param errorMessage - any error message
+     */
+    void logError( String source, String region, String eventName, String errorMessage );
+
+    /**
+     * Logs an error.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param errorMessage - any error message
+     * @param item - the item being processed
+     */
+    void logError( String source, String region, String eventName, String errorMessage, ICacheElement item );
+
+    /**
+     * Logs an error.
+     * <p>
+     * @param source - e.g. RemoteCacheServer
+     * @param region - the name of the region
+     * @param eventName - e.g. update, get, put, remove
+     * @param errorMessage - any error message
+     * @param key - the cache key
+     */
+    void logError( String source, String region, String eventName, String errorMessage, Serializable key );
+}

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/IElementSerializer.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/IElementSerializer.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/IElementSerializer.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/behavior/IElementSerializer.java Wed Aug 13 15:14:46 2008
@@ -24,7 +24,7 @@
 
 /**
  * Defines the behavior for cache element serializers. This layer of abstraction allows us to plug
- * in different serialization mechanisms, such as XStream.
+ * in different serialization mechanisms, such as a compressing standard serializer.
  * <p>
  * @author Aaron Smuts
  */

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java?rev=685702&r1=685701&r2=685702&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheConfigurator.java Wed Aug 13 15:14:46 2008
@@ -32,19 +32,20 @@
 import org.apache.jcs.auxiliary.AuxiliaryCache;
 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
-import org.apache.jcs.config.OptionConverter;
-import org.apache.jcs.config.PropertySetter;
 import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICacheEventLogger;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
 import org.apache.jcs.engine.behavior.IElementAttributes;
+import org.apache.jcs.engine.behavior.IElementSerializer;
+import org.apache.jcs.utils.config.OptionConverter;
+import org.apache.jcs.utils.config.PropertySetter;
 
 /**
  * This class configures JCS based on a properties object.
  * <p>
- * This class is based on the log4j class org.apache.log4j.PropertyConfigurator
- * which was made by: "Luke Blanshard" <Luke@quiq.com>"Mark DONSZELMANN"
- * <Mark.Donszelmann@cern.ch>"Anders Kristensen" <akristensen@dynamicsoft.com>
- *
+ * This class is based on the log4j class org.apache.log4j.PropertyConfigurator which was made by:
+ * "Luke Blanshard" <Luke@quiq.com>"Mark DONSZELMANN" <Mark.Donszelmann@cern.ch>"Anders Kristensen"
+ * <akristensen@dynamicsoft.com>
  */
 public class CompositeCacheConfigurator
 {
@@ -64,11 +65,25 @@
 
     final static String ELEMENT_ATTRIBUTE_PREFIX = ".elementattributes";
 
+    /**
+     * jcs.auxiliary.NAME.cacheeventlogger=CLASSNAME
+     * <p>
+     * jcs.auxiliary.NAME.cacheeventlogger.attributes.CUSTOMPROPERTY=VALUE
+     */
+    final static String CACHE_EVENT_LOGGER_PREFIX = ".cacheeventlogger";
+
+    /**
+     * jcs.auxiliary.NAME.serializer=CLASSNAME
+     * <p>
+     * jcs.auxiliary.NAME.serializer.attributes.CUSTOMPROPERTY=VALUE
+     */
+    final static String SERIALIZER_PREFIX = ".serializer";
+
     private CompositeCacheManager compositeCacheManager;
 
     /**
      * Constructor for the CompositeCacheConfigurator object
-     *
+     *<p>
      * @param ccMgr
      */
     public CompositeCacheConfigurator( CompositeCacheManager ccMgr )
@@ -79,9 +94,9 @@
     /**
      * Configure cached for file name.
      * <p>
-     * This is only used for testing. The manager handles the translation of a
-     * file into a properties object.
-     *
+     * This is only used for testing. The manager handles the translation of a file into a
+     * properties object.
+     * <p>
      * @param configFileName
      */
     protected void doConfigure( String configFileName )
@@ -115,7 +130,6 @@
      * <li>Setup system caches to be used
      * <li>Setup preconfigured caches
      * </ul>
-     *
      * @param properties
      */
     public void doConfigure( Properties properties )
@@ -124,10 +138,13 @@
 
         // store props for use by non configured caches
         compositeCacheManager.props = properties;
+
         // set default value list
         setDefaultAuxValues( properties );
+
         // set default cache attr
         setDefaultCompositeCacheAttributes( properties );
+
         // set default element attr
         setDefaultElementAttributes( properties );
 
@@ -148,7 +165,7 @@
 
     /**
      * Set the default aux list for new caches.
-     *
+     * <p>
      * @param props
      */
     protected void setDefaultAuxValues( Properties props )
@@ -164,7 +181,7 @@
 
     /**
      * Set the default CompositeCacheAttributes for new caches.
-     *
+     *<p>
      * @param props
      */
     protected void setDefaultCompositeCacheAttributes( Properties props )
@@ -178,7 +195,7 @@
 
     /**
      * Set the default ElementAttributes for new caches.
-     *
+     *<p>
      * @param props
      */
     protected void setDefaultElementAttributes( Properties props )
@@ -190,9 +207,8 @@
     }
 
     /**
-     * Create caches used internally. System status gives them creation
-     * priority.
-     *
+     * Create caches used internally. System status gives them creation priority.
+     *<p>
      * @param props
      */
     protected void parseSystemRegions( Properties props )
@@ -220,7 +236,7 @@
 
     /**
      * Parse region elements.
-     *
+     *<p>
      * @param props
      */
     protected void parseRegions( Properties props )
@@ -237,11 +253,11 @@
 
                 regionNames.add( regionName );
 
-                String value = OptionConverter.findAndSubst( key, props );
+                String auxiliaryList = OptionConverter.findAndSubst( key, props );
                 ICache cache;
                 synchronized ( regionName )
                 {
-                    cache = parseRegion( props, regionName, value );
+                    cache = parseRegion( props, regionName, auxiliaryList );
                 }
                 compositeCacheManager.caches.put( regionName, cache );
             }
@@ -251,12 +267,11 @@
         {
             log.info( "Parsed regions " + regionNames );
         }
-
     }
 
     /**
      * Create cache region.
-     *
+     *<p>
      * @param props
      * @param regName
      * @param value
@@ -270,8 +285,8 @@
     /**
      * Get all the properties for a region and configure its cache.
      * <p>
-     * This method tells the otehr parse method the name of the region prefix.
-     *
+     * This method tells the other parse method the name of the region prefix.
+     *<p>
      * @param props
      * @param regName
      * @param value
@@ -285,7 +300,7 @@
 
     /**
      * Get all the properties for a region and configure its cache.
-     *
+     *<p>
      * @param props
      * @param regName
      * @param value
@@ -294,7 +309,7 @@
      * @return CompositeCache
      */
     protected CompositeCache parseRegion( Properties props, String regName, String value,
-                                         ICompositeCacheAttributes cca, String regionPrefix )
+                                          ICompositeCacheAttributes cca, String regionPrefix )
     {
         // First, create or get the cache and element attributes, and create
         // the cache.
@@ -362,7 +377,7 @@
 
     /**
      * Get an compositecacheattributes for the listed region.
-     *
+     *<p>
      * @param props
      * @param regName
      * @return
@@ -374,14 +389,14 @@
 
     /**
      * Get the main attributes for a region.
-     *
+     *<p>
      * @param props
      * @param regName
      * @param regionPrefix
      * @return ICompositeCacheAttributes
      */
     protected ICompositeCacheAttributes parseCompositeCacheAttributes( Properties props, String regName,
-                                                                      String regionPrefix )
+                                                                       String regionPrefix )
     {
         ICompositeCacheAttributes ccAttr;
 
@@ -396,7 +411,8 @@
         {
             if ( log.isInfoEnabled() )
             {
-                log.info( "No special CompositeCacheAttributes class defined for key [" + attrName + "], using default class." );
+                log.info( "No special CompositeCacheAttributes class defined for key [" + attrName
+                    + "], using default class." );
             }
 
             ICompositeCacheAttributes ccAttr2 = compositeCacheManager.getDefaultCacheAttributes();
@@ -422,9 +438,8 @@
     }
 
     /**
-     * Create the element attributes from the properties object for a cache
-     * region.
-     *
+     * Create the element attributes from the properties object for a cache region.
+     *<p>
      * @param props
      * @param regName
      * @param regionPrefix
@@ -471,15 +486,11 @@
 
     /**
      * Get an aux cache for the listed aux for a region.
-     *
-     * @param cache
-     *            the cache manager
-     * @param props
-     *            the configuration propeties
-     * @param auxName
-     *            the name of the auxiliary cache
-     * @param regName
-     *            the name of the region.
+     *<p>
+     * @param cache the cache manager
+     * @param props the configuration properties
+     * @param auxName the name of the auxiliary cache
+     * @param regName the name of the region.
      * @return AuxiliaryCache
      */
     protected AuxiliaryCache parseAuxiliary( CompositeCache cache, Properties props, String auxName, String regName )
@@ -521,7 +532,7 @@
             String prefix = AUXILIARY_PREFIX + auxName + ATTRIBUTE_PREFIX;
             auxAttr = (AuxiliaryCacheAttributes) OptionConverter
                 .instantiateByKey( props, prefix, org.apache.jcs.auxiliary.AuxiliaryCacheAttributes.class, null );
-            if ( auxFac == null )
+            if ( auxAttr == null )
             {
                 log.error( "Could not instantiate auxAttr named '" + attrName + "'" );
                 return null;
@@ -547,11 +558,70 @@
 
         // GET CACHE FROM FACTORY WITH ATTRIBUTES
         auxAttr.setCacheName( regName );
+
+        // CONFIGURE THE EVENT LOGGER
+        ICacheEventLogger cacheEventLogger = parseCacheEventLogger( props, auxName );
+
+        // CONFIGURE THE ELEMENT SERIALIZER
+        IElementSerializer elementSerializer = parseElementSerializer( props, auxName );
+
         // Consider putting the compositeCache back in the factory interface
         // since the manager may not know about it at this point.
-        // need to make sure the maanger already has the cache
+        // need to make sure the manager already has the cache
         // before the auxiliary is created.
-        auxCache = auxFac.createCache( auxAttr, compositeCacheManager );
+        auxCache = auxFac.createCache( auxAttr, compositeCacheManager, cacheEventLogger, elementSerializer );
+
         return auxCache;
     }
+
+    /**
+     * Parses the event logger config, if there is any for the auxiliary.
+     * <p>
+     * @param props
+     * @param auxName
+     * @return cacheEventLogger
+     */
+    protected ICacheEventLogger parseCacheEventLogger( Properties props, String auxName )
+    {
+        ICacheEventLogger cacheEventLogger = null;
+
+        // auxFactory was not previously initialized.
+        String eventLoggerClassName = AUXILIARY_PREFIX + auxName + CACHE_EVENT_LOGGER_PREFIX;
+        cacheEventLogger = (ICacheEventLogger) OptionConverter
+            .instantiateByKey( props, eventLoggerClassName, org.apache.jcs.engine.behavior.ICacheEventLogger.class,
+                               null );
+        if ( cacheEventLogger != null )
+        {
+            String cacheEventLoggerAttributePrefix = AUXILIARY_PREFIX + auxName + CACHE_EVENT_LOGGER_PREFIX
+                + ATTRIBUTE_PREFIX;
+            PropertySetter.setProperties( cacheEventLogger, props, cacheEventLoggerAttributePrefix + "." );
+        }
+        return cacheEventLogger;
+    }
+
+    /**
+     * Parses the element config, if there is any for the auxiliary.
+     * <p>
+     * @param props
+     * @param auxName
+     * @return cacheEventLogger
+     */
+    protected IElementSerializer parseElementSerializer( Properties props, String auxName )
+    {
+        // TODO take in the entire prop key
+        
+        IElementSerializer elementSerializer = null;
+
+        // auxFactory was not previously initialized.
+        String elementSerializerClassName = AUXILIARY_PREFIX + auxName + SERIALIZER_PREFIX;
+        elementSerializer = (IElementSerializer) OptionConverter
+            .instantiateByKey( props, elementSerializerClassName,
+                               org.apache.jcs.engine.behavior.IElementSerializer.class, null );
+        if ( elementSerializer != null )
+        {
+            String cacheEventLoggerAttributePrefix = AUXILIARY_PREFIX + auxName + SERIALIZER_PREFIX + ATTRIBUTE_PREFIX;
+            PropertySetter.setProperties( elementSerializer, props, cacheEventLoggerAttributePrefix + "." );
+        }
+        return elementSerializer;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org


Mime
View raw message