KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > jms > tcp > XAQueueTcpConnectionFactory


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2004 - Bull SA
4  * Copyright (C) 2004 - ScalAgent Distributed Technologies
5  * Copyright (C) 1996 - Dyade
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA.
21  *
22  * Initial developer(s): Frederic Maistre (INRIA)
23  * Contributor(s): Nicolas Tachker (ScalAgent)
24  */

25 package org.objectweb.joram.client.jms.tcp;
26
27 import org.objectweb.joram.client.jms.XAConnection;
28 import org.objectweb.joram.client.jms.XAQueueConnection;
29 import org.objectweb.joram.client.jms.Connection;
30 import org.objectweb.joram.client.jms.QueueConnection;
31 import org.objectweb.joram.client.jms.admin.AdminModule;
32
33 import java.util.Vector JavaDoc;
34
35 import javax.naming.NamingException JavaDoc;
36
37
38 /**
39  * An <code>XAQueueTcpConnectionFactory</code> instance is a factory of
40  * TCP connections for XA PTP communication.
41  */

42 public class XAQueueTcpConnectionFactory
43              extends org.objectweb.joram.client.jms.XAQueueConnectionFactory
44 {
45   /**
46    * Constructs an <code>XAQueueTcpConnectionFactory</code> instance.
47    *
48    * @param host Name or IP address of the server's host.
49    * @param port Server's listening port.
50    */

51   public XAQueueTcpConnectionFactory(String JavaDoc host, int port)
52   {
53     super(host, port);
54   }
55
56
57   /**
58    * Method inherited from the <code>XAQueueConnectionFactory</code> class.
59    *
60    * @exception JMSSecurityException If the user identification is incorrect.
61    * @exception IllegalStateException If the server is not listening.
62    */

63   public javax.jms.XAQueueConnection JavaDoc
64       createXAQueueConnection(String JavaDoc name, String JavaDoc password)
65     throws javax.jms.JMSException JavaDoc {
66     return new XAQueueConnection(params,
67                                  new TcpConnection(params,
68                                                    name,
69                                                    password,
70                                                    reliableClass));
71   }
72
73   /**
74    * Method inherited from the <code>XAConnectionFactory</code> class.
75    *
76    * @exception JMSSecurityException If the user identification is incorrect.
77    * @exception IllegalStateException If the server is not listening.
78    */

79   public javax.jms.XAConnection JavaDoc
80       createXAConnection(String JavaDoc name, String JavaDoc password)
81     throws javax.jms.JMSException JavaDoc {
82     return new XAConnection(params,
83                             new TcpConnection(params,
84                                               name,
85                                               password,
86                                               reliableClass));
87   }
88
89   /**
90    * Method inherited from the <code>QueueConnectionFactory</code> class.
91    *
92    * @exception JMSSecurityException If the user identification is incorrect.
93    * @exception IllegalStateException If the server is not listening.
94    */

95   public javax.jms.QueueConnection JavaDoc
96       createQueueConnection(String JavaDoc name, String JavaDoc password)
97     throws javax.jms.JMSException JavaDoc {
98     return new QueueConnection(params,
99                                new TcpConnection(params,
100                                                  name,
101                                                  password,
102                                                  reliableClass));
103   }
104
105   /**
106    * Method inherited from the <code>ConnectionFactory</code> class.
107    *
108    * @exception JMSSecurityException If the user identification is incorrect.
109    * @exception IllegalStateException If the server is not listening.
110    */

111   public javax.jms.Connection JavaDoc createConnection(String JavaDoc name, String JavaDoc password)
112     throws javax.jms.JMSException JavaDoc {
113     return new Connection(params,
114                           new TcpConnection(params,
115                                             name,
116                                             password,
117                                             reliableClass));
118   }
119
120   /**
121    * Admin method creating a <code>javax.jms.XAQueueConnectionFactory</code>
122    * instance for creating TCP connections with a given server.
123    *
124    * @param host Name or IP address of the server's host.
125    * @param port Server's listening port.
126    */

127   public static javax.jms.XAQueueConnectionFactory JavaDoc
128                 create(String JavaDoc host, int port) {
129     return create(host,
130                   port,
131                   "org.objectweb.joram.client.jms.tcp.ReliableTcpClient");
132   }
133
134   /**
135    * Admin method creating a <code>javax.jms.XAQueueConnectionFactory</code>
136    * instance for creating TCP connections with a given server.
137    *
138    * @param host Name or IP address of the server's host.
139    * @param port Server's listening port.
140    * @param reliableClass Reliable class name.
141    */

142   public static javax.jms.XAQueueConnectionFactory JavaDoc
143       create(String JavaDoc host,
144              int port,
145              String JavaDoc reliableClass) {
146     XAQueueTcpConnectionFactory cf = new XAQueueTcpConnectionFactory(host, port);
147     cf.setReliableClass(reliableClass);
148     return cf;
149   }
150
151   /**
152    * Admin method creating a <code>javax.jms.XAQueueConnectionFactory</code>
153    * instance for creating TCP connections with the local server.
154    *
155    * @exception ConnectException If the admin connection is closed or broken.
156    */

157   public static javax.jms.XAQueueConnectionFactory JavaDoc create()
158                 throws java.net.ConnectException JavaDoc
159   {
160     return create(AdminModule.getLocalHost(), AdminModule.getLocalPort());
161   }
162
163 }
164
Popular Tags