You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/07/18 20:06:57 UTC

svn commit: r423158 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java

Author: fhanik
Date: Tue Jul 18 11:06:57 2006
New Revision: 423158

URL: http://svn.apache.org/viewvc?rev=423158&view=rev
Log:
Added in hashCode and equals to the map, otherwise the maps will not get added as channel listeners if they aren't unique.
This is needed for multiple context and different contexts support

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=423158&r1=423157&r2=423158&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Tue Jul 18 11:06:57 2006
@@ -91,6 +91,7 @@
     private transient ClassLoader[] externalLoaders;
     protected transient int currentNode = 0;
     private transient long accessTimeout = 5000;
+    private transient String mapname = "";
     
 
 //------------------------------------------------------------------------------
@@ -125,6 +126,7 @@
     }
 
     private void init(Object owner, Channel channel, String mapContextName, long timeout, int channelSendOptions,ClassLoader[] cls) {
+        log.info("Initializing AbstractReplicatedMap with context name:"+mapContextName);
         this.mapOwner = owner;
         this.externalLoaders = cls;
         this.channelSendOptions = channelSendOptions;
@@ -132,6 +134,7 @@
         this.rpcTimeout = timeout;
 
         try {
+            this.mapname = mapContextName;
             //unique context is more efficient if it is stored as bytes
             this.mapContextName = mapContextName.getBytes(chset);
         } catch (UnsupportedEncodingException x) {
@@ -224,6 +227,18 @@
         this.stateTransferred = false;
         this.externalLoaders = null;
     }
+    
+    public int hashCode() {
+        return Arrays.hashCode(this.mapContextName);
+    }
+    
+    public boolean equals(Object o) {
+        if ( o == null ) return false;
+        if ( !(o instanceof AbstractReplicatedMap)) return false;
+        if ( !(o.getClass().equals(this.getClass())) ) return false;
+        AbstractReplicatedMap other = (AbstractReplicatedMap)o;
+        return Arrays.equals(mapContextName,other.mapContextName);
+    }
 
 //------------------------------------------------------------------------------
 //              GROUP COM INTERFACES
@@ -438,6 +453,10 @@
         if (! (msg instanceof MapMessage)) return;
 
         MapMessage mapmsg = (MapMessage) msg;
+        if ( log.isTraceEnabled() ) {
+            log.trace("Map["+mapname+"] received message:"+mapmsg);
+        }
+        
         try {
             mapmsg.deserialize(getExternalLoaders());
         } catch (IOException x) {
@@ -518,12 +537,12 @@
     }
 
     public boolean accept(Serializable msg, Member sender) {
-        if ( log.isTraceEnabled() ) log.trace("Map accepting...."+msg);
         boolean result = false;
         if (msg instanceof MapMessage) {
+            if ( log.isTraceEnabled() ) log.trace("Map["+mapname+"] accepting...."+msg);
             result = Arrays.equals(mapContextName, ( (MapMessage) msg).getMapId());
+            if ( log.isTraceEnabled() ) log.trace("Msg["+mapname+"] accepted["+result+"]...."+msg);
         }
-        if ( log.isTraceEnabled() ) log.trace("Msg accepted["+result+"]...."+msg);
         return result;
     }
 



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