01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.jms;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.Collections;
21: import java.util.Enumeration;
22:
23: import javax.jms.ConnectionMetaData;
24: import javax.jms.JMSException;
25:
26: import org.directwebremoting.util.VersionUtil;
27:
28: /**
29: * An implementation of {@link ConnectionMetaData} that uses DWR meta-data.
30: * @author Joe Walker [joe at getahead dot ltd dot uk]
31: */
32: public class DwrConnectionMetaData implements ConnectionMetaData {
33: /* (non-Javadoc)
34: * @see javax.jms.ConnectionMetaData#getJMSMajorVersion()
35: */
36: public int getJMSMajorVersion() throws JMSException {
37: return 1;
38: }
39:
40: /* (non-Javadoc)
41: * @see javax.jms.ConnectionMetaData#getJMSMinorVersion()
42: */
43: public int getJMSMinorVersion() throws JMSException {
44: return 1;
45: }
46:
47: /* (non-Javadoc)
48: * @see javax.jms.ConnectionMetaData#getJMSProviderName()
49: */
50: public String getJMSProviderName() throws JMSException {
51: return "DWR";
52: }
53:
54: /* (non-Javadoc)
55: * @see javax.jms.ConnectionMetaData#getJMSVersion()
56: */
57: public String getJMSVersion() throws JMSException {
58: return "1.1";
59: }
60:
61: /* (non-Javadoc)
62: * @see javax.jms.ConnectionMetaData#getJMSXPropertyNames()
63: */
64: public Enumeration<String> getJMSXPropertyNames()
65: throws JMSException {
66: return Collections.enumeration(properties);
67: }
68:
69: /* (non-Javadoc)
70: * @see javax.jms.ConnectionMetaData#getProviderMajorVersion()
71: */
72: public int getProviderMajorVersion() throws JMSException {
73: String version = getProviderVersion();
74: String[] strings = version.split("\\.");
75: return Integer.parseInt(strings[0]);
76: }
77:
78: /* (non-Javadoc)
79: * @see javax.jms.ConnectionMetaData#getProviderMinorVersion()
80: */
81: public int getProviderMinorVersion() throws JMSException {
82: String version = getProviderVersion();
83: String[] strings = version.split("\\.");
84: return Integer.parseInt(strings[1]);
85: }
86:
87: /* (non-Javadoc)
88: * @see javax.jms.ConnectionMetaData#getProviderVersion()
89: */
90: public String getProviderVersion() throws JMSException {
91: return VersionUtil.getLabel();
92: }
93:
94: private Collection<String> properties = new ArrayList<String>();
95: }
|