Author: robbie
Date: Sun Feb  5 20:55:38 2012
New Revision: 1240813

URL: http://svn.apache.org/viewvc?rev=1240813&view=rev
Log:
QPID-3814: ensure the 0-10 client sends its version number during 
ConnectionStart(Ok) process, align properties better across protocol versions, 
general tidy up of the property handling

Added:
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
Removed:
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java
Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
 Sun Feb  5 20:55:38 2012
@@ -80,10 +80,7 @@ public class ConnectionStartOkMethodHand
 
             final AuthenticationResult authResult = authMgr.authenticate(ss, 
body.getResponse());
             //save clientProperties
-            if (session.getClientProperties() == null)
-            {
-                session.setClientProperties(body.getClientProperties());
-            }
+            session.setClientProperties(body.getClientProperties());
 
             MethodRegistry methodRegistry = session.getMethodRegistry();
 

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
 Sun Feb  5 20:55:38 2012
@@ -27,8 +27,8 @@ import org.apache.qpid.AMQConnectionExce
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.codec.AMQCodecFactory;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.framing.*;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.protocol.AMQMethodEvent;
 import org.apache.qpid.protocol.AMQMethodListener;
@@ -87,8 +87,6 @@ public class AMQProtocolEngine implement
 {
     private static final Logger _logger = 
Logger.getLogger(AMQProtocolEngine.class);
 
-    private static final String CLIENT_PROPERTIES_INSTANCE = 
ClientProperties.instance.toString();
-
     // to save boxing the channelId and looking up in a map... cache in an 
array the low numbered
     // channels.  This value must be of the form 2^x - 1.
     private static final int CHANNEL_CACHE_SIZE = 0xff;
@@ -96,7 +94,7 @@ public class AMQProtocolEngine implement
 
     private AMQShortString _contextKey;
 
-    private AMQShortString _clientVersion = null;
+    private String _clientVersion = null;
 
     private VirtualHost _virtualHost;
 
@@ -133,7 +131,6 @@ public class AMQProtocolEngine implement
     private ProtocolOutputConverter _protocolOutputConverter;
     private Subject _authorizedSubject;
     private MethodDispatcher _dispatcher;
-    private ProtocolSessionIdentifier _sessionIdentifier;
 
     private final long _sessionID;
 
@@ -921,31 +918,22 @@ public class AMQProtocolEngine implement
         _saslServer = saslServer;
     }
 
-    public FieldTable getClientProperties()
-    {
-        return _clientProperties;
-    }
-
     public void setClientProperties(FieldTable clientProperties)
     {
         _clientProperties = clientProperties;
         if (_clientProperties != null)
         {
-            if (_clientProperties.getString(CLIENT_PROPERTIES_INSTANCE) != 
null)
+            if 
(_clientProperties.getString(ConnectionStartProperties.CLIENT_ID_0_8) != null)
             {
-                String clientID = 
_clientProperties.getString(CLIENT_PROPERTIES_INSTANCE);
+                String clientID = 
_clientProperties.getString(ConnectionStartProperties.CLIENT_ID_0_8);
                 setContextKey(new AMQShortString(clientID));
 
                 // Log the Opening of the connection for this client
                 _actor.message(ConnectionMessages.OPEN(clientID, 
_protocolVersion.toString(), true, true));
             }
 
-            if 
(_clientProperties.getString(ClientProperties.version.toString()) != null)
-            {
-                _clientVersion = new 
AMQShortString(_clientProperties.getString(ClientProperties.version.toString()));
-            }
+            _clientVersion = 
_clientProperties.getString(ConnectionStartProperties.VERSION_0_8);
         }
-        _sessionIdentifier = new ProtocolSessionIdentifier(this);
     }
 
     private void setProtocolVersion(ProtocolVersion pv)
@@ -1154,14 +1142,9 @@ public class AMQProtocolEngine implement
         return _lastReceivedTime;
     }
 
