KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > ActiveMQConnectionMetaData


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq;
19
20 import java.util.Enumeration JavaDoc;
21 import java.util.Hashtable JavaDoc;
22 import java.util.regex.Matcher JavaDoc;
23 import java.util.regex.Pattern JavaDoc;
24
25 import javax.jms.ConnectionMetaData JavaDoc;
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 JavaDoc {
33
34     public static final String JavaDoc PROVIDER_VERSION;
35     public static final int PROVIDER_MAJOR_VERSION;
36     public static final int PROVIDER_MINOR_VERSION;
37     
38     public static final ActiveMQConnectionMetaData INSTANCE = new ActiveMQConnectionMetaData();
39     
40     static {
41         String JavaDoc version=null;
42         int major=0;
43         int minor=0;
44         try {
45             Package JavaDoc p = Package.getPackage("org.apache.activemq");
46             if (p != null) {
47                 version = p.getImplementationVersion();
48                 Pattern JavaDoc pattern = Pattern.compile("(\\d+)\\.(\\d+).*");
49                 Matcher JavaDoc m = pattern.matcher(version);
50                 if( m.matches() ) {
51                     major = Integer.parseInt(m.group(1));
52                     minor = Integer.parseInt(m.group(2));
53                 }
54             }
55         } catch ( Throwable JavaDoc e) {
56         }
57         PROVIDER_VERSION = version;
58         PROVIDER_MAJOR_VERSION = major;
59         PROVIDER_MINOR_VERSION = minor;
60     }
61     
62     private ActiveMQConnectionMetaData() {}
63     
64     /**
65      * Gets the JMS API version.
66      *
67      * @return the JMS API version
68      */

69
70     public String JavaDoc getJMSVersion() {
71         return "1.1";
72     }
73
74     /**
75      * Gets the JMS major version number.
76      *
77      * @return the JMS API major version number
78      */

79
80     public int getJMSMajorVersion() {
81         return 1;
82     }
83
84     /**
85      * Gets the JMS minor version number.
86      *
87      * @return the JMS API minor version number
88      */

89
90     public int getJMSMinorVersion() {
91         return 1;
92     }
93
94     /**
95      * Gets the JMS provider name.
96      *
97      * @return the JMS provider name
98      */

99
100     public String JavaDoc getJMSProviderName() {
101         return "ActiveMQ";
102     }
103
104     /**
105      * Gets the JMS provider version.
106      *
107      * @return the JMS provider version
108      */

109
110     public String JavaDoc getProviderVersion() {
111         return PROVIDER_VERSION;
112     }
113
114     /**
115      * Gets the JMS provider major version number.
116      *
117      * @return the JMS provider major version number
118      */

119
120     public int getProviderMajorVersion() {
121         return PROVIDER_MAJOR_VERSION;
122     }
123
124     /**
125      * Gets the JMS provider minor version number.
126      *
127      * @return the JMS provider minor version number
128      */

129
130     public int getProviderMinorVersion() {
131         return PROVIDER_MINOR_VERSION;
132     }
133
134     /**
135      * Gets an enumeration of the JMSX property names.
136      *
137      * @return an Enumeration of JMSX property names
138      */

139
140     public Enumeration JavaDoc getJMSXPropertyNames() {
141         Hashtable JavaDoc jmxProperties = new Hashtable JavaDoc();
142         jmxProperties.put("JMSXGroupID", "1");
143         jmxProperties.put("JMSXGroupSeq", "1");
144         jmxProperties.put("JMSXDeliveryCount","1");
145         return jmxProperties.keys();
146     }
147 }
148
Popular Tags