summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2012-02-05 20:55:38 +0000
committerRobert Gemmell <robbie@apache.org>2012-02-05 20:55:38 +0000
commit9f999bb08dd75698d26d883cda9f28e9745365e6 (patch)
treef9a85883bad8cb2629f3a2f99fe51074f0018639
parent6f4c0cf239c847a8b80c7cd6cda8bbae990c4d52 (diff)
downloadqpid-python-9f999bb08dd75698d26d883cda9f28e9745365e6.tar.gz
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
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1240813 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java5
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java29
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java37
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java2
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java4
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java10
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java13
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java3
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java18
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java3
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java42
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java52
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java6
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java88
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java39
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java11
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java3
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java33
18 files changed, 200 insertions, 198 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
index d6e4569e44..162e4e0215 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
@@ -80,10 +80,7 @@ public class ConnectionStartOkMethodHandler implements StateAwareMethodListener<
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();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
index 93954108fa..670f83899e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
@@ -27,8 +27,8 @@ import org.apache.qpid.AMQConnectionException;
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 implements ServerProtocolEngine, Managable, AMQPr
{
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 implements ServerProtocolEngine, Managable, AMQPr
private AMQShortString _contextKey;
- private AMQShortString _clientVersion = null;
+ private String _clientVersion = null;
private VirtualHost _virtualHost;
@@ -133,7 +131,6 @@ public class AMQProtocolEngine implements ServerProtocolEngine, Managable, AMQPr
private ProtocolOutputConverter _protocolOutputConverter;
private Subject _authorizedSubject;
private MethodDispatcher _dispatcher;
- private ProtocolSessionIdentifier _sessionIdentifier;
private final long _sessionID;
@@ -921,31 +918,22 @@ public class AMQProtocolEngine implements ServerProtocolEngine, Managable, AMQPr
_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 implements ServerProtocolEngine, Managable, AMQPr
return _lastReceivedTime;
}
- public ProtocolSessionIdentifier getSessionIdentifier()
- {
- return _sessionIdentifier;
- }
-
public String getClientVersion()
{
- return (_clientVersion == null) ? null : _clientVersion.toString();
+ return _clientVersion;
}
public Boolean isIncoming()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
index d0dd78052f..b68f6097e0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
@@ -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.AuthorizationHolder;
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 extends AMQVersionAwareProtocolSession, Auth
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 extends AMQVersionAwareProtocolSession, Auth
*/
void setSaslServer(SaslServer saslServer);
-
- FieldTable getClientProperties();
-
void setClientProperties(FieldTable clientProperties);
Object getClientIdentifier();
@@ -217,8 +192,6 @@ public interface AMQProtocolSession extends AMQVersionAwareProtocolSession, Auth
public MethodDispatcher getMethodDispatcher();
- public ProtocolSessionIdentifier getSessionIdentifier();
-
String getClientVersion();
long getLastIoTime();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
index 105aa1f260..e70720600e 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
@@ -92,7 +92,7 @@ public class AMQProtocolSessionMBean extends AbstractAMQManagedConnectionObject
public String getVersion()
{
- return (_protocolSession.getClientVersion() == null) ? null : _protocolSession.getClientVersion().toString();
+ return _protocolSession.getClientVersion();
}
public Date getLastIoTime()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
index c410b822a5..0f6bc976de 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
@@ -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 implements Subscription, FlowCreditManage
private final Boolean _autoClose;
-
- private static final String CLIENT_PROPERTIES_INSTANCE = ClientProperties.instance.toString();
-
private AMQQueue _queue;
private final AtomicBoolean _deleted = new AtomicBoolean(false);
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
index 2e458b22b4..ca5551163f 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnection.java
@@ -488,4 +488,14 @@ public class ServerConnection extends Connection implements Managable, AMQConnec
_mBean = null;
}
}
+
+ public String getClientId()
+ {
+ return getConnectionDelegate().getClientId();
+ }
+
+ public String getClientVersion()
+ {
+ return getConnectionDelegate().getClientVersion();
+ }
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
index eb845d7cfb..0bf65d388b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
@@ -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 extends ServerDelegate
{
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
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
index 3bf799cba6..bb545164fb 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionMBean.java
@@ -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 extends AbstractAMQManagedConnectionObject
@Override
public String getVersion()
{
- return String.valueOf(_serverConnection.getConnectionDelegate().getClientProperties().get(ClientProperties.version.toString()));
+ return String.valueOf(_serverConnection.getClientVersion());
}
@Override
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
index d3ce94bdc7..5a208aaeaf 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
@@ -526,12 +526,12 @@ public class ServerSession extends Session
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 Session
public Object getReference()
{
- return ((ServerConnection) getConnection()).getReference();
+ return getConnection().getReference();
}
public MessageStore getMessageStore()
@@ -626,7 +626,7 @@ public class ServerSession extends Session
public AMQConnectionModel getConnectionModel()
{
- return (ServerConnection) getConnection();
+ return getConnection();
}
public String getClientID()
@@ -634,6 +634,12 @@ public class ServerSession extends Session
return getConnection().getClientId();
}
+ @Override
+ public ServerConnection getConnection()
+ {
+ return (ServerConnection) super.getConnection();
+ }
+
public LogActor getLogActor()
{
return _actor;
@@ -715,8 +721,8 @@ public class ServerSession extends Session
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
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
index a18a3fcbd4..56ee56d178 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
@@ -34,6 +34,7 @@ import org.apache.qpid.framing.ProtocolVersion;
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 implements AMQConnectionDelegate, Connec
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)
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
index 8fc51f7799..66c4821f60 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
@@ -29,14 +29,15 @@ import org.apache.qpid.client.security.AMQCallbackHandler;
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 ConnectionStartMethodHandler implements StateAwareMethodListener<Co
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 ConnectionStartMethodHandler implements StateAwareMethodListener<Co
}
}
- 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");
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java
deleted file mode 100644
index 7371c12519..0000000000
--- a/qpid/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.common;
-
-import org.apache.qpid.framing.AMQShortString;
-
-/**
- * Specifies the available client property types that different clients can use to identify themselves with.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Specify the available client property types.
- * </table>
- */
-public enum ClientProperties
-{
- instance("instance"),
- product("product"),
- version("version"),
- platform("platform");
-
- private final AMQShortString _amqShortString;
-
- private ClientProperties(String name)
- {
- _amqShortString = new AMQShortString(name);
- }
-
-
- public AMQShortString toAMQShortString()
- {
- return _amqShortString;
- }
-}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
index e6adc51591..19a77d143e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
@@ -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";
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
new file mode 100644
index 0000000000..0215c87618
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
@@ -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();
+ }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
index e732bee421..c75adab444 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
@@ -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.Connection.State.RESUMING;
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 ConnectionDelegate
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 ConnectionDelegate
}
}
- 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;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
index d9b94245e1..fbf53996a8 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
@@ -124,7 +124,6 @@ public class Connection extends ConnectionInvoker
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 ConnectionInvoker
}
}
- public String getClientId()
- {
- return _clientId;
- }
-
- public void setClientId(String id)
- {
- _clientId = id;
- }
-
void setLocale(String locale)
{
this.locale = locale;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
index 6cd9da3d9a..d30e48ad85 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
@@ -69,9 +69,6 @@ public class ServerDelegate extends ConnectionDelegate
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);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
index 6a8125fd04..3fc370dc68 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagedConnectionMBeanTest.java
@@ -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 extends QpidBrokerTestCase
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());
+ }
}