KickJava   Java API By Example, From Geeks To Geeks.

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


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.Connection;
28 import org.objectweb.joram.client.jms.FactoryParameters;
29 import org.objectweb.joram.client.jms.TopicConnection;
30 import org.objectweb.joram.client.jms.admin.AdminModule;
31
32 import java.util.Vector JavaDoc;
33
34 import javax.naming.NamingException JavaDoc;
35
36
37 /**
38  * A <code>TopicTcpConnectionFactory</code> instance is a factory of
39  * TCP connections for Pub/Sub communication.
40  */

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

50   public TopicTcpConnectionFactory(String JavaDoc host, int port)
51   {
52     super(host, port);
53   }
54
55   /**
56    * Constructs an empty <code>TopicTcpConnectionFactory</code> instance.
57    */

58   public TopicTcpConnectionFactory()
59   {}
60
61   /**
62    * Method inherited from the <code>TopicConnectionFactory</code> class.
63    *
64    * @exception JMSSecurityException If the user identification is incorrect.
65    * @exception IllegalStateException If the server is not listening.
66    */

67   public javax.jms.TopicConnection JavaDoc
68       createTopicConnection(String JavaDoc name, String JavaDoc password)
69     throws javax.jms.JMSException JavaDoc {
70     return new TopicConnection(params,
71                                new TcpConnection(params,
72                                                  name,
73                                                  password,
74                                                  reliableClass));
75   }
76
77   /**
78    * Method inherited from the <code>ConnectionFactory</code> class.
79    *
80    * @exception JMSSecurityException If the user identification is incorrect.
81    * @exception IllegalStateException If the server is not listening.
82    */

83   public javax.jms.Connection JavaDoc createConnection(String JavaDoc name, String JavaDoc password)
84     throws javax.jms.JMSException JavaDoc {
85     return new Connection(params,
86                           new TcpConnection(params,
87                                             name,
88                                             password,
89                                             reliableClass));
90   }
91
92
93   /**
94    * Admin method creating a <code>javax.jms.TopicConnectionFactory</code>
95    * instance for creating TCP connections with a given server.
96    *
97    * @param host Name or IP address of the server's host.
98    * @param port Server's listening port.
99    */

100   public static javax.jms.TopicConnectionFactory JavaDoc
101       create(String JavaDoc host, int port) {
102     return create(host,
103                   port,
104                   "org.objectweb.joram.client.jms.tcp.ReliableTcpClient");
105   }
106
107   /**
108    * Admin method creating a <code>javax.jms.TopicConnectionFactory</code>
109    * instance for creating TCP connections with a given server.
110    *
111    * @param host Name or IP address of the server's host.
112    * @param port Server's listening port.
113    * @param reliableClass Reliable class name.
114    */

115   public static javax.jms.TopicConnectionFactory JavaDoc
116       create(String JavaDoc host,
117              int port,
118              String JavaDoc reliableClass) {
119     TopicTcpConnectionFactory cf = new TopicTcpConnectionFactory(host, port);
120     cf.setReliableClass(reliableClass);
121     return cf;
122   }
123
124   /**
125    * Admin method creating a <code>javax.jms.TopicConnectionFactory</code>
126    * instance for creating TCP connections with the local server.
127    *
128    * @exception ConnectException If the admin connection is closed or broken.
129    */

130   public static javax.jms.TopicConnectionFactory JavaDoc create()
131                 throws java.net.ConnectException JavaDoc
132   {
133     return create(AdminModule.getLocalHost(), AdminModule.getLocalPort());
134   }
135 }
136
Popular Tags