Source code: org/activemq/ActiveMQConnectionMetaData.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.activemq;
19
20 import java.util.Enumeration;
21 import java.util.Hashtable;
22 import java.util.regex.Matcher;
23 import java.util.regex.Pattern;
24
25 import javax.jms.ConnectionMetaData;
26
27 /**
28 * A <CODE>ConnectionMetaData</CODE> object provides information describing
29 * the <CODE>Connection</CODE> object.
30 */
31
32 public class ActiveMQConnectionMetaData implements ConnectionMetaData {
33
34 public static final String PROVIDER_VERSION;
35 public static final int PROVIDER_MAJOR_VERSION;
36 public static final int PROVIDER_MINOR_VERSION;
37
38 static {
39 String version=null;
40 int major=0;
41 int minor=0;
42 try {
43 Package p = Package.getPackage("org.activemq");
44 if (p != null) {
45 version = p.getImplementationVersion();
46 Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+).*");
47 Matcher m = pattern.matcher(version);
48 if( m.matches() ) {
49 major = Integer.parseInt(m.group(1));
50 minor = Integer.parseInt(m.group(2));
51 }
52 }
53 } catch ( Throwable e) {
54 }
55 PROVIDER_VERSION = version;
56 PROVIDER_MAJOR_VERSION = major;
57 PROVIDER_MINOR_VERSION = minor;
58 }
59
60 /**
61 * Gets the JMS API version.
62 *
63 * @return the JMS API version
64 */
65
66 public String getJMSVersion() {
67 return "1.1";
68 }
69
70 /**
71 * Gets the JMS major version number.
72 *
73 * @return the JMS API major version number
74 */
75
76 public int getJMSMajorVersion() {
77 return 1;
78 }
79
80 /**
81 * Gets the JMS minor version number.
82 *
83 * @return the JMS API minor version number
84 */
85
86 public int getJMSMinorVersion() {
87 return 1;
88 }
89
90 /**
91 * Gets the JMS provider name.
92 *
93 * @return the JMS provider name
94 */
95
96 public String getJMSProviderName() {
97 return "ActiveMQ";
98 }
99
100 /**
101 * Gets the JMS provider version.
102 *
103 * @return the JMS provider version
104 */
105
106 public String getProviderVersion() {
107 return PROVIDER_VERSION;
108 }
109
110 /**
111 * Gets the JMS provider major version number.
112 *
113 * @return the JMS provider major version number
114 */
115
116 public int getProviderMajorVersion() {
117 return PROVIDER_MAJOR_VERSION;
118 }
119
120 /**
121 * Gets the JMS provider minor version number.
122 *
123 * @return the JMS provider minor version number
124 */
125
126 public int getProviderMinorVersion() {
127 return PROVIDER_MINOR_VERSION;
128 }
129
130 /**
131 * Gets an enumeration of the JMSX property names.
132 *
133 * @return an Enumeration of JMSX property names
134 */
135
136 public Enumeration getJMSXPropertyNames() {
137 Hashtable jmxProperties = new Hashtable();
138 jmxProperties.put("JMSXGroupID", "1");
139 jmxProperties.put("JMSXGroupSeq", "1");
140 jmxProperties.put("JMSXDeliveryCount","1");
141 return jmxProperties.keys();
142 }
143 }