KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > providers > java > JavaProvider


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55
56 package org.jboss.axis.providers.java;
57
58 import org.jboss.axis.AxisEngine;
59 import org.jboss.axis.AxisFault;
60 import org.jboss.axis.Constants;
61 import org.jboss.axis.Handler;
62 import org.jboss.axis.Message;
63 import org.jboss.axis.MessageContext;
64 import org.jboss.axis.description.ServiceDesc;
65 import org.jboss.axis.encoding.TypeMapping;
66 import org.jboss.axis.enums.Scope;
67 import org.jboss.axis.handlers.soap.SOAPService;
68 import org.jboss.axis.message.SOAPEnvelopeAxisImpl;
69 import org.jboss.axis.providers.BasicProvider;
70 import org.jboss.axis.session.Session;
71 import org.jboss.axis.utils.ClassUtils;
72 import org.jboss.axis.utils.Messages;
73 import org.jboss.axis.utils.cache.ClassCache;
74 import org.jboss.axis.utils.cache.JavaClass;
75 import org.jboss.axis.wsdl.fromJava.Emitter;
76 import org.jboss.logging.Logger;
77 import org.w3c.dom.Document JavaDoc;
78 import org.xml.sax.SAXException JavaDoc;
79
80 import javax.xml.rpc.JAXRPCException JavaDoc;
81 import javax.xml.rpc.holders.IntHolder JavaDoc;
82 import javax.xml.rpc.server.ServiceLifecycle JavaDoc;
83 import java.util.ArrayList JavaDoc;
84 import java.util.StringTokenizer JavaDoc;
85
86 /**
87  * Base class for Java dispatching. Fetches various fields out of envelope,
88  * looks up service object (possibly using session state), and delegates
89  * envelope body processing to subclass via abstract processMessage method.
90  *
91  * @author Doug Davis (dug@us.ibm.com)
92  * @author Carl Woolf (cwoolf@macromedia.com)
93  */

