Author: asmuts
Date: Mon Dec  1 10:41:07 2008
New Revision: 722168

URL: http://svn.apache.org/viewvc?rev=722168&view=rev
Log:
simple refactoring

Modified:
    
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java

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=722168&r1=722167&r2=722168&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
 Mon Dec  1 10:41:07 2008
@@ -265,17 +265,13 @@
             CacheListeners cacheDesc = getCacheListeners( item.getCacheName() 
);
             /* Object val = */item.getVal();
 
-            Integer remoteTypeL = (Integer) idTypeMap.get( new Long( 
requesterId ) );
+            boolean fromCluster = isRequestFromCluster( requesterId );         
   
+
             if ( log.isDebugEnabled() )
             {
-                log.debug( "In update, requesterId = [" + requesterId + "] 
remoteType = " + remoteTypeL );
+                log.debug( "In update, requesterId = [" + requesterId + "] 
fromCluster = " + fromCluster );
             }
 
-            boolean fromCluster = false;
-            if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-            {
-                fromCluster = true;
-            }
             // ordered cache item update and notification.
             synchronized ( cacheDesc )
             {
@@ -454,23 +450,12 @@
      */
     private ICacheElement processGet( String cacheName, Serializable key, long 
requesterId )
     {
-        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) 
);
-
+        boolean fromCluster = isRequestFromCluster( requesterId );
+        
         if ( log.isDebugEnabled() )
         {
             log.debug( "get [" + key + "] from cache [" + cacheName + "] 
requesterId = [" + requesterId
-                + "] remoteType = " + remoteTypeL );
-        }
-
-        // Since a non-receiving remote cache client will not register a
-        // listener, it will not have a listener id assigned from the server. 
As
-        // such the remote server cannot determine if it is a cluster or a
-        // normal client. It will assume that it is a normal client.
-
-        boolean fromCluster = false;
-        if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-        {
-            fromCluster = true;
+                + "] fromCluster = " + fromCluster );
         }
 
         CacheListeners cacheDesc = null;
@@ -567,18 +552,12 @@
                                                     
ICacheEventLogger.GETMATCHING_EVENT );
         try
         {
-            Integer remoteTypeL = (Integer) idTypeMap.get( new Long( 
requesterId ) );
-
+            boolean fromCluster = isRequestFromCluster( requesterId );
+            
             if ( log.isDebugEnabled() )
             {
                 log.debug( "getMatching [" + pattern + "] from cache [" + 
cacheName + "] requesterId = [" + requesterId
-                    + "] remoteType = " + remoteTypeL );
-            }
-
-            boolean fromCluster = false;
-            if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-            {
-                fromCluster = true;
+                    + "] fromCluster = " + fromCluster );
             }
 
             CacheListeners cacheDesc = null;
@@ -705,23 +684,12 @@
     {
         Map elements = null;
 
-        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) 
);
+        boolean fromCluster = isRequestFromCluster( requesterId );
 
         if ( log.isDebugEnabled() )
         {
             log.debug( "getMultiple [" + keys + "] from cache [" + cacheName + 
"] requesterId = [" + requesterId
-                + "] remoteType = " + remoteTypeL );
-        }
-
-        // Since a non-receiving remote cache client will not register a
-        // listener, it will not have a listener id assigned from the server. 
As
-        // such the remote server cannot determine if it is a cluster or a
-        // normal client. It will assume that it is a normal client.
-
-        boolean fromCluster = false;
-        if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-        {
-            fromCluster = true;
+                + "] fromCluster = " + fromCluster );
         }
 
         CacheListeners cacheDesc = null;
@@ -739,6 +707,26 @@
     }
 
     /**
+     * Since a non-receiving remote cache client will not register a listener, 
it will not have a
+     * listener id assigned from the server. As such the remote server cannot 
determine if it is a
+     * cluster or a normal client. It will assume that it is a normal client.
+     * <p>
+     * @param requesterId
+     * @return true is from a cluster.
+     */
+    private boolean isRequestFromCluster( long requesterId )
+    {
+        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) 
);
+
+        boolean fromCluster = false;
+        if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
+        {
+            fromCluster = true;
+        }
+        return fromCluster;
+    }
+
+    /**
      * Gets the items from the associated cache listeners.
      * <p>
      * @param keys
@@ -880,12 +868,7 @@
 
         CacheListeners cacheDesc = (CacheListeners) cacheListenersMap.get( 
cacheName );
 
-        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) 
);
-        boolean fromCluster = false;
-        if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-        {
-            fromCluster = true;
-        }
+        boolean fromCluster = isRequestFromCluster( requesterId );
 
         if ( cacheDesc != null )
         {
@@ -984,12 +967,7 @@
     {
         CacheListeners cacheDesc = (CacheListeners) cacheListenersMap.get( 
cacheName );
 
-        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( requesterId ) 
);
-        boolean fromCluster = false;
-        if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-        {
-            fromCluster = true;
-        }
+        boolean fromCluster = isRequestFromCluster( requesterId );
 
         if ( cacheDesc != null )
         {
@@ -1413,12 +1391,7 @@
             log.info( message );
         }
 
-        Integer remoteTypeL = (Integer) idTypeMap.get( new Long( listenerId ) 
);
-        boolean isClusterListener = false;
-        if ( remoteTypeL != null && remoteTypeL.intValue() == 
IRemoteCacheAttributes.CLUSTER )
-        {
-            isClusterListener = true;
-        }
+        boolean isClusterListener = isRequestFromCluster( listenerId );
 
         CacheListeners cacheDesc = null;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to