[jboss-cvs] JBoss Messaging SVN: r2134 - trunk/src/main/org/jboss/jms/server/endpoint.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 2 01:39:15 EST 2007


Author: ovidiu.feodorov at jboss.com
Date: 2007-02-02 01:39:14 -0500 (Fri, 02 Feb 2007)
New Revision: 2134

Modified:
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-791

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-02-02 06:38:23 UTC (rev 2133)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-02-02 06:39:14 UTC (rev 2134)
@@ -31,6 +31,7 @@
 import javax.jms.Destination;
 import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
+import javax.jms.InvalidClientIDException;
 
 import org.jboss.jms.client.delegate.ClientSessionDelegate;
 import org.jboss.jms.client.remoting.CallbackManager;
@@ -96,6 +97,7 @@
 
    // the server itself
    private ServerPeer serverPeer;
+
    // access to server's extensions
    private PostOffice postOffice;
    private SecurityManager sm;
@@ -279,11 +281,34 @@
          {
             throw new IllegalStateException("Connection is closed");
          }
-         if (trace) { log.trace("setClientID:" + clientID); }
+
          if (this.clientID != null)
          {
-            throw new IllegalStateException("Cannot set clientID, already set as:" + this.clientID);
+            throw new IllegalStateException("Cannot set clientID, already set as " + this.clientID);
          }
+
+         // verify the clientID is unique
+
+         // JMS 1.1 Specifications, Section 4.3.2:
+         // "By definition, the client state identified by a client identifier can be ‘in use’ by
+         // only one client at a time. A JMS provider must prevent concurrently executing clients
+         // from using it."
+
+         ConnectionManager cm = serverPeer.getConnectionManager();
+         List conns = cm.getActiveConnections();
+
+         for(Iterator i = conns.iterator(); i.hasNext(); )
+         {
+            ServerConnectionEndpoint sce = (ServerConnectionEndpoint)i.next();
+            if (clientID != null && clientID.equals(sce.getClientID()))
+            {
+               throw new InvalidClientIDException(
+                  "Client ID '" + clientID + "' already used by " + sce);
+            }
+         }
+
+         log.debug(this + "setting client ID to " + clientID);
+
          this.clientID = clientID;
       }
       catch (Throwable t)




More information about the jboss-cvs-commits mailing list