94 public abstract class JavaProvider extends BasicProvider
95 {
96    private static Logger log = Logger.getLogger(JavaProvider.class.getName());
97
98    public static final String JavaDoc OPTION_CLASSNAME = "className";
99    public static final String JavaDoc OPTION_ALLOWEDMETHODS = "allowedMethods";
100    public static final String JavaDoc OPTION_IS_STATIC = "isStatic";
101    public static final String JavaDoc OPTION_CLASSPATH = "classPath";
102    public static final String JavaDoc OPTION_WSDL_PORTTYPE = "wsdlPortType";
103    public static final String JavaDoc OPTION_WSDL_SERVICEELEMENT = "wsdlServiceElement";
104    public static final String JavaDoc OPTION_WSDL_SERVICEPORT = "wsdlServicePort";
105    public static final String JavaDoc OPTION_WSDL_TARGETNAMESPACE = "wsdlTargetNamespace";
106    public static final String JavaDoc OPTION_WSDL_INPUTSCHEMA = "wsdlInputSchema";
107
108    public static final String JavaDoc OPTION_SCOPE = "scope";
109
110    /**
111     * Get the service object whose method actually provides the service.
112     * May look up in session table.
113     */

114    public Object JavaDoc getServiceObject(MessageContext msgContext,
115                                   Handler service,
116                                   String JavaDoc clsName,
117                                   IntHolder JavaDoc scopeHolder)
118            throws Exception JavaDoc
119    {
120       String JavaDoc serviceName = msgContext.getService().getName();
121
122       // scope can be "Request", "Session", "Application"
123
// (as with Apache SOAP)
124
Scope scope = Scope.getScope((String JavaDoc)service.getOption(OPTION_SCOPE), Scope.DEFAULT);
125
126       scopeHolder.value = scope.getValue();
127
128       if (scope == Scope.REQUEST)
129       {
130          // make a one-off
131
return getNewServiceObject(msgContext, clsName);
132       }
133       else if (scope == Scope.SESSION)
134       {
135          // What do we do if serviceName is null at this point???
136
if (serviceName == null)
137             serviceName = msgContext.getService().toString();
138
139          // look in incoming session
140
Session session = msgContext.getSession();
141          if (session != null)
142          {
143             return getSessionServiceObject(session, serviceName,
144                     msgContext, clsName);
145          }
146          else
147          {
148             // was no incoming session, sigh, treat as request scope
149
scopeHolder.value = Scope.DEFAULT.getValue();
150             return getNewServiceObject(msgContext, clsName);
151          }
152       }
153       else if (scope == Scope.APPLICATION)
154       {
155          // MUST be AxisEngine here!
156
AxisEngine engine = msgContext.getAxisEngine();
157          Session appSession = engine.getApplicationSession();
158          if (appSession != null)
159          {
160             return getSessionServiceObject(appSession, serviceName,
161                     msgContext, clsName);
162          }
163          else
164          {
165             // was no application session, sigh, treat as request scope
166
// FIXME : Should we bomb in this case?
167
scopeHolder.value = Scope.DEFAULT.getValue();
168             return getNewServiceObject(msgContext, clsName);
169          }
170       }
171       else
172       {
173          // NOTREACHED
174
return null;
175       }
176    }
177
178    /**
179     * Simple utility class for dealing with synchronization issues.
180     */

181    class LockObject
182    {
183       private boolean completed = false;
184
185       synchronized void waitUntilComplete() throws InterruptedException JavaDoc
186       {
187          while (!completed)
188          {
189             wait();
190          }
191       }
192
193       synchronized void complete()
194       {
195          completed = true;
196          notifyAll();
197       }
198    }
199
200    /**
201     * Get a service object from a session. Handles threading / locking
202     * issues when multiple threads might be accessing the same session
203     * object, and ensures only one thread gets to create the service
204     * object if there isn't one already.
205     */

206    private Object JavaDoc getSessionServiceObject(Session session,
207                                           String JavaDoc serviceName,
208                                           MessageContext msgContext,
209                                           String JavaDoc clsName) throws Exception JavaDoc
210    {
211       Object JavaDoc obj = null;
212       boolean makeNewObject = false;
213
214       // This is a little tricky.
215
synchronized (session.getLockObject())
216       {
217          // store service objects in session, indexed by class name
218
obj = session.get(serviceName);
219
220          // If nothing there, put in a placeholder object so
221
// other threads wait for us to create the real
222
// service object.
223
if (obj == null)
224          {
225             obj = new LockObject();
226             makeNewObject = true;
227             session.set(serviceName, obj);
228          }
229       }
230
231       // OK, we DEFINITELY have something in obj at this point. Either
232
// it's the service object or it's a LockObject (ours or someone
233
// else's).
234

235       if (LockObject.class == obj.getClass())
236       {
237          LockObject lock = (LockObject)obj;
238
239          // If we were the lucky thread who got to install the
240
// placeholder, create a new service object and install it
241
// instead, then notify anyone waiting on the LockObject.
242
if (makeNewObject)
243          {
244             try
245             {
246                obj = getNewServiceObject(msgContext, clsName);
247                session.set(serviceName, obj);
248             }
249             finally
250             {
251                lock.complete();
252             }
253          }
254          else
255          {
256             // It's someone else's LockObject, so wait around until
257
// it's completed.
258
lock.waitUntilComplete();
259
260             // Now we are guaranteed there is a service object in the
261
// session, so this next part doesn't need syncing
262
obj = session.get(serviceName);
263          }
264       }
265
266       return obj;
267    }
268
269    /**
270     * Return a new service object which, if it implements the ServiceLifecycle
271     * interface, has been init()ed.
272     *
273     * @param msgContext the MessageContext
274     * @param clsName the name of the class to instantiate
275     * @return an initialized service object
276     */

277    private Object JavaDoc getNewServiceObject(MessageContext msgContext,
278                                       String JavaDoc clsName) throws Exception JavaDoc
279    {
280       Object JavaDoc serviceObject = makeNewServiceObject(msgContext, clsName);
281       if (serviceObject != null &&
282               serviceObject instanceof ServiceLifecycle JavaDoc)
283       {
284          ((ServiceLifecycle JavaDoc)serviceObject).init(msgContext.getProperty(Constants.MC_SERVLET_ENDPOINT_CONTEXT));
285       }
286       return serviceObject;
287    }
288
289    /**
290     * Process the current message. Side-effect resEnv to create return value.
291     *
292     * @param msgContext self-explanatory
293     * @param reqEnv the request envelope
294     * @param resEnv the response envelope
295     * @param obj the service object itself
296     */

297    public abstract void processMessage(MessageContext msgContext,
298                                        SOAPEnvelopeAxisImpl reqEnv,
299                                        SOAPEnvelopeAxisImpl resEnv,
300                                        Object JavaDoc obj)
301            throws Exception JavaDoc;
302
303
304    /**
305     * Invoke the message by obtaining various common fields, looking up
306     * the service object (via getServiceObject), and actually processing
307     * the message (via processMessage).
308     */

309    public void invoke(MessageContext msgContext) throws AxisFault
310    {
311       if (log.isDebugEnabled())
312          log.debug("Enter: JavaProvider::invoke (" + this + ")");
313
314       /* Find the service we're invoking so we can grab it's options */
315       /***************************************************************/
316       String JavaDoc serviceName = msgContext.getTargetService();
317       Handler service = msgContext.getService();
318
319       /* Now get the service (RPC) specific info */
320       /********************************************/
321       String JavaDoc clsName = getServiceClassName(service);
322
323       if ((clsName == null) || clsName.equals(""))
324       {
325          throw new AxisFault("Server.NoClassForService",
326                  Messages.getMessage("noOption00", getServiceClassNameOptionName(), serviceName),
327                  null, null);
328       }
329
330       IntHolder JavaDoc scope = new IntHolder JavaDoc();
331       Object JavaDoc serviceObject = null;
332
333       try
334       {
335          serviceObject = getServiceObject(msgContext, service, clsName, scope);
336
337          Message resMsg = msgContext.getResponseMessage();
338          SOAPEnvelopeAxisImpl resEnv;
339
340          // If we didn't have a response message, make sure we set one up
341
// with the appropriate versions of SOAP and Schema
342
if (resMsg == null)
343          {
344             resEnv = new SOAPEnvelopeAxisImpl(msgContext.getSOAPConstants(),
345                     msgContext.getSchemaVersion());
346
347             resMsg = new Message(resEnv);
348             msgContext.setResponseMessage(resMsg);
349          }
350          else
351          {
352             resEnv = resMsg.getSOAPEnvelope();
353          }
354
355          Message reqMsg = msgContext.getRequestMessage();
356          SOAPEnvelopeAxisImpl reqEnv = reqMsg.getSOAPEnvelope();
357
358          processMessage(msgContext, reqEnv, resEnv, serviceObject);
359       }
360       catch (Exception JavaDoc ex)
361       {
362          processException(ex);
363          log.error("Detect unprocessed exception", ex);
364          throw AxisFault.makeFault(ex);
365       }
366       finally
367       {
368          // If this is a request scoped service object which implements
369
// ServiceLifecycle, let it know that it's being destroyed now.
370
if (serviceObject != null &&
371                  scope.value == Scope.REQUEST.getValue() &&
372                  serviceObject instanceof ServiceLifecycle JavaDoc)
373          {
374             ((ServiceLifecycle JavaDoc)serviceObject).destroy();
375          }
376       }
377
378       if (log.isDebugEnabled())
379          log.debug("Exit: JavaProvider::invoke (" + this + ")");
380    }
381
382    /**
383     * Externalize exception handling
384     * @param ex Exception during message processing
385     * @throws AxisFault The generated Axis fault
386     */

387    protected void processException(Exception JavaDoc ex) throws AxisFault
388    {
389       if (ex instanceof AxisFault)
390       {
391          throw (AxisFault)ex;
392       }
393
394       // This hack unwrapps the checked AxisException from a RuntimeException
395
// so we don't loose the fault code, etc
396
// [TDI] 17-Aug-2004
397
if (ex instanceof JAXRPCException JavaDoc)
398       {
399          JAXRPCException JavaDoc rte = (JAXRPCException JavaDoc)ex;
400          if (rte.getLinkedCause() instanceof AxisFault)
401             throw (AxisFault)rte.getLinkedCause();
402
403          AxisFault fault = AxisFault.makeFault(ex);
404          fault.addFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION, "true");
405          throw fault;
406       }
407
408       if (ex instanceof SAXException JavaDoc)
409       {
410          SAXException JavaDoc exp = (SAXException JavaDoc)ex;
411          Exception JavaDoc real = exp.getException();
412          if (real != null)
413             throw AxisFault.makeFault(real);
414       }
415
416       AxisFault fault = AxisFault.makeFault(ex);
417       throw fault;
418    }
419
420    /**
421     * Generate the WSDL for this service.
422     * <p/>
423     * Put in the "WSDL" property of the message context
424     * as a org.w3c.dom.Document
425     */

