KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.ubermq.jms.client;
2
3 import com.ubermq.jms.client.impl.*;
4 import com.ubermq.jms.client.unicast.*;
5 import com.ubermq.jms.common.datagram.impl.*;
6 import java.net.*;
7 import javax.jms.*;
8
9 /**
10  * Creates a point to point connection over SSL.
11  */

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

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

47     public SSLConnectionFactory(String JavaDoc host, int port)
48     {
49         this.icd = new SimpleInternetConnectionDescriptor(host, port);
50     }
51
52     public javax.jms.Connection JavaDoc createConnection() throws JMSException
53     {
54         try {
55             return new UnicastConnection(new SSLClientSession(DatagramFactory.getInstance()),
56                                          icd,
57                                          DatagramFactory.getHolder(),
58                                          new SimpleDeliveryManager());
59         } catch(Exception JavaDoc x) {
60             throw new JMSException(x.getMessage());
61         }
62     }
63 }
64
Popular Tags