KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > ConnectionFactory


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 com.scalagent.kjoram;
25
26 import java.util.Vector JavaDoc;
27 import java.util.Hashtable JavaDoc;
28
29 import com.scalagent.kjoram.excepts.JMSException;
30
31
32 public abstract class ConnectionFactory
33   extends com.scalagent.kjoram.admin.AdministeredObject
34 {
35   /** Object containing the factory's parameters. */
36   protected FactoryParameters params;
37
38
39   /**
40    * Constructs a <code>ConnectionFactory</code> dedicated to a given server.
41    *
42    * @param host Name or IP address of the server's host.
43    * @param port Server's listening port.
44    */

45   public ConnectionFactory(String JavaDoc host, int port)
46   {
47     super(host + ":" + port);
48     params = new FactoryParameters(host, port);
49
50     if (JoramTracing.dbgClient)
51       JoramTracing.log(JoramTracing.DEBUG, this + ": created.");
52   }
53
54   /**
55    * Constructs an empty <code>ConnectionFactory</code>.
56    */

57   public ConnectionFactory()
58   {}
59
60
61   /** Returns a string view of the connection factory. */
62   public String JavaDoc toString()
63   {
64     return "CF:" + params.getHost() + "-" + params.getPort();
65   }
66
67
68   /**
69    * API method, implemented according to the communication protocol.
70    *
71    * @exception JMSSecurityException If the user identification is incorrect.
72    * @exception IllegalStateException If the server is not listening.
73    */

74   public abstract Connection
75                   createConnection(String JavaDoc name, String JavaDoc password)
76                   throws JMSException;
77
78   /**
79    * API method.
80    *
81    * @exception JMSSecurityException If the default identification is
82    * incorrect.
83    * @exception IllegalStateException If the server is not listening.
84    */

85   public Connection createConnection() throws JMSException
86   {
87     return createConnection("anonymous", "anonymous");
88   }
89
90   /**
91    * Returns the factory's configuration parameters.
92    */

93   public FactoryParameters getParameters()
94   {
95     return params;
96   }
97
98   public void setParameters(FactoryParameters params) {
99     this.params = params;
100   }
101
102   /**
103    * Codes a <code>ConnectionFactory</code> as a Hashtable for travelling
104    * through the SOAP protocol.
105    */

106   public Hashtable JavaDoc code() {
107     Hashtable JavaDoc h = super.code();
108     h.put("host",params.getHost());
109     h.put("port",new Integer JavaDoc(params.getPort()));
110     h.put("connectingTimer",new Integer JavaDoc(params.connectingTimer));
111     h.put("txPendingTimer",new Integer JavaDoc(params.txPendingTimer));
112     h.put("cnxPendingTimer",new Integer JavaDoc(params.soapCnxPendingTimer));
113     return h;
114   }
115
116   public static Object JavaDoc decode(Hashtable JavaDoc h) {
117     return null;
118   }
119 }
120
Popular Tags