426    public void generateWSDL(MessageContext msgContext) throws AxisFault
427    {
428       if (log.isDebugEnabled())
429          log.debug("Enter: JavaProvider::generateWSDL (" + this + ")");
430
431       /* Find the service we're invoking so we can grab it's options */
432       /***************************************************************/
433       SOAPService service = msgContext.getService();
434       ServiceDesc serviceDesc = service.getInitializedServiceDesc(msgContext);
435
436       // Calculate the appropriate namespaces for the WSDL we're going
437
// to put out.
438
//
439
// If we've been explicitly told which namespaces to use, respect
440
// that. If not:
441
//
442
// The "interface namespace" should be either:
443
// 1) The namespace of the ServiceDesc
444
// 2) The transport URL (if there's no ServiceDesc ns)
445

446       try
447       {
448          // Location URL is whatever is explicitly set in the MC
449
String JavaDoc locationUrl =
450                  msgContext.getStrProp(MessageContext.WSDLGEN_SERV_LOC_URL);
451
452          if (locationUrl == null)
453          {
454             // If nothing, try what's explicitly set in the ServiceDesc
455
locationUrl = serviceDesc.getEndpointURL();
456          }
457
458          if (locationUrl == null)
459          {
460             // If nothing, use the actual transport URL
461
locationUrl = msgContext.getStrProp(MessageContext.TRANS_URL);
462          }
463
464          // Interface namespace is whatever is explicitly set
465
String JavaDoc interfaceNamespace =
466                  msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
467
468          if (interfaceNamespace == null)
469          {
470             // If nothing, use the default namespace of the ServiceDesc
471
interfaceNamespace = serviceDesc.getDefaultNamespace();
472          }
473
474          if (interfaceNamespace == null)
475          {
476             // If nothing still, use the location URL determined above
477
interfaceNamespace = locationUrl;
478          }
479
480 // Do we want to do this?
481
//
482
// if (locationUrl == null) {
483
// locationUrl = url;
484
// } else {
485
// try {
486
// URL urlURL = new URL(url);
487
// URL locationURL = new URL(locationUrl);
488
// URL urlTemp = new URL(urlURL.getProtocol(),
489
// locationURL.getHost(),
490
// locationURL.getPort(),
491
// urlURL.getFile());
492
// interfaceNamespace += urlURL.getFile();
493
// locationUrl = urlTemp.toString();
494
// } catch (Exception e) {
495
// locationUrl = url;
496
// interfaceNamespace = url;
497
// }
498
// }
499

500          Emitter emitter = new Emitter();
501
502          // This seems like a good idea, but in fact isn't because the
503
// emitter will figure out a reasonable name (<classname>Service)
504
// for the WSDL service element name. We provide the 'alias'
505
// setting to explicitly set this name. See bug 13262 for more info.
506
//emitter.setServiceElementName(serviceDesc.getName());
507

508          // service alias may be provided if exact naming is required,
509
// otherwise Axis will name it according to the implementing class name
510
String JavaDoc alias = (String JavaDoc)service.getOption("alias");
511          if (alias != null) emitter.setServiceElementName(alias);
512
513          // Set style/use
514
emitter.setStyle(serviceDesc.getStyle());
515          emitter.setUse(serviceDesc.getUse());
516
517          emitter.setClsSmart(serviceDesc.getImplClass(), locationUrl);
518
519          // If a wsdl target namespace was provided, use the targetNamespace.
520
// Otherwise use the interfaceNamespace constructed above.
521
String JavaDoc targetNamespace = (String JavaDoc)service.getOption(OPTION_WSDL_TARGETNAMESPACE);
522          if (targetNamespace == null ||
523                  targetNamespace.length() == 0)
524          {
525             targetNamespace = interfaceNamespace;
526          }
527          emitter.setIntfNamespace(targetNamespace);
528
529          emitter.setLocationUrl(locationUrl);
530          emitter.setServiceDesc(serviceDesc);
531          emitter.setTypeMapping((TypeMapping)msgContext.getTypeMappingRegistry()
532                  .getTypeMapping(serviceDesc.getUse().getEncoding()));
533          emitter.setDefaultTypeMapping((TypeMapping)msgContext.getTypeMappingRegistry().
534                  getDefaultTypeMapping());
535
536          String JavaDoc wsdlPortType = (String JavaDoc)service.getOption(OPTION_WSDL_PORTTYPE);
537          String JavaDoc wsdlServiceElement = (String JavaDoc)service.getOption(OPTION_WSDL_SERVICEELEMENT);
538          String JavaDoc wsdlServicePort = (String JavaDoc)service.getOption(OPTION_WSDL_SERVICEPORT);
539
540          if (wsdlPortType != null && wsdlPortType.length() > 0)
541          {
542             emitter.setPortTypeName(wsdlPortType);
543          }
544          if (wsdlServiceElement != null && wsdlServiceElement.length() > 0)
545          {
546             emitter.setServiceElementName(wsdlServiceElement);
547          }
548          if (wsdlServicePort != null && wsdlServicePort.length() > 0)
549          {
550             emitter.setServicePortName(wsdlServicePort);
551          }
552
553          String JavaDoc wsdlInputSchema = (String JavaDoc)
554                  service.getOption(OPTION_WSDL_INPUTSCHEMA);
555          if (null != wsdlInputSchema && wsdlInputSchema.length() > 0)
556          {
557             emitter.setInputSchema(wsdlInputSchema);
558          }
559
560          Document JavaDoc doc = emitter.emit(Emitter.MODE_ALL);
561
562          msgContext.setProperty("WSDL", doc);
563       }
564       catch (NoClassDefFoundError JavaDoc e)
565       {
566          log.info(Messages.getMessage("toAxisFault00"), e);
567          throw new AxisFault(e.toString(), e);
568       }
569       catch (Exception JavaDoc e)
570       {
571          log.info(Messages.getMessage("toAxisFault00"), e);
572          throw AxisFault.makeFault(e);
573       }
574
575       if (log.isDebugEnabled())
576          log.debug("Exit: JavaProvider::generateWSDL (" + this + ")");
577    }
578
579    private String JavaDoc getAllowedMethods(Handler service)
580    {
581       String JavaDoc val = (String JavaDoc)service.getOption(OPTION_ALLOWEDMETHODS);
582       if (val == null || val.length() == 0)
583       {
584          // Try the old option for backwards-compatibility
585
val = (String JavaDoc)service.getOption("methodName");
586       }
587       return val;
588    }
589
590    ///////////////////////////////////////////////////////////////
591
///////////////////////////////////////////////////////////////
592
/////// Default methods for java classes. Override, eg, for
593
/////// ejbeans
594
///////////////////////////////////////////////////////////////
595
///////////////////////////////////////////////////////////////
596

