KickJava   Java API By Example, From Geeks To Geeks.

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


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

24 package org.objectweb.joram.client.jms.tcp;
25
26 import org.objectweb.joram.client.jms.XAConnection;
27 import org.objectweb.joram.client.jms.admin.AdminModule;
28
29 import java.util.Vector JavaDoc;
30
31 import javax.naming.NamingException JavaDoc;
32
33
34 /**
35  * An <code>XATcpConnectionFactory</code> instance is a factory of
36  * TCP connections dedicated to XA communication.
37  */

38 public class XATcpConnectionFactory
39              extends org.objectweb.joram.client.jms.XAConnectionFactory
40 {
41   /**
42    * Constructs an <code>iXATcpConnectionFactory</code> instance.
43    *
44    * @param host Name or IP address of the server's host.
45    * @param port Server's listening port.
46    */

47   public XATcpConnectionFactory(String JavaDoc host, int port)
48   {
49     super(host, port);
50   }
51
52   /**
53    * Method inherited from the <code>XAConnectionFactory</code> class.
54    *
55    * @exception JMSSecurityException If the user identification is incorrect.
56    * @exception IllegalStateException If the server is not listening.
57    */

58   public javax.jms.XAConnection JavaDoc
59       createXAConnection(String JavaDoc name, String JavaDoc password)
60     throws javax.jms.JMSException JavaDoc {
61     return new XAConnection(params,
62                             new TcpConnection(params,
63                                               name,
64                                               password,
65                                               reliableClass));
66   }
67   
68   /**
69    * Admin method creating a <code>javax.jms.XAConnectionFactory</code>
70    * instance for creating TCP connections with a given server.
71    *
72    * @param host Name or IP address of the server's host.
73    * @param port Server's listening port.
74    */

75   public static javax.jms.XAConnectionFactory JavaDoc
76       create(String JavaDoc host, int port) {
77     return create(host,
78                   port,
79                   "org.objectweb.joram.client.jms.tcp.ReliableTcpClient");
80   }
81
82   /**
83    * Admin method creating a <code>javax.jms.XAConnectionFactory</code>
84    * instance for creating TCP connections with a given server.
85    *
86    * @param host Name or IP address of the server's host.
87    * @param port Server's listening port.
88    * @param reliableClass Reliable class name.
89    */

90   public static javax.jms.XAConnectionFactory JavaDoc
91       create(String JavaDoc host,
92              int port,
93              String JavaDoc reliableClass) {
94     XATcpConnectionFactory cf = new XATcpConnectionFactory(host, port);
95     cf.setReliableClass(reliableClass);
96     return cf;
97   }
98
99   /**
100    * Admin method creating a <code>javax.jms.XAConnectionFactory</code>
101    * instance for creating TCP connections with the local server.
102    *
103    * @exception ConnectException If the admin connection is closed or broken.
104    */

105   public static javax.jms.XAConnectionFactory JavaDoc create()
106                 throws java.net.ConnectException JavaDoc
107   {
108     return create(AdminModule.getLocalHost(), AdminModule.getLocalPort());
109   }
110
111 }
112
Popular Tags