-    public ProtocolSessionIdentifier getSessionIdentifier()
-    {
-        return _sessionIdentifier;
-    }
-
     public String getClientVersion()
     {
-        return (_clientVersion == null) ? null : _clientVersion.toString();
+        return _clientVersion;
     }
 
     public Boolean isIncoming()

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
 Sun Feb  5 20:55:38 2012
@@ -20,9 +20,13 @@
  */
 package org.apache.qpid.server.protocol;
 
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.security.sasl.SaslServer;
+
 import org.apache.qpid.AMQConnectionException;
 import org.apache.qpid.AMQException;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.MethodDispatcher;
@@ -35,10 +39,6 @@ import org.apache.qpid.server.security.A
 import org.apache.qpid.server.subscription.ClientDeliveryMethod;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
-import javax.security.auth.Subject;
-import javax.security.sasl.SaslServer;
-import java.util.List;
-
 
 public interface AMQProtocolSession extends AMQVersionAwareProtocolSession, 
AuthorizationHolder, AMQConnectionModel
 {
@@ -60,28 +60,6 @@ public interface AMQProtocolSession exte
 
     long getLastReceivedTime();
 
-    public static final class ProtocolSessionIdentifier
-    {
-        private final Object _sessionIdentifier;
-        private final Object _sessionInstance;
-
-        ProtocolSessionIdentifier(AMQProtocolSession session)
-        {
-            _sessionIdentifier = session.getClientIdentifier();
-            _sessionInstance = session.getClientProperties() == null ? null : 
session.getClientProperties().getObject(ClientProperties.instance.toAMQShortString());
-        }
-
-        public Object getSessionIdentifier()
-        {
-            return _sessionIdentifier;
-        }
-
-        public Object getSessionInstance()
-        {
-            return _sessionInstance;
-        }
-    }
-
     public static interface Task
     {
         public void doTask(AMQProtocolSession session) throws AMQException;
@@ -192,9 +170,6 @@ public interface AMQProtocolSession exte
      */
     void setSaslServer(SaslServer saslServer);
 
-
-    FieldTable getClientProperties();
-
     void setClientProperties(FieldTable clientProperties);
 
     Object getClientIdentifier();
@@ -217,8 +192,6 @@ public interface AMQProtocolSession exte
 
     public MethodDispatcher getMethodDispatcher();
 
-    public ProtocolSessionIdentifier getSessionIdentifier();
-
     String getClientVersion();
 
     long getLastIoTime();

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
 Sun Feb  5 20:55:38 2012
@@ -92,7 +92,7 @@ public class AMQProtocolSessionMBean ext
 
     public String getVersion()
     {
-        return (_protocolSession.getClientVersion() == null) ? null : 
_protocolSession.getClientVersion().toString();
+        return _protocolSession.getClientVersion();
     }
 
     public Date getLastIoTime()

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
 Sun Feb  5 20:55:38 2012
@@ -24,7 +24,6 @@ import org.apache.log4j.Logger;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.common.AMQPFilterTypes;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.AMQChannel;
@@ -320,9 +319,6 @@ public abstract class SubscriptionImpl i
 
     private final Boolean _autoClose;
 
-
-    private static final String CLIENT_PROPERTIES_INSTANCE = 
ClientProperties.instance.toString();
-
     private AMQQueue _queue;
     private final AtomicBoolean _deleted = new AtomicBoolean(false);
 

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
 Sun Feb  5 20:55:38 2012
@@ -488,4 +488,14 @@ public class ServerConnection extends Co
             _mBean = null;
         }
     }
+
+    public String getClientId()
+    {
+        return getConnectionDelegate().getClientId();
+    }
+
+    public String getClientVersion()
+    {
+        return getConnectionDelegate().getClientVersion();
+    }
 }

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
 Sun Feb  5 20:55:38 2012
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.transport;
 
 import org.apache.qpid.common.ServerPropertyNames;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.ProtocolEngine;
 import org.apache.qpid.server.configuration.BrokerConfig;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