597    /**
598     * Default java service object comes from simply instantiating the
599     * class wrapped in jc
600     */

601    protected Object JavaDoc makeNewServiceObject(MessageContext msgContext, String JavaDoc clsName)
602            throws Exception JavaDoc
603    {
604
605       Object JavaDoc serviceObject = null;
606
607       ClassLoader JavaDoc cl = msgContext.getClassLoader();
608
609       ClassCache cache = msgContext.getAxisEngine().getClassCache();
610       if (cache != null)
611       {
612          log.debug("makeNewServiceObject from cache: " + clsName);
613          JavaClass jc = cache.lookup(clsName, cl);
614          serviceObject = jc.getJavaClass().newInstance();
615       }
616       else
617       {
618          log.debug("makeNewServiceObject for name: " + clsName);
619          Class JavaDoc serviceClass = ClassUtils.forName(clsName, true, cl);
620          serviceObject = serviceClass.newInstance();
621       }
622
623       return serviceObject;
624    }
625
626    /**
627     * Return the class name of the service
628     */

629    protected String JavaDoc getServiceClassName(Handler service)
630    {
631       return (String JavaDoc)service.getOption(getServiceClassNameOptionName());
632    }
633
634    /**
635     * Return the option in the configuration that contains the service class
636     * name
637     */

