KickJava   Java API By Example, From Geeks To Geeks.

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


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.jms.*;
27
28 import java.io.IOException JavaDoc;
29 import java.io.InterruptedIOException JavaDoc;
30 import java.util.Vector JavaDoc;
31
32 /**
33  * A <code>SoapDriver</code> gets server deliveries through RCP SOAP calls.
34  */

35 class SoapDriver extends com.scalagent.kjoram.Driver {
36
37   String JavaDoc serviceUrl = null;
38   int cnxId = -1;
39   HttpConnection httpConnection = null;
40   String JavaDoc name = null;
41
42   /**
43    * Constructs a <code>SoapDriver</code> daemon.
44    *
45    * @param cnx The connection the driver belongs to.
46    */

47   SoapDriver(com.scalagent.kjoram.Connection cnx,
48              String JavaDoc serviceUrl,
49              int cnxId) {
50     super(cnx);
51     this.serviceUrl = serviceUrl;
52     this.cnxId = cnxId;
53     httpConnection = new HttpConnection(serviceUrl);
54     name = cnx.getUserName();
55   }
56
57
58   /**
59    * Returns an <code>AbstractJmsReply</code> delivered by the server.
60    *
61    * @exception IOException If the SOAP call failed, or if the SOAP service
62    * is unable to process the call, or if the driver closes.
63    */

64   protected AbstractJmsReply getDelivery() throws IOException JavaDoc {
65     AbstractJmsReply reply = null;
66
67     try {
68       reply = httpConnection.call(new GetReply(name,cnxId),name,cnxId);
69
70       if (reply == null) return null;
71     } catch (Exception JavaDoc exc) {
72       throw new IOException JavaDoc("The SOAP call failed: " + exc.getMessage());
73     }
74
75     if (reply instanceof CnxCloseReply) {
76       throw new IOException JavaDoc("Driver is closing.");
77     } else if (reply instanceof AbstractJmsReply) {
78       return (AbstractJmsReply) reply;
79     } else {
80       throw new IOException JavaDoc("The SOAP service failed to process the call: "
81                             + reply);
82     }
83   }
84
85   /** Shuts down the driver. */
86   public void shutdown() {
87   }
88 }
89
Popular Tags