@@ -290,4 +291,14 @@ public class ServerConnectionDelegate ex
     {
         return _clientProperties;
     }
-}
+
+    public String getClientId()
+    {
+        return _clientProperties == null ? null : (String) 
_clientProperties.get(ConnectionStartProperties.CLIENT_ID_0_10);
+    }
+
+    public String getClientVersion()
+    {
+        return _clientProperties == null ? null : (String) 
_clientProperties.get(ConnectionStartProperties.VERSION_0_10);
+    }
+}
\ No newline at end of file

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
 Sun Feb  5 20:55:38 2012
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.transport;
 
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor;
 import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -76,7 +75,7 @@ public class ServerConnectionMBean exten
     @Override
     public String getVersion()
     {
-        return 
String.valueOf(_serverConnection.getConnectionDelegate().getClientProperties().get(ClientProperties.version.toString()));
+        return String.valueOf(_serverConnection.getClientVersion());
     }
 
     @Override

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
 Sun Feb  5 20:55:38 2012
@@ -526,12 +526,12 @@ public class ServerSession extends Sessi
     
     public Principal getAuthorizedPrincipal()
     {
-        return ((ServerConnection) getConnection()).getAuthorizedPrincipal();
+        return getConnection().getAuthorizedPrincipal();
     }
     
     public Subject getAuthorizedSubject()
     {
-        return ((ServerConnection) getConnection()).getAuthorizedSubject();
+        return getConnection().getAuthorizedSubject();
     }
 
     public void addSessionCloseTask(Task task)
@@ -546,7 +546,7 @@ public class ServerSession extends Sessi
 
     public Object getReference()
     {
-        return ((ServerConnection) getConnection()).getReference();
+        return getConnection().getReference();
     }
 
     public MessageStore getMessageStore()
@@ -626,7 +626,7 @@ public class ServerSession extends Sessi
 
     public AMQConnectionModel getConnectionModel()
     {
-        return (ServerConnection) getConnection();
+        return getConnection();
     }
 
     public String getClientID()
@@ -634,6 +634,12 @@ public class ServerSession extends Sessi
         return getConnection().getClientId();
     }
 