638    protected String JavaDoc getServiceClassNameOptionName()
639    {
640       return OPTION_CLASSNAME;
641    }
642
643    /**
644     * Returns the Class info about the service class.
645     */

646    protected Class JavaDoc getServiceClass(String JavaDoc clsName, SOAPService service, MessageContext msgContext)
647            throws AxisFault
648    {
649
650       ClassLoader JavaDoc cl = null;
651       Class JavaDoc serviceClass = null;
652       AxisEngine engine = service.getEngine();
653
654       // If we have a message context, use that to get classloader
655
// otherwise get the current threads classloader
656
if (msgContext != null)
657       {
658          cl = msgContext.getClassLoader();
659       }
660       else
661       {
662          cl = Thread.currentThread().getContextClassLoader();
663       }
664
665       // If we have an engine, use its class cache
666
if (engine != null && engine.getClassCache() != null)
667       {
668          try
669          {
670             JavaClass jc = engine.getClassCache().lookup(clsName, cl);
671             serviceClass = jc.getJavaClass();
672          }
673          catch (ClassNotFoundException JavaDoc e)
674          {
675             log.error(Messages.getMessage("exception00"), e);
676             throw new AxisFault(Messages.getMessage("noClassForService00", clsName), e);
677          }
678       }
679
680       // use Class.forName instead.
681
if (serviceClass == null)
682       {
683          try
684          {
685             serviceClass = ClassUtils.forName(clsName, true, cl);
686          }
687          catch (ClassNotFoundException JavaDoc e)
688          {
689             log.error(Messages.getMessage("exception00"), e);
690             throw new AxisFault(Messages.getMessage("noClassForService00", clsName), e);
691          }
692       }
693
694       return serviceClass;
695    }
696
697    /**
698     * Fill in a service description with the correct impl class
699     * and typemapping set. This uses methods that can be overridden by
700     * other providers (like the EJBProvider) to get the class from the
701     * right place.
702     */

703    public void initServiceDesc(SOAPService service, MessageContext msgContext)
704            throws AxisFault
705    {
706       // Set up the Implementation class for the service
707

708       String JavaDoc clsName = getServiceClassName(service);
709       if (clsName == null)
710       {
711          throw new AxisFault(Messages.getMessage("noServiceClass"));
712       }
713       Class JavaDoc cls = getServiceClass(clsName, service, msgContext);
714       ServiceDesc serviceDescription = service.getServiceDescription();
715
716       // And the allowed methods, if necessary
717
if (serviceDescription.getAllowedMethods() == null && service != null)
718       {
719          String JavaDoc allowedMethods = getAllowedMethods(service);
720          if (allowedMethods != null && !"*".equals(allowedMethods))
721          {
722             ArrayList JavaDoc methodList = new ArrayList JavaDoc();
723             StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(allowedMethods, " ,");
724             while (tokenizer.hasMoreTokens())
725             {
726                methodList.add(tokenizer.nextToken());
727             }
728             serviceDescription.setAllowedMethods(methodList);
729          }
730       }
731
732       serviceDescription.loadServiceDescByIntrospection(cls);
733    }
734
735 }
736
Popular Tags