summaryrefslogtreecommitdiff
path: root/java/common/src
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
commit7b189df7fbc75216eaacc7d372bf3052a5710f5c (patch)
tree69476c7066801b57c6d1875daac600579c189df4 /java/common/src
parent315a7622924f4303d120ac33ccef23ef6cdf0041 (diff)
downloadqpid-python-7b189df7fbc75216eaacc7d372bf3052a5710f5c.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/qpid@1240813 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
-rw-r--r--java/common/src/main/java/org/apache/qpid/common/ClientProperties.java52
-rw-r--r--java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java6
-rw-r--r--java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java88
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java39
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/Connection.java11
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java3
6 files changed, 103 insertions, 96 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java b/java/common/src/main/java/org/apache/qpid/common/ClientProperties.java
deleted file mode 100644
index 7371c12519..0000000000
--- a/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/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
index e6adc51591..19a77d143e 100644
--- a/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
+++ b/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/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java b/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
new file mode 100644
index 0000000000..0215c87618
--- /dev/null
+++ b/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/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
index e732bee421..c75adab444 100644
--- a/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
+++ b/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/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/java/common/src/main/java/org/apache/qpid/transport/Connection.java
index d9b94245e1..fbf53996a8 100644
--- a/java/common/src/main/java/org/apache/qpid/transport/Connection.java
+++ b/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/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java b/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
index 6cd9da3d9a..d30e48ad85 100644
--- a/java/common/src/main/java/org/apache/qpid/transport/ServerDelegate.java
+++ b/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);