+    @Override
+    public ServerConnection getConnection()
+    {
+        return (ServerConnection) super.getConnection();
+    }
+
     public LogActor getLogActor()
     {
         return _actor;
@@ -715,8 +721,8 @@ public class ServerSession extends Sessi
 
     public String toLogString()
     {
-        long connectionId = getConnection() instanceof ServerConnection
-                            ? ((ServerConnection) 
getConnection()).getConnectionId()
+        long connectionId = super.getConnection() instanceof ServerConnection
+                            ? getConnection().getConnectionId()
                             : -1;
 
         String remoteAddress = _connectionConfig instanceof ProtocolEngine

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
 Sun Feb  5 20:55:38 2012
@@ -34,6 +34,7 @@ import org.apache.qpid.framing.ProtocolV
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ChannelLimitReachedException;
 import org.apache.qpid.jms.Session;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.transport.Connection;
 import org.apache.qpid.transport.ConnectionClose;
@@ -428,7 +429,7 @@ public class AMQConnectionDelegate_0_10 
         Map<String, Object> clientProps = new HashMap<String, Object>();
         try
         {
-            clientProps.put("clientName", _conn.getClientID());
+            clientProps.put(ConnectionStartProperties.CLIENT_ID_0_10, 
_conn.getClientID());
                conSettings.setClientProperties(clientProps);
         }
         catch (JMSException e)

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
 Sun Feb  5 20:55:38 2012
@@ -29,14 +29,15 @@ import org.apache.qpid.client.security.A
 import org.apache.qpid.client.security.CallbackHandlerRegistry;
 import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.common.ClientProperties;
 import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.configuration.ClientProperties;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ConnectionStartBody;
 import org.apache.qpid.framing.ConnectionStartOkBody;
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.framing.ProtocolVersion;
+import org.apache.qpid.properties.ConnectionStartProperties;
 
 import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslClient;
@@ -148,14 +149,18 @@ public class ConnectionStartMethodHandle
                 
session.getStateManager().changeState(AMQState.CONNECTION_NOT_TUNED);
                 FieldTable clientProperties = 
FieldTableFactory.newFieldTable();
 
-                clientProperties.setString(new 
AMQShortString(ClientProperties.instance.toString()),
-                    session.getClientID());
-                clientProperties.setString(new 
AMQShortString(ClientProperties.product.toString()),
-                    QpidProperties.getProductName());
-                clientProperties.setString(new 
AMQShortString(ClientProperties.version.toString()),
-                    QpidProperties.getReleaseVersion());
-                clientProperties.setString(new 
AMQShortString(ClientProperties.platform.toString()), getFullSystemInfo());
-
+                
clientProperties.setString(ConnectionStartProperties.CLIENT_ID_0_8,
+                        session.getClientID());
+                clientProperties.setString(ConnectionStartProperties.PRODUCT,
+                        QpidProperties.getProductName());
+                
clientProperties.setString(ConnectionStartProperties.VERSION_0_8,
+                        QpidProperties.getReleaseVersion());
+                clientProperties.setString(ConnectionStartProperties.PLATFORM,
+                        ConnectionStartProperties.getPlatformInfo());
+                clientProperties.setString(ConnectionStartProperties.PROCESS,
+                        System.getProperty(ClientProperties.PROCESS_NAME, 
"Qpid Java Client"));
+                clientProperties.setInteger(ConnectionStartProperties.PID,
+                        ConnectionStartProperties.getPID());
 
                 ConnectionStartOkBody connectionStartOkBody = 
session.getMethodRegistry().createConnectionStartOkBody(clientProperties,new 
AMQShortString(mechanism),saslResponse,new AMQShortString(locales));
                 // AMQP version change: Hardwire the version to 0-8 (major=8, 
minor=0)
@@ -178,25 +183,6 @@ public class ConnectionStartMethodHandle
         }
     }
 
-    private String getFullSystemInfo()
-    {
-        StringBuilder fullSystemInfo = new 
StringBuilder(System.getProperty("java.runtime.name"));
-        fullSystemInfo.append(", ");
-        fullSystemInfo.append(System.getProperty("java.runtime.version"));
-        fullSystemInfo.append(", ");
-        fullSystemInfo.append(System.getProperty("java.vendor"));
-        fullSystemInfo.append(", ");
-        fullSystemInfo.append(System.getProperty("os.arch"));
-        fullSystemInfo.append(", ");
-        fullSystemInfo.append(System.getProperty("os.name"));
-        fullSystemInfo.append(", ");
-        fullSystemInfo.append(System.getProperty("os.version"));
-        fullSystemInfo.append(", ");
-        fullSystemInfo.append(System.getProperty("sun.os.patch.level"));
-
-        return fullSystemInfo.toString();
-    }
-
     private String chooseMechanism(byte[] availableMechanisms) throws 
UnsupportedEncodingException
     {
         final String mechanisms = new String(availableMechanisms, "utf8");

Modified: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
 (original)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
 Sun Feb  5 20:55:38 2012
@@ -144,4 +144,10 @@ public class ClientProperties
      * System property to enable allow dispatcher thread to be run as a daemon 
thread
      */
     public static final String DAEMON_DISPATCHER = 
"qpid.jms.daemon.dispatcher";
+
+    /**
+     * Used to name the process utilising the Qpid client, to override the 
default
+     * value is used in the ConnectionStartOk reply to the broker.
+     */
+    public static final String PROCESS_NAME = "qpid.client_process";
 }

Added: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java?rev=1240813&view=auto
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
 (added)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
 Sun Feb  5 20:55:38 2012
