KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > jms > soap > SoapServiceStarter


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 DT)
23  */

24 package org.objectweb.joram.client.jms.soap;
25
26 import org.apache.soap.rpc.Parameter;
27 import org.apache.soap.server.DeploymentDescriptor;
28 import org.apache.soap.server.ServiceManagerClient;
29 import org.apache.soap.server.TypeMapping;
30 import org.apache.soap.util.xml.QName;
31
32 /**
33  * Utility class allowing to start JORAM SOAP service and the embedded
34  * server.
35  */

36 public class SoapServiceStarter {
37   /**
38    * Deploys and starts JORAM SOAP service and the embedded JORAM server.
39    *
40    * @param args Name of host hosting Tomcat, tomcat's HTTP port (generally
41    * 8080), identifier of the embedded server, name of the embedded
42    * server.
43    *
44    * @exception exception If the deployment fails because Tomcat is not
45    * started.
46    */

47   public static void main(String JavaDoc[] args) throws Exception JavaDoc {
48     String JavaDoc host = args[0];
49     int port = Integer.parseInt(args[1]);
50     int serverId = Integer.parseInt(args[2]);
51     String JavaDoc serverName = args[3];
52
53     java.net.URL JavaDoc url = new java.net.URL JavaDoc("http://" + host + ":" + port
54                                         + "/soap/servlet/rpcrouter");
55
56     System.out.println("Starting the SOAP service on host "
57                        + host
58                        + " listening on port "
59                        + port);
60
61     ServiceManagerClient smc = new ServiceManagerClient(url);
62     smc.deploy(getDeploymentDescriptor());
63
64     System.out.println("SOAP service deployed.");
65
66     org.apache.soap.rpc.Call call = new org.apache.soap.rpc.Call();
67     call.setTargetObjectURI("urn:ProxyService");
68     call.setMethodName("start");
69
70     java.util.Vector JavaDoc params = new java.util.Vector JavaDoc();
71     params.add(new Parameter("serverId", Integer JavaDoc.class,
72                              new Integer JavaDoc(serverId), null));
73     params.add(new Parameter("serverName", String JavaDoc.class, serverName, null));
74     call.setParams(params);
75
76     System.out.println("Starting the " + serverName + " embedded server.");
77
78     org.apache.soap.rpc.Response resp = call.invoke(url,"");
79
80     System.out.println("Server " + serverId + " started.");
81   }
82
83   /**
84    * Builds and returns the <code>DeploymentDescriptor</code> of
85    * JORAM SOAP service.
86    */

87   private static DeploymentDescriptor getDeploymentDescriptor() {
88     DeploymentDescriptor dd = new DeploymentDescriptor();
89     
90     dd.setID("urn:ProxyService");
91
92     dd.setProviderType(DeploymentDescriptor.PROVIDER_JAVA);
93     dd.setProviderClass("org.objectweb.joram.mom.proxies.soap.SoapProxyService");
94     dd.setScope(DeploymentDescriptor.SCOPE_APPLICATION);
95     
96     String JavaDoc[] methods = {"start", "setConnection", "send", "getReply"};
97     dd.setMethods(methods);
98
99     String JavaDoc[] listener = {"org.apache.soap.server.DOMFaultListener"};
100     dd.setFaultListener(listener);
101
102     dd.setMappings(getTypeMappings());
103
104     return dd;
105   }
106
107   /** Builds and return the type mappings for JORAM SOAP service. */
108   private static TypeMapping[] getTypeMappings() {
109     TypeMapping[] mappings = new TypeMapping[27];
110
111     String JavaDoc encoding = "http://schemas.xmlsoap.org/soap/encoding/";
112     String JavaDoc bSerializer = "org.apache.soap.encoding.soapenc.BeanSerializer";
113
114     int i = 0;
115
116     mappings[i++] =
117       new TypeMapping(encoding,
118                       new QName("urn:ProxyService", "AbstractJmsRequest"),
119                       "org.objectweb.joram.shared.client.AbstractJmsRequest",
120                       bSerializer, bSerializer);
121     mappings[i++] =
122       new TypeMapping(encoding,
123                       new QName("urn:ProxyService", "CnxConnectRequest"),
124                       "org.objectweb.joram.shared.client.CnxConnectRequest",
125                       bSerializer, bSerializer);
126     mappings[i++] =
127       new TypeMapping(encoding,
128                       new QName("urn:ProxyService", "CnxStartRequest"),
129                       "org.objectweb.joram.shared.client.CnxStartRequest",
130                       bSerializer, bSerializer);
131     mappings[i++] =
132       new TypeMapping(encoding,
133                       new QName("urn:ProxyService", "CnxStopRequest"),
134                       "org.objectweb.joram.shared.client.CnxStopRequest",
135                       bSerializer, bSerializer);
136     mappings[i++] =
137       new TypeMapping(encoding,
138                       new QName("urn:ProxyService", "CnxCloseRequest"),
139                       "org.objectweb.joram.shared.client.CnxCloseRequest",
140                       bSerializer, bSerializer);
141     mappings[i++] =
142       new TypeMapping(encoding,
143                       new QName("urn:ProxyService", "ConsumerAckRequest"),
144                       "org.objectweb.joram.shared.client.ConsumerAckRequest",
145                       bSerializer, bSerializer);
146     mappings[i++] =
147       new TypeMapping(encoding,
148                       new QName("urn:ProxyService", "ConsumerDenyRequest"),
149                       "org.objectweb.joram.shared.client.ConsumerDenyRequest",
150                       bSerializer, bSerializer);
151     mappings[i++] =
152       new TypeMapping(encoding,
153                       new QName("urn:ProxyService", "ConsumerReceiveRequest"),
154                       "org.objectweb.joram.shared.client.ConsumerReceiveRequest",
155                       bSerializer, bSerializer);
156     mappings[i++] =
157       new TypeMapping(encoding,
158                       new QName("urn:ProxyService", "ConsumerSetListRequest"),
159                       "org.objectweb.joram.shared.client.ConsumerSetListRequest",
160                       bSerializer, bSerializer);
161     mappings[i++] =
162        new TypeMapping(encoding,
163                        new QName("urn:ProxyService",
164                                  "ConsumerUnsetListRequest"),
165                        "org.objectweb.joram.shared.client.ConsumerUnsetListRequest",
166                        bSerializer, bSerializer);
167     mappings[i++] =
168       new TypeMapping(encoding,
169                       new QName("urn:ProxyService", "ConsumerSubRequest"),
170                       "org.objectweb.joram.shared.client.ConsumerSubRequest",
171                       bSerializer, bSerializer);
172     mappings[i++] =
173       new TypeMapping(encoding,
174                       new QName("urn:ProxyService", "ConsumerCloseSubRequest"),
175                       "org.objectweb.joram.shared.client.ConsumerCloseSubRequest",
176                       bSerializer, bSerializer);
177     mappings[i++] =
178       new TypeMapping(encoding,
179                       new QName("urn:ProxyService", "ConsumerUnsubRequest"),
180                       "org.objectweb.joram.shared.client.ConsumerUnsubRequest",
181                       bSerializer, bSerializer);
182     mappings[i++] =
183       new TypeMapping(encoding,
184                       new QName("urn:ProxyService", "QBrowseRequest"),
185                       "org.objectweb.joram.shared.client.QBrowseRequest",
186                       bSerializer, bSerializer);
187     mappings[i++] =
188       new TypeMapping(encoding,
189                       new QName("urn:ProxyService", "SessAckRequest"),
190                       "org.objectweb.joram.shared.client.SessAckRequest",
191                       bSerializer, bSerializer);
192     mappings[i++] =
193       new TypeMapping(encoding,
194                       new QName("urn:ProxyService", "SessDenyRequest"),
195                       "org.objectweb.joram.shared.client.SessDenyRequest",
196                       bSerializer, bSerializer);
197     mappings[i++] =
198       new TypeMapping(encoding,
199                       new QName("urn:ProxyService", "SessCreateTQRequest"),
200                       "org.objectweb.joram.shared.client.SessCreateTQRequest",
201                       bSerializer, bSerializer);
202     mappings[i++] =
203       new TypeMapping(encoding,
204                       new QName("urn:ProxyService", "SessCreateTTRequest"),
205                       "org.objectweb.joram.shared.client.SessCreateTTRequest",
206                       bSerializer, bSerializer);
207     mappings[i++] =
208       new TypeMapping(encoding,
209                       new QName("urn:ProxyService", "TempDestDeleteRequest"),
210                       "org.objectweb.joram.shared.client.TempDestDeleteRequest",
211                       bSerializer, bSerializer);
212     mappings[i++] =
213       new TypeMapping(encoding,
214                       new QName("urn:ProxyService", "GetAdminTopicRequest"),
215                       "org.objectweb.joram.shared.client.GetAdminTopicRequest",
216                       bSerializer, bSerializer);
217     mappings[i++] =
218       new TypeMapping(encoding,
219                       new QName("urn:ProxyService", "AbstractJmsReply"),
220                       "org.objectweb.joram.shared.client.AbstractJmsReply",
221                       bSerializer, bSerializer);
222     mappings[i++] =
223       new TypeMapping(encoding,
224                       new QName("urn:ProxyService", "ServerReply"),
225                       "org.objectweb.joram.shared.client.ServerReply",
226                       bSerializer, bSerializer);
227     mappings[i++] =
228       new TypeMapping(encoding,
229                       new QName("urn:ProxyService", "MomExceptionReply"),
230                       "org.objectweb.joram.shared.client.MomExceptionReply",
231                       bSerializer, bSerializer);
232     mappings[i++] =
233       new TypeMapping(encoding,
234                       new QName("urn:ProxyService", "CnxConnectReply"),
235                       "org.objectweb.joram.shared.client.CnxConnectReply",
236                       bSerializer, bSerializer);
237     mappings[i++] =
238       new TypeMapping(encoding,
239                       new QName("urn:ProxyService", "CnxCloseReply"),
240                       "org.objectweb.joram.shared.client.CnxCloseReply",
241                       bSerializer, bSerializer);
242     mappings[i++] =
243       new TypeMapping(encoding,
244                       new QName("urn:ProxyService", "SessCreateTDReply"),
245                       "org.objectweb.joram.shared.client.SessCreateTDReply",
246                       bSerializer, bSerializer);
247     mappings[i++] =
248       new TypeMapping(encoding,
249                       new QName("urn:ProxyService", "GetAdminTopicReply"),
250                       "org.objectweb.joram.shared.client.GetAdminTopicReply",
251                       bSerializer, bSerializer);
252
253     return mappings;
254   }
255 }
256
Popular Tags