KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > client > UnicastConnectionFactory


1 package com.ubermq.jms.client;
2
3 import com.ubermq.jms.client.impl.*;
4 import com.ubermq.jms.client.unicast.*;
5 import java.net.*;
6 import javax.jms.*;
7
8 /**
9  * Creates a point to point topic connection, attached to a particular
10  * message server instance.
11  */

12 public class UnicastConnectionFactory
13     extends AbstractConnectionFactory
14     implements java.io.Serializable JavaDoc,
15     javax.jms.TopicConnectionFactory JavaDoc,
16     javax.jms.QueueConnectionFactory JavaDoc
17 {
18     private final InternetConnectionDescriptor icd;
19     public static final long serialVersionUID = 1L;
20
21     /**
22      * Connects to a named URL, if the string is of the form <code>method://host:port</code>
23      * or a named host on the default port (3999) otherwise.<p>
24      *
25      * The URL may also be a comma separated list of URLs, indicating
26      * that failover should occur if a host is unreachable. <p>
27      *
28      * The method specification is ignored.<P>
29      *
30      * @see com.ubermq.jms.client.unicast.FailoverConnectionDescriptor
31      * @param host a URL, or the name of the host to connect to.
32      */

33     public UnicastConnectionFactory(String JavaDoc url)
34     {
35         this.icd = FailoverConnectionDescriptor.parseFailoverSpec(url, com.ubermq.jms.common.MessageConstants.DEFAULT_PORT);
36     }
37
38     public UnicastConnectionFactory(URI uri)
39     {
40         this.icd = FailoverConnectionDescriptor.parseFailoverSpec(uri, com.ubermq.jms.common.MessageConstants.DEFAULT_PORT);
41     }
42
43     /**
44      * Connects to a named host and port.
45      *
46      * @param host the host to connect to.
47      * @param port the port to connect on.
48      */

49     public UnicastConnectionFactory(String JavaDoc host, int port)
50     {
51         this.icd = new SimpleInternetConnectionDescriptor(host, port);
52     }
53
54     public javax.jms.Connection JavaDoc createConnection() throws JMSException
55     {
56         try {
57             return new UnicastConnection(icd);
58         } catch(Exception JavaDoc x) {throw new JMSException(x.toString());}
59     }
60 }
61
Popular Tags