@@ -0,0 +1,88 @@
+/*
+ *  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.
+ *
+ *
+ */
+package org.apache.qpid.properties;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+
+import org.apache.qpid.transport.util.Logger;
+
+/**
+ * Constants for the various properties 0-10 clients can
+ * set values for during the ConnectionStartOk reply.
+ */
+public class ConnectionStartProperties
+{
+    private static final Logger LOGGER = 
Logger.get(ConnectionStartProperties.class);
+
+    public static final String CLIENT_ID_0_10 = "clientName";
+    public static final String CLIENT_ID_0_8 = "instance";
+
+    public static final String VERSION_0_8 = "version";
+    public static final String VERSION_0_10 = "qpid.client_version";
+
+    public static final String PROCESS = "qpid.client_process";
+
+    public static final String PID = "qpid.client_pid";
+
+    public static final String PLATFORM = "platform";
+
+    public static final String PRODUCT ="product";
+
+    public static final String SESSION_FLOW = "qpid.session_flow";
+
+    public static int getPID()
+    {
+        RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
+        String processName = rtb.getName();
+        if (processName != null && processName.indexOf('@') > 0)
+        {
+            try
+            {
+                return 
Integer.parseInt(processName.substring(0,processName.indexOf('@')));
+            }
+            catch(Exception e)
+            {
+                LOGGER.warn("Unable to get the PID due to error",e);
+                return -1;
+            }
+        }
+        else
+        {
+            LOGGER.warn("Unable to get the PID due to unsupported format : " + 
processName);
+            return -1;
+        }
+    }
+
+    public static String getPlatformInfo()
+    {
+        StringBuffer fullSystemInfo = new StringBuffer();
+        fullSystemInfo.append(System.getProperty("java.runtime.name"));
+        fullSystemInfo.append(", " + 
System.getProperty("java.runtime.version"));
+        fullSystemInfo.append(", " + System.getProperty("java.vendor"));
+        fullSystemInfo.append(", " + System.getProperty("os.arch"));
+        fullSystemInfo.append(", " + System.getProperty("os.name"));
+        fullSystemInfo.append(", " + System.getProperty("os.version"));
+        fullSystemInfo.append(", " + System.getProperty("sun.os.patch.level"));
+
+        return fullSystemInfo.toString();
+    }
+}

Modified: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
 (original)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
 Sun Feb  5 20:55:38 2012
@@ -20,6 +20,9 @@
  */
 package org.apache.qpid.transport;
 
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.transport.util.Logger;
 
 import static org.apache.qpid.transport.Connection.State.OPEN;
@@ -27,8 +30,6 @@ import static org.apache.qpid.transport.
 
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -70,10 +71,12 @@ public class ClientDelegate extends Conn
             clientProperties.putAll(_connectionSettings.getClientProperties());
         }
 
-        clientProperties.put("qpid.session_flow", 1);
-        clientProperties.put("qpid.client_pid",getPID());
-        clientProperties.put("qpid.client_process",
-                System.getProperty("qpid.client_process","Qpid Java Client"));
+        clientProperties.put(ConnectionStartProperties.SESSION_FLOW, 1);
+        clientProperties.put(ConnectionStartProperties.PID, 
ConnectionStartProperties.getPID());
+        clientProperties.put(ConnectionStartProperties.PROCESS, 
System.getProperty(ClientProperties.PROCESS_NAME, "Qpid Java Client"));
+        clientProperties.put(ConnectionStartProperties.VERSION_0_10, 
QpidProperties.getReleaseVersion());
+        clientProperties.put(ConnectionStartProperties.PRODUCT, 
QpidProperties.getProductName());
+        clientProperties.put(ConnectionStartProperties.PLATFORM, 
ConnectionStartProperties.getPlatformInfo());
 
         List<Object> brokerMechs = start.getMechanisms();
         if (brokerMechs == null || brokerMechs.isEmpty())
@@ -196,30 +199,6 @@ public class ClientDelegate extends Conn
         }
     }
 
