001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018 package org.activemq;
019
020 import java.util.Enumeration;
021 import java.util.Hashtable;
022 import java.util.regex.Matcher;
023 import java.util.regex.Pattern;
024
025 import javax.jms.ConnectionMetaData;
026
027 /**
028 * A <CODE>ConnectionMetaData</CODE> object provides information describing
029 * the <CODE>Connection</CODE> object.
030 */
031
032 public class ActiveMQConnectionMetaData implements ConnectionMetaData {
033
034 public static final String PROVIDER_VERSION;
035 public static final int PROVIDER_MAJOR_VERSION;
036 public static final int PROVIDER_MINOR_VERSION;
037
038 static {
039 String version=null;
040 int major=0;
041 int minor=0;
042 try {
043 Package p = Package.getPackage("org.activemq");
044 if (p != null) {
045 version = p.getImplementationVersion();
046 Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+).*");
047 Matcher m = pattern.matcher(version);
048 if( m.matches() ) {
049 major = Integer.parseInt(m.group(1));
050 minor = Integer.parseInt(m.group(2));
051 }
052 }
053 } catch ( Throwable e) {
054 }
055 PROVIDER_VERSION = version;
056 PROVIDER_MAJOR_VERSION = major;
057 PROVIDER_MINOR_VERSION = minor;
058 }
059
060 /**
061 * Gets the JMS API version.
062 *
063 * @return the JMS API version
064 */
065
066 public String getJMSVersion() {
067 return "1.1";
068 }
069
070 /**
071 * Gets the JMS major version number.
072 *
073 * @return the JMS API major version number
074 */
075
076 public int getJMSMajorVersion() {
077 return 1;
078 }
079
080 /**
081 * Gets the JMS minor version number.
082 *
083 * @return the JMS API minor version number
084 */
085
086 public int getJMSMinorVersion() {
087 return 1;
088 }
089
090 /**
091 * Gets the JMS provider name.
092 *
093 * @return the JMS provider name
094 */
095
096 public String getJMSProviderName() {
097 return "ActiveMQ";
098 }
099
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 }