KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > client > JBossConnectionFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.jms.client;
8
9 import javax.jms.Connection JavaDoc;
10 import javax.jms.ConnectionFactory JavaDoc;
11 import javax.jms.JMSException JavaDoc;
12 import javax.jms.QueueConnection JavaDoc;
13 import javax.jms.QueueConnectionFactory JavaDoc;
14 import javax.jms.TopicConnection JavaDoc;
15 import javax.jms.TopicConnectionFactory JavaDoc;
16 import javax.jms.XAConnection JavaDoc;
17 import javax.jms.XAConnectionFactory JavaDoc;
18 import javax.jms.XAQueueConnection JavaDoc;
19 import javax.jms.XAQueueConnectionFactory JavaDoc;
20 import javax.jms.XATopicConnection JavaDoc;
21 import javax.jms.XATopicConnectionFactory JavaDoc;
22 import javax.naming.NamingException JavaDoc;
23 import javax.naming.Reference JavaDoc;
24 import javax.naming.Referenceable JavaDoc;
25
26 /**
27  * A connection factory
28  *
29  * @author <a HREF="mailto:adrian@jboss.org>Adrian Brock</a>
30  * @version $Revision: 1.1 $
31  */

32 public class JBossConnectionFactory
33    implements ConnectionFactory JavaDoc, QueueConnectionFactory JavaDoc, TopicConnectionFactory JavaDoc,
34               XAConnectionFactory JavaDoc, XAQueueConnectionFactory JavaDoc, XATopicConnectionFactory JavaDoc,
35               Referenceable JavaDoc
36 {
37    // Constants -----------------------------------------------------
38

39    // Attributes ----------------------------------------------------
40

41    /** The implementation delegate */
42    ImplementationDelegate delegate;
43
44    // Static --------------------------------------------------------
45

46    // Constructors --------------------------------------------------
47

48    // Public --------------------------------------------------------
49

50    /**
51     * Construct a new Connection factory
52     *
53     * @param delegate the implementation
54     */

55    public JBossConnectionFactory(ImplementationDelegate delegate)
56       throws JMSException JavaDoc
57    {
58       this.delegate = delegate;
59    }
60
61    // ConnectionFactory implementation ------------------------------
62

63     public Connection JavaDoc createConnection()
64       throws JMSException JavaDoc
65     {
66       return createConnection(null, null);
67     }
68
69     public Connection JavaDoc createConnection(String JavaDoc userName, String JavaDoc password)
70       throws JMSException JavaDoc
71     {
72       ConnectionDelegate connection = delegate.createConnection(userName, password);
73       return new JBossConnection(connection, false);
74     }
75
76    // QueueConnectionFactory implementation -------------------------
77

78     public QueueConnection JavaDoc createQueueConnection()
79       throws JMSException JavaDoc
80     {
81       return (QueueConnection JavaDoc) createConnection(null, null);
82     }
83
84     public QueueConnection JavaDoc createQueueConnection(String JavaDoc userName, String JavaDoc password)
85       throws JMSException JavaDoc
86     {
87       return (QueueConnection JavaDoc) createConnection(userName, password);
88     }
89
90    // TopicConnectionFactory implementation -------------------------
91

92     public TopicConnection JavaDoc createTopicConnection()
93       throws JMSException JavaDoc
94     {
95       return (TopicConnection JavaDoc) createConnection(null, null);
96     }
97
98     public TopicConnection JavaDoc createTopicConnection(String JavaDoc userName, String JavaDoc password)
99       throws JMSException JavaDoc
100     {
101       return (TopicConnection JavaDoc) createConnection(userName, password);
102     }
103
104    // XAConnectionFactory implementation ----------------------------
105

106    public XAConnection JavaDoc createXAConnection() throws JMSException JavaDoc
107    {
108       return createXAConnection(null, null);
109    }
110
111    public XAConnection JavaDoc createXAConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
112    {
113       ConnectionDelegate connection = delegate.createConnection(userName, password);
114       return new JBossConnection(connection, true);
115    }
116
117    // XAQueueConnectionFactory implementation -----------------------
118

119    public XAQueueConnection JavaDoc createXAQueueConnection() throws JMSException JavaDoc
120    {
121       return (XAQueueConnection JavaDoc) createXAConnection(null, null);
122    }
123
124    public XAQueueConnection JavaDoc createXAQueueConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
125    {
126       return (XAQueueConnection JavaDoc) createXAConnection(userName, password);
127    }
128
129    // XATopicConnectionFactory implementation -----------------------
130

131    public XATopicConnection JavaDoc createXATopicConnection() throws JMSException JavaDoc
132    {
133       return (XATopicConnection JavaDoc) createXAConnection(null, null);
134    }
135
136    public XATopicConnection JavaDoc createXATopicConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
137    {
138       return (XATopicConnection JavaDoc) createXAConnection(userName, password);
139    }
140
141    // Referenceable implementation------------------------------------
142

143    public Reference JavaDoc getReference() throws NamingException JavaDoc
144    {
145       return delegate.getReference();
146    }
147
148    // Protected ------------------------------------------------------
149

150    // Package Private ------------------------------------------------
151

152    // Private --------------------------------------------------------
153

154    // Inner Classes --------------------------------------------------
155

156 }
157
Popular Tags