-    private int getPID()
-    {
-        RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
-        String processName = rtb.getName();
-        if (processName != null && processName.indexOf('@')>0)
-        {
-            try
-            {
-                return 
Integer.parseInt(processName.substring(0,processName.indexOf('@')));
-            }
-            catch(Exception e)
-            {
-                log.warn("Unable to get the client PID due to error",e);
-                return -1;
-            }
-        }
-        else
-        {
-            log.warn("Unable to get the client PID due to unsupported format : 
" + processName);
-            return -1;
-        }
-
-    }
-
     public ConnectionSettings getConnectionSettings()
     {
         return _connectionSettings;

Modified: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
 (original)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
 Sun Feb  5 20:55:38 2012
@@ -124,7 +124,6 @@ public class Connection extends Connecti
     private String userID;
     private ConnectionSettings conSettings;
     private SecurityLayer securityLayer;
-    private String _clientId;
 
     private final AtomicBoolean connectionLost = new AtomicBoolean(false);
 
@@ -160,16 +159,6 @@ public class Connection extends Connecti
         }
     }
 
-    public String getClientId()
-    {
-        return _clientId;
-    }
-
-    public void setClientId(String id)
-    {
-        _clientId = id;
-    }
-
     void setLocale(String locale)
     {
         this.locale = locale;

Modified: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
 (original)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
 Sun Feb  5 20:55:38 2012
@@ -69,9 +69,6 @@ public class ServerDelegate extends Conn
         conn.setLocale(ok.getLocale());
         String mechanism = ok.getMechanism();
 
-        String clientName = (String) 
ok.getClientProperties().get("clientName");
-        conn.setClientId(clientName);
-
         if (mechanism == null || mechanism.length() == 0)
         {
             tuneAuthorizedConnection(conn);

Modified: 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java?rev=1240813&r1=1240812&r2=1240813&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
 (original)
+++ 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
 Sun Feb  5 20:55:38 2012
@@ -22,6 +22,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.management.common.mbeans.ManagedConnection;
 import org.apache.qpid.test.utils.JMXTestUtils;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
@@ -242,4 +243,36 @@ public class ManagedConnectionMBeanTest 
         assertNotNull("Connection MBean is null", mBean);
         assertEquals("Unexpected authorized id", "guest", 
mBean.getAuthorizedId());
     }
+
+    public void testClientVersion() throws Exception
+    {
+        List<ManagedConnection> connections = 
_jmxUtils.getManagedConnections("test");
+        assertNotNull("Connection MBean is not found", connections);
+        assertEquals("Unexpected number of connection mbeans", 1, 
connections.size());
+        final ManagedConnection mBean = connections.get(0);
+        assertNotNull("Connection MBean is null", mBean);
+
+        String expectedVersion = QpidProperties.getReleaseVersion();
+        assertNotNull("version should not be null", expectedVersion);
+        assertFalse("version should not be the empty string", 
expectedVersion.equals(""));
+        assertFalse("version should not be the string 'null'", 
expectedVersion.equals("null"));
+
+        assertEquals("Unexpected version", expectedVersion, 
mBean.getVersion());
+    }
+
+    public void testClientId() throws Exception
+    {
+        List<ManagedConnection> connections = 
_jmxUtils.getManagedConnections("test");
+        assertNotNull("Connection MBean is not found", connections);
+        assertEquals("Unexpected number of connection mbeans", 1, 
connections.size());
+        final ManagedConnection mBean = connections.get(0);
+        assertNotNull("Connection MBean is null", mBean);
+
+        String expectedClientId = _connection.getClientID();
+        assertNotNull("ClientId should not be null", expectedClientId);
+        assertFalse("ClientId should not be the empty string", 
expectedClientId.equals(""));
+        assertFalse("ClientId should not be the string 'null'", 
expectedClientId.equals("null"));
+
+        assertEquals("Unexpected ClientId", expectedClientId, 
mBean.getClientId());
+    }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to