KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > ksoap > SoapConnectionFactory


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): Nicolas Tachker (ScalAgent)
22  * Contributor(s):
23  */

24 package com.scalagent.kjoram.ksoap;
25
26 import com.scalagent.kjoram.Connection;
27 import com.scalagent.kjoram.FactoryParameters;
28 import com.scalagent.kjoram.excepts.*;
29
30 import java.util.Vector JavaDoc;
31 import java.util.Hashtable JavaDoc;
32
33
34 /**
35  * A <code>SoapConnectionFactory</code> instance is a factory of SOAP
36  * connections.
37  */

38 public class SoapConnectionFactory extends com.scalagent.kjoram.ConnectionFactory
39 {
40   /**
41    * Constructs a <code>SoapConnectionFactory</code> instance.
42    *
43    * @param host Name or IP address of the server's host.
44    * @param port Server's listening port.
45    * @param timeout Duration in seconds during which a SOAP connection might
46    * be inactive before being considered as dead (0 for never).
47    */

48   public SoapConnectionFactory(String JavaDoc host, int port, int timeout)
49   {
50     super(host, port);
51     params.soapCnxPendingTimer = timeout;
52   }
53
54   /**
55    * Constructs an empty <code>SoapConnectionFactory</code> instance.
56    */

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

67   public Connection createConnection(String JavaDoc name, String JavaDoc password)
68          throws JMSException
69   {
70     return new Connection(params, new SoapConnection(params, name, password));
71   }
72
73   public static Object JavaDoc decode(Hashtable JavaDoc h) {
74     SoapConnectionFactory ret = new SoapConnectionFactory();
75     FactoryParameters params =
76       new FactoryParameters((String JavaDoc) h.get("host"),
77                             ((Integer JavaDoc) h.get("port")).intValue());
78     params.connectingTimer = ((Integer JavaDoc) h.get("connectingTimer")).intValue();
79     params.txPendingTimer = ((Integer JavaDoc) h.get("txPendingTimer")).intValue();
80     params.soapCnxPendingTimer = ((Integer JavaDoc) h.get("cnxPendingTimer")).intValue();
81     ret.setParameters(params);
82     ret.setId(ret.getClass().getName() + ":" +
83               params.getHost()+ ":" + params.getPort());
84     ret.addInstanceTable(ret.getId(), ret);
85     return ret;
86   }
87 }
88
Popular Tags