axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From R J Scheuerle Jr <sc...@us.ibm.com>
Subject Re: cvs commit: xml-axis/java/src/org/apache/axis/utils axisNLS.properties
Date Fri, 23 Aug 2002 16:24:09 GMT

Glen,

1) The namespace.pop() change is breaking the functional tests.  I am
investigating.

2) Could you explain in more detail the changes in RPCHandler.
   a) do we need a check to make sure that the paramDesc has a non-null
javaType. Is this an assertion check that should be added to OperationDesc
or ServiceDesc ?
   b) Was the code to check isConvertable at this point wrong or just
redundant.  Don't we want to know conversion problems at this point so that
we don't have to investigate the remaining parameters ( I am thinking of
the overloaded operations).  Or perhaps we want to only do the
isConveratable check if we are doing overloading.

Thanks,

Rich Scheuerle
IBM WebSphere & Axis Web Services Development
512-838-5115  (IBM TL 678-5115)


                                                                                         
                                 
                      gdaniels@apache.                                                   
                                 
                      org                      To:       xml-axis-cvs@apache.org         
                                 
                                               cc:                                       
                                 
                      08/23/2002 10:08         Subject:  cvs commit: xml-axis/java/src/org/apache/axis/utils
axisNLS.      
                      AM                        properties                               
                                 
                      Please respond to                                                  
                                 
                      axis-dev                                                           
                                 
                                                                                         
                                 
                                                                                         
                                 



gdaniels    2002/08/23 08:08:56

  Modified:    java/test/wsdd testStructure1.wsdd
               java/test/encoding TestBody.java
               java/src/org/apache/axis/handlers/soap SOAPService.java
               java/src/org/apache/axis/description ServiceDesc.java
               java/src/org/apache/axis/providers/java RPCProvider.java
                        JavaProvider.java
               java/src/org/apache/axis/message RPCHandler.java
               java/src/org/apache/axis/handlers JWSHandler.java
               java/src/org/apache/axis/encoding
                        DeserializationContextImpl.java
                        DeserializationContext.java
               java/src/org/apache/axis/utils axisNLS.properties
  Removed:     java/src/org/apache/axis/providers JWSProvider.java
               java/src/org/apache/axis/handlers JWSProcessor.java
  Log:
  * Streamline the JWS process.

    Formerly, JWS worked by having one shared "JWSProcessor" service (i.e.
    a SOAPService with a JWSProcessor as the provider), which when invoked
    would create a "real" service using an RPCProvider and pointing to the
    target class.  The JWSProcessor would also do all the compilation of
    the class, so we didn't have the class (or an intialized ServiceDesc)
    available until the handler chain had gotten all the way to the end.

    Now there's no unnecessary middle step - the JWSHandler notices the
    file extension when it runs, and it does all the compilation/class
    loading work.  Rather than a shared "JWSProcessor" service, the
    JWSHandler now simply directly sets the service to the "real"
    RPC one which accesses the JWS class.

  * Improve deserialization of RPC parameters

    Formerly, we were always deserializing RPC parameters based only on
    their XML type.  In other words, we were always getting the first
    Deserializer that could handle the xsi:type which came over the
    wire.  We then relied on being able to convert() the resultant
    Java object into the desired Java type.  This wasn't working very
    well when we had multiple Java mappings and no defined conversion,
    as in the xsd:dateTime -> Date/Calendar case.  (actually, we should
    fix isConvertable() to return TRUE for Date/Calendar, but that
    doesn't change the basic problem here).

    Now we use the getDeserializer(Class c, QName xmlType) method of
    the DeserializationContextImpl/DeserializationContext (grr - I
    still really think that interface is unnecessary!) to make sure
    we prefer the RIGHT Deserializer, which can deserialize the XML
    type directly to the desired Java type.  We still fall back to
    deserializing and convert()ing if there's no exact match.

  * Add namespaces.pop() call to end of DeserializationContextImpl's
    endElement() (thanks to Marco Framba for noticing this one!)

  * Bits of general cleanup

  Revision  Changes    Path
  1.2       +4 -2      xml-axis/java/test/wsdd/testStructure1.wsdd

  Index: testStructure1.wsdd
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdd/testStructure1.wsdd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- testStructure1.wsdd            14 Nov 2001 21:22:54 -0000
1.1
  +++ testStructure1.wsdd            23 Aug 2002 15:08:55 -0000
1.2
  @@ -11,14 +11,16 @@
     <handler type="java:org.apache.axis.handlers.JWSHandler"/>
    </chain>

  - <service name="service.one" provider="java:MSG">
  + <service name="service.one" provider="java:RPC">
  +  <parameter name="className" value="test.wsdd.TestStructure"/>
     <responseFlow>
       <handler type="java:org.apache.axis.providers.java.RPCProvider"
                name="BackReference"/>
     </responseFlow>
    </service>

  - <service name="service.two" provider="java:MSG">
  + <service name="service.two" provider="java:RPC">
  +  <parameter name="className" value="test.wsdd.TestStructure"/>
     <requestFlow>
       <handler type="BackReference"/>
     </requestFlow>



  1.13      +2 -0      xml-axis/java/test/encoding/TestBody.java

  Index: TestBody.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestBody.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TestBody.java            11 Jun 2002 14:54:02 -0000          1.12
  +++ TestBody.java            23 Aug 2002 15:08:55 -0000          1.13
  @@ -6,6 +6,7 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.providers.java.RPCProvider;
  +import org.apache.axis.providers.java.JavaProvider;
   import org.apache.axis.configuration.SimpleProvider;
   import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.message.RPCElement;
  @@ -33,6 +34,7 @@

           // register the service with the engine
           SOAPService target = new SOAPService(new RPCProvider());
  +        target.setOption(JavaProvider.OPTION_CLASSNAME, "test.encoding.
TestBody");
           provider.deployService(new QName(null,namespace), target);

           // setup



  1.77      +0 -1      xml-
axis/java/src/org/apache/axis/handlers/soap/SOAPService.java

  Index: SOAPService.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- SOAPService.java         6 Aug 2002 03:55:04 -0000           1.76
  +++ SOAPService.java         23 Aug 2002 15:08:55 -0000          1.77
  @@ -288,7 +288,6 @@

       /**
        * Returns a service description with the implementation class
filled in.
  -     *
        * Syncronized to prevent simutaneous modification of
serviceDescription.
        */
       public synchronized ServiceDesc getInitializedServiceDesc(



  1.49      +31 -14    xml-
axis/java/src/org/apache/axis/description/ServiceDesc.java

  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- ServiceDesc.java         21 Aug 2002 03:36:33 -0000          1.48
  +++ ServiceDesc.java         23 Aug 2002 15:08:55 -0000          1.49
  @@ -228,6 +228,10 @@

       /**
        * set the implementation class
  +     * <p>
  +     * Warning: You cannot call getInitializedServiceDesc() after
setting this
  +     * as it uses this to indicate its work has already been done.
  +     *
        * @param implClass
        * @throws IllegalArgumentException if the implementation class is
already
        *         set
  @@ -479,7 +483,7 @@
           // Developer Note:
           //
           // The goal of the sync code is to associate
  -        // the OperationDesc/ParamterDesc with the
  +        // the OperationDesc/ParamterDesc with the
           // target Method.  There are a number of ways to get to this
           // point depending on what information
           // is available.  Here are the main scenarios:
  @@ -488,17 +492,17 @@
           //   * OperationDesc/ParameterDesc loaded from deploy.wsdd
           //   * Loaded ParameterDesc does not have javaType,
           //     so it is discovered using the TypeMappingRegistry
  -        //     (also loaded via deploy.wsdd) and the
  +        //     (also loaded via deploy.wsdd) and the
           //     typeQName specified by the ParameterDesc.
           //   * Sync occurs using the discovered
           //     javaTypes and the javaTypes of the Method
           //     parameters
           //
           // B) Deployment with no wsdd OperationDesc info (non-skeleton):
  -        //   * Implementation Class introspected to build
  +        //   * Implementation Class introspected to build
           //     OperationDesc/ParameterDesc.
           //   * ParameterDesc is known via introspection.
  -        //   * ParameterDesc are discovered using javaType
  +        //   * ParameterDesc are discovered using javaType
           //     and TypeMappingRegistry.
           //   * Sync occurs using the introspected
           //     javaTypes and the javaTypes of the Method
  @@ -509,13 +513,13 @@
           //   * In this scenario the ParameterDescs' already
           //     have javaTypes (see E below).
           //   * Sync occurs using the ParameterDesc
  -        //     javaTypes and the javaTypes of the Method
  +        //     javaTypes and the javaTypes of the Method
           //     parameters.
           //
           // D) Commandline Java2WSDL loading non-Skeleton Class/Interface
  -        //   * Class/Interface introspected to build
  +        //   * Class/Interface introspected to build
           //     OperationDesc/ParameterDesc.
  -        //   * The javaTypes of the ParameterDesc are set using
introspection.
  +        //   * The javaTypes of the ParameterDesc are set using
introspection.
           //   * typeQNames are determined for built-in types using
           //     from the default TypeMappingRegistry.  Other
           //     typeQNames are guessed from the javaType.  Note
  @@ -524,7 +528,7 @@
           //     javaTypes and the javaTypes of the Method
           //     parameters.
           //
  -        // E) Commandline Java2WSDL loading Skeleton Class
  +        // E) Commandline Java2WSDL loading Skeleton Class
           //   * OperationDesc/ParameterDesc loaded from Skeleton
           //   * Each ParameterDesc has an appropriate typeQName
           //   * Each ParameterDesc also has a javaType, which is
  @@ -537,9 +541,9 @@
           // So in each scenario, the ultimate sync'ing occurs
           // using the javaTypes of the ParameterDescs and the
           // javaTypes of the Method parameters.
  -        //
  +        //
           // ------------------------------------------------
  -
  +
           // If we're already mapped to a Java method, no need to do
anything.
           if (oper.getMethod() != null)
               return;
  @@ -630,10 +634,10 @@
               syncOperationToClass(oper, superClass);
           }

  -        // Exception if sync fails to find method for operation
  +        // Exception if sync fails to find method for operation
           if (oper.getMethod() == null) {
  -            InternalException ie =
  -                new InternalException(JavaUtils.
getMessage("serviceDescOperSync00",
  +            InternalException ie =
  +                new InternalException(JavaUtils.
getMessage("serviceDescOperSync00",
                                                              oper.
getName(),
                                                              implClass.
getName()));
               throw ie;
  @@ -656,12 +660,19 @@
       /**
        * Fill in a service description by introspecting the implementation
        * class.
  -     */
  +     */
       public void loadServiceDescByIntrospection(Class implClass) {
           if (introspectionComplete || implClass == null) {
               return;
           }

  +        // set the implementation class for the service description
  +        this.implClass = implClass;
  +        if (Skeleton.class.isAssignableFrom(implClass)) {
  +            isSkeletonClass = true;
  +            loadSkeletonOperations();
  +        }
  +
           /** If the class knows what it should be exporting,
           * respect its wishes.
           */
  @@ -741,6 +752,12 @@
           // Should we complain if the implClass changes???
           implClass = cls;
           this.tm = tm;
  +
  +        if (Skeleton.class.isAssignableFrom(implClass)) {
  +            isSkeletonClass = true;
  +            loadSkeletonOperations();
  +        }
  +
           loadServiceDescByIntrospection();
       }




  1.91      +11 -13    xml-
axis/java/src/org/apache/axis/providers/java/RPCProvider.java

  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- RPCProvider.java         22 Aug 2002 22:06:17 -0000          1.90
  +++ RPCProvider.java         23 Aug 2002 15:08:55 -0000          1.91
  @@ -58,8 +58,6 @@
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
   import org.apache.axis.MessageContext;
  -import org.apache.axis.attachments.MimeMultipartDataSource;
  -import org.apache.axis.attachments.PlainTextDataSource;
   import org.apache.axis.enum.Style;
   import org.apache.axis.description.OperationDesc;
   import org.apache.axis.description.ServiceDesc;
  @@ -101,7 +99,7 @@
           LogFactory.getLog(RPCProvider.class.getName());

      /**
  -     * Process the current message.
  +     * Process the current message.
        * Result in resEnv.
        *
        * @param msgContext self-explanatory
  @@ -122,7 +120,7 @@
           SOAPService service = msgContext.getService();
           ServiceDesc serviceDesc = service.getServiceDescription();
           OperationDesc operation = msgContext.getOperation();
  -
  +
           Vector          bodies = reqEnv.getBodyElements();
           if (log.isDebugEnabled()) {
               log.debug(JavaUtils.getMessage("bodyElems00", "" + bodies.
size()));
  @@ -161,12 +159,12 @@
          // special case code for a document style operation with no
          // arguments (which is a strange thing to have, but whatever)
           if (body == null) {
  -            // throw an error if this isn't a document style service

  +            // throw an error if this isn't a document style service
               if (!serviceDesc.getStyle().equals(Style.DOCUMENT)) {
                   throw new Exception(JavaUtils.getMessage("noBody00"));
               }
  -
  -            // look for a method in the service that has no arguments,
  +
  +            // look for a method in the service that has no arguments,
               // use the first one we find.
               ArrayList ops = serviceDesc.getOperations();
               for (Iterator iterator = ops.iterator(); iterator.
hasNext();) {
  @@ -224,7 +222,7 @@

               // first check the type on the paramter
               ParameterDesc paramDesc = rpcParam.getParamDesc();
  -
  +
               // if we found some type info try to make sure the value
type is
               // correct.  For instance, if we deserialized a xsd:dateTime
in
               // to a Calendar and the service takes a Date, we need to
convert
  @@ -242,7 +240,7 @@
                       outs.add(rpcParam);
                   }
               }
  -
  +
               // Put the value (possibly converted) in the argument array
               // make sure to use the parameter order if we have it
               if (paramDesc == null || paramDesc.getOrder() == -1) {
  @@ -284,11 +282,11 @@
                   }
               }
           }
  -
  +
           // OK!  Now we can invoke the method
           Object objRes = null;
           try {
  -            objRes = invokeMethod(msgContext,
  +            objRes = invokeMethod(msgContext,
                                    operation.getMethod(),
                                    obj, argValues);
           } catch (IllegalArgumentException e) {
  @@ -304,7 +302,7 @@
                       argClasses += ",";
                   }
               }
  -            log.info(JavaUtils.getMessage("dispatchIAE00",
  +            log.info(JavaUtils.getMessage("dispatchIAE00",
                                             new String[] {methodSig,
argClasses}),
                        e);
               throw new AxisFault(JavaUtils.getMessage("dispatchIAE00",
  @@ -453,7 +451,7 @@
       } // getDataFromDataHandler

       /**
  -     * This method encapsulates the method invocation.
  +     * This method encapsulates the method invocation.
        * @param msgContext MessageContext
        * @param method the target method.
        * @param obj the target object



  1.73      +5 -6      xml-
axis/java/src/org/apache/axis/providers/java/JavaProvider.java

  Index: JavaProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- JavaProvider.java        6 Aug 2002 03:55:05 -0000           1.72
  +++ JavaProvider.java        23 Aug 2002 15:08:55 -0000          1.73
  @@ -492,13 +492,12 @@
           // Set up the Implementation class for the service

           String clsName = getServiceClassName(service);
  +        if (clsName == null) {
  +            throw new AxisFault(JavaUtils.getMessage("noServiceClass"));
  +        }
  +        Class cls = getServiceClass(clsName, service, msgContext);
           ServiceDesc serviceDescription = service.
getServiceDescription();

  -        if (clsName != null) {
  -            Class cls = getServiceClass(clsName, service, msgContext);
  -            serviceDescription.setImplClass(cls);
  -        }
  -
           // And the allowed methods, if necessary
           if (serviceDescription.getAllowedMethods() == null && service !=
null) {
               String allowedMethods = getAllowedMethods(service);
  @@ -512,7 +511,7 @@
               }
           }

  -        serviceDescription.loadServiceDescByIntrospection();
  +        serviceDescription.loadServiceDescByIntrospection(cls);
       }

   }



  1.58      +32 -21    xml-
axis/java/src/org/apache/axis/message/RPCHandler.java

  Index: RPCHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCHandler.
java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- RPCHandler.java          19 Aug 2002 12:12:08 -0000          1.57
  +++ RPCHandler.java          23 Aug 2002 15:08:55 -0000          1.58
  @@ -199,17 +199,21 @@
           if (log.isDebugEnabled()) {
               log.debug(JavaUtils.getMessage("typeFromAttr00", "" +
type));
           }
  +
  +
  +        Class destClass = null;

           // If we have an operation descriptor, try to associate this
parameter
           // with the appropriate ParameterDesc
           if (operation != null) {
  +
               // Try by name first
               if (isResponse) {
                   paramDesc = operation.getOutputParamByQName(qname);
               } else {
                   paramDesc = operation.getInputParamByQName(qname);
               }
  -
  +
               // If that didn't work, try position
               // FIXME : Do we need to be in EITHER named OR positional
               //         mode?  I.e. will it screw us up to find something
  @@ -218,28 +222,22 @@
               if (paramDesc == null) {
                   paramDesc = operation.getParameter(params.size() - 1);
               }
  -
  -            if (paramDesc != null) {
  -                // Keep the association so we can use it later
  -                // (see RPCProvider.processMessage())
  -                currentParam.setParamDesc(paramDesc);
  -
  -                if (type == null) {
  -                    type = paramDesc.getTypeQName();
  -                } else if (paramDesc.getJavaType() != null) {
  -                    // If we have an xsi:type, make sure it makes sense
  -                    // with the current paramDesc type
  -                    Class xsiClass =
  -                            context.getTypeMapping().
getClassForQName(type);
  -                    Class destClass = paramDesc.getJavaType();
  -                    if (!JavaUtils.isConvertable(xsiClass, destClass)) {
  -                        throw new SAXException("Bad types (" +
  -                            xsiClass + " -> " + destClass + ")"); //
FIXME!
  -                    }
  -                }
  +
  +
  +            if (paramDesc == null) {
  +                throw new SAXException("operation description is missing
parameter description!");
  +            }
  +            destClass = paramDesc.getJavaType();
  +
  +            // Keep the association so we can use it later
  +            // (see RPCProvider.processMessage())
  +            currentParam.setParamDesc(paramDesc);
  +
  +            if (type == null) {
  +                type = paramDesc.getTypeQName();
               }
           }
  -
  +
           // If the nil attribute is set, just
           // return the base DeserializerImpl.
           // Register the value target to set the value
  @@ -263,10 +261,23 @@
           Deserializer dser = null;
           if ((type == null) && (namespace != null) && (!namespace.
equals(""))) {
               dser = context.getDeserializerForType(qname);
  +        } else {
  +            dser = context.getDeserializer(destClass, type);
           }
  +
           if (dser == null) {
             if (type != null) {
                 dser = context.getDeserializerForType(type);
  +              if (paramDesc != null && paramDesc.getJavaType() != null)
{
  +                  // If we have an xsi:type, make sure it makes sense
  +                  // with the current paramDesc type
  +                  Class xsiClass =
  +                          context.getTypeMapping().
getClassForQName(type);
  +                  if (!JavaUtils.isConvertable(xsiClass, destClass)) {
  +                      throw new SAXException("Bad types (" +
  +                                             xsiClass + " -> " +
destClass + ")"); // FIXME!
  +                  }
  +              }
             } else {
                 dser = new DeserializerImpl();
             }



  1.23      +370 -22   xml-
axis/java/src/org/apache/axis/handlers/JWSHandler.java

  Index: JWSHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/handlers/JWSHandler.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JWSHandler.java          10 Jul 2002 19:32:13 -0000          1.22
  +++ JWSHandler.java          23 Aug 2002 15:08:56 -0000          1.23
  @@ -57,12 +57,41 @@
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
   import org.apache.axis.MessageContext;
  +import org.apache.axis.AxisProperties;
  +import org.apache.axis.transport.http.HTTPConstants;
  +import org.apache.axis.encoding.TypeMappingRegistry;
  +import org.apache.axis.description.ServiceDesc;
  +import org.apache.axis.enum.Scope;
  +import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.XMLUtils;
  +import org.apache.axis.utils.ClassUtils;
  +import org.apache.axis.utils.JWSClassLoader;
  +import org.apache.axis.providers.java.RPCProvider;
   import org.apache.axis.handlers.soap.SOAPService;

   import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.components.compiler.Compiler;
  +import org.apache.axis.components.compiler.CompilerFactory;
  +import org.apache.axis.components.compiler.CompilerError;
   import org.apache.commons.logging.Log;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;

  -import java.util.Hashtable;
  +import java.util.HashMap;
  +import java.util.List;
  +import java.util.StringTokenizer;
  +import java.util.jar.JarFile;
  +import java.util.jar.Manifest;
  +import java.util.jar.Attributes;
  +import java.util.jar.JarInputStream;
  +import java.io.File;
  +import java.io.FileReader;
  +import java.io.FileWriter;
  +import java.io.FileInputStream;
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.net.URLClassLoader;
  +import java.net.URL;

   /** A <code>JWSHandler</code> sets the target service and JWS filename
    * in the context depending on the JWS configuration and the target URL.
  @@ -79,48 +108,367 @@
       public final String OPTION_JWS_FILE_EXTENSION = "extension";
       public final String DEFAULT_JWS_FILE_EXTENSION = ".jws";

  -    // Keep the processor Handler around so we can make it the service
  -    // Handler for this request if appropriate.  No need for these to be
  -    // static, since it may be desirable to have JWS handlers with
different
  -    // behaviours for different file extensions.
  -    JWSProcessor jws = new JWSProcessor();
  -    SOAPService processor = new SOAPService(jws);
  -
  -    boolean firstTime = true;
  +    protected static HashMap soapServices = new HashMap();

  +    /**
  +     * Just set up the service, the inner service will do the rest...
  +     */
       public void invoke(MessageContext msgContext) throws AxisFault
       {
           if (log.isDebugEnabled()) {
               log.debug("Enter: JWSHandler::invoke");
           }

  -        if (firstTime) {
  -            processor.setEngine(msgContext.getAxisEngine());
  +        try {
  +            setupService(msgContext);
  +        } catch (Exception e) {
  +            log.error( JavaUtils.getMessage("exception00"), e );
  +            throw AxisFault.makeFault(e);
           }
  -
  +    }
  +
  +    /**
  +     * If our path ends in the right file extension (*.jws), handle all
the
  +     * work necessary to compile the source file if it needs it, and set
  +     * up the "proxy" RPC service surrounding it as the MessageContext's
  +     * active service.
  +     *
  +     */
  +    protected void setupService(MessageContext msgContext) throws
Exception {
           // FORCE the targetService to be JWS if the URL is right.
           String realpath = msgContext.getStrProp(Constants.MC_REALPATH);
           String extension = (String)getOption(OPTION_JWS_FILE_EXTENSION);
           if (extension == null) extension = DEFAULT_JWS_FILE_EXTENSION;
  -
  +
           if ((realpath!=null) && (realpath.endsWith(extension))) {
  -            msgContext.setService(processor);
  +            /* Grab the *.jws filename from the context - should have
been */
  +            /* placed there by another handler (ie. HTTPActionHandler)
*/
  +
/***************************************************************/
  +            String   jwsFile = realpath;
  +            String rel = msgContext.getStrProp(Constants.
MC_RELATIVE_PATH);
  +            if (rel.charAt(0) == '/') {
  +                rel = rel.substring(1);
  +            }
  +
  +            int lastSlash = rel.lastIndexOf('/');
  +            String dir = null;
  +
  +            if (lastSlash > 0) {
  +                dir = rel.substring(0, lastSlash);
  +            }
  +
  +            String file = rel.substring(lastSlash + 1);
  +
  +            String outdir = msgContext.getStrProp( Constants.
MC_JWS_CLASSDIR );
  +            if ( outdir == null ) outdir = "." ;
  +
  +            // Build matching directory structure under the output
  +            // directory.  In other words, if we have:
  +            //    /webroot/jws1/Foo.jws
  +            //
  +            // That will be compiled to:
  +            //    .../jwsOutputDirectory/jws1/Foo.class
  +            if (dir != null) {
  +                outdir = outdir + File.separator + dir;
  +            }
  +
  +            // Confirm output directory exists.  If not, create it IF
we're
  +            // allowed to.
  +            // !!! TODO: add a switch to control this.
  +            File outDirectory = new File(outdir);
  +            if (!outDirectory.exists()) {
  +                outDirectory.mkdirs();
  +            }
  +
  +            if (log.isDebugEnabled())
  +                log.debug("jwsFile: " + jwsFile );
  +
  +            String   jFile   = outdir + File.separator + file.
substring(0, file.length()-3) +
  +                    "java" ;
  +            String   cFile   = outdir + File.separator + file.
substring(0, file.length()-3) +
  +                    "class" ;
  +
  +            if (log.isDebugEnabled()) {
  +                log.debug("jFile: " + jFile );
  +                log.debug("cFile: " + cFile );
  +                log.debug("outdir: " + outdir);
  +            }
  +
  +            File  f1 = new File( cFile );
  +            File  f2 = new File( jwsFile );
  +
  +            /* Get the class */
  +            /*****************/
  +            String clsName = null ;
  +            //clsName = msgContext.getStrProp(Constants.
MC_RELATIVE_PATH);
  +            if ( clsName == null ) clsName = f2.getName();
  +            if ( clsName != null && clsName.charAt(0) == '/' )
  +                clsName = clsName.substring(1);
  +
  +            clsName = clsName.substring( 0, clsName.length()-4 );
  +            clsName = clsName.replace('/', '.');
  +
  +            if (log.isDebugEnabled())
  +                log.debug("ClsName: " + clsName );
  +
  +            /* Check to see if we need to recompile */
  +            /****************************************/
  +            if ( !f1.exists() || f2.lastModified() > f1.lastModified() )
{
  +                /* If the class file doesn't exist, or it's older than
the */
  +                /* java file then recompile the java file.
*/
  +                /* Start by copying the *.jws file to *.java
*/
  +
/***********************************************************/
  +                log.debug(JavaUtils.getMessage("compiling00", jwsFile)
);
  +                log.debug(JavaUtils.getMessage("copy00", jwsFile, jFile)
);
  +                FileReader fr = new FileReader( jwsFile );
  +                FileWriter fw = new FileWriter( jFile );
  +                char[] buf = new char[4096];
  +                int    rc ;
  +                while ( (rc = fr.read( buf, 0, 4095)) >= 0 )
  +                    fw.write( buf, 0, rc );
  +                fw.close();
  +                fr.close();
  +
  +                /* Now run javac on the *.java file */
  +                /************************************/
  +                log.debug("javac " + jFile );
  +                // Process proc = rt.exec( "javac " + jFile );
  +                // proc.waitFor();
  +                Compiler          compiler = CompilerFactory.
getCompiler();
  +
  +                compiler.setClasspath(getDefaultClasspath(msgContext));
  +                compiler.setDestination(outdir);
  +                compiler.addFile(jFile);
  +
  +                boolean result   = compiler.compile();
  +
  +                /* Delete the temporary *.java file and check return
code */
  +
/**********************************************************/
  +                (new File(jFile)).delete();
  +
  +                if ( !result ) {
  +                    /* Delete the *class file - sometimes it gets
created even */
  +                    /* when there are errors - so erase it so it doesn't
*/
  +                    /* confuse us.
*/
  +
/***********************************************************/
  +                    (new File(cFile)).delete();
  +
  +                    Document doc = XMLUtils.newDocument();
  +
  +                    Element         root = doc.createElementNS("",
"Errors");
  +                    StringBuffer message = new StringBuffer("Error
compiling ");
  +                    message.append(jFile);
  +                    message.append(":\n");
  +
  +                    List errors = compiler.getErrors();
  +                    int count = errors.size();
  +                    for (int i = 0; i < count; i++) {
  +                        CompilerError error = (CompilerError) errors.
get(i);
  +                        if (i > 0) message.append("\n");
  +                        message.append("Line ");
  +                        message.append(error.getStartLine());
  +                        message.append(", column ");
  +                        message.append(error.getStartColumn());
  +                        message.append(": ");
  +                        message.append(error.getMessage());
  +                    }
  +                    root.appendChild( doc.createTextNode( message.
toString() ) );
  +                    throw new AxisFault( "Server.compileError",
  +                                         JavaUtils.
getMessage("badCompile00", jFile),
  +                                         null, new Element[] { root } );
  +                }
  +                ClassUtils.removeClassLoader( clsName );
  +                // And clean out the cached service.
  +                soapServices.remove(clsName);
  +            }
  +
  +            ClassLoader cl = ClassUtils.getClassLoader(clsName);
  +            if (cl == null) {
  +                cl = new JWSClassLoader(clsName,
  +                                        msgContext.getClassLoader(),
  +                                        cFile);
  +            }
  +
  +            msgContext.setClassLoader(cl);
  +
  +            /* Create a new RPCProvider - this will be the "service"
*/
  +            /* that we invoke.
*/
  +
/******************************************************************/
  +            // Cache the rpc service created to handle the class.  The
cache
  +            // is based on class name, so only one .jws/.jwr class can
be active
  +            // in the system at a time.
  +            SOAPService rpc = (SOAPService)soapServices.get(clsName);
  +            if (rpc == null) {
  +                rpc = new SOAPService(new RPCProvider());
  +                rpc.setOption(RPCProvider.OPTION_CLASSNAME, clsName );
  +                rpc.setEngine(msgContext.getAxisEngine());
  +
  +                // Support specification of "allowedMethods" as a
parameter.
  +                String allowed = (String)getOption(RPCProvider.
OPTION_ALLOWEDMETHODS);
  +                if (allowed == null) allowed = "*";
  +                rpc.setOption(RPCProvider.OPTION_ALLOWEDMETHODS,
allowed);
  +                // Take the setting for the scope option from the
handler
  +                // parameter named "scope"
  +                String scope = (String)getOption(RPCProvider.
OPTION_SCOPE);
  +                if (scope == null) scope = Scope.DEFAULT.getName();
  +                rpc.setOption(RPCProvider.OPTION_SCOPE, scope);
  +
  +                // Set up service description
  +                ServiceDesc sd = rpc.getServiceDescription();
  +
  +                TypeMappingRegistry tmr = msgContext.getAxisEngine().
getTypeMappingRegistry();
  +                sd.setTypeMappingRegistry(tmr);
  +                sd.setTypeMapping(msgContext.getTypeMapping());
  +
  +                rpc.getInitializedServiceDesc(msgContext);
  +
  +                soapServices.put(clsName, rpc);
  +
  +            }
  +
  +            // Set engine, which hooks up type mappings.
  +            rpc.setEngine(msgContext.getAxisEngine());
  +
  +            rpc.init();   // ??
  +
  +            // OK, this is now the destination service!
  +            msgContext.setService( rpc );
           }

           if (log.isDebugEnabled()) {
               log.debug("Exit: JWSHandler::invoke");
           }
       }
  +
  +    private String getDefaultClasspath(MessageContext msgContext)
  +    {
  +        StringBuffer classpath = new StringBuffer();
  +        ClassLoader cl = Thread.currentThread().getContextClassLoader();

  -    public void generateWSDL(MessageContext msgContext) throws AxisFault
{
  -        invoke(msgContext);
  +        while(cl != null)
  +        {
  +            if(cl instanceof URLClassLoader)
  +            {
  +                URL[] urls = ((URLClassLoader) cl).getURLs();
  +
  +                for(int i=0; (urls != null) && i < urls.length; i++)
  +                {
  +                    String path = urls[i].getPath();
  +                    //If it is a drive letter, adjust accordingly.
  +                    if(path.charAt(0)=='/'&&path.charAt(2)==':')
  +                        path = path.substring(1);
  +                    classpath.append(path);
  +                    classpath.append(File.pathSeparatorChar);
  +
  +                    // if its a jar extract Class-Path entries from
manifest
  +                    File file = new File(urls[i].getFile());
  +                    if(file.isFile())
  +                    {
  +                        FileInputStream fis = null;
  +
  +                        try
  +                        {
  +                            fis = new FileInputStream(file);
  +
  +                            if(isJar(fis))
  +                            {
  +                                JarFile jar = new JarFile(file);
  +                                Manifest manifest = jar.getManifest();
  +                                if (manifest != null)
  +                                {
  +                                    Attributes attributes = manifest.
  +                                            getMainAttributes();
  +                                    if (attributes != null)
  +                                    {
  +                                        String s = attributes.
  +                           getValue(java.util.jar.Attributes.Name.
CLASS_PATH);
  +                                        String base = file.getParent();
  +
  +                                        if (s != null)
  +                                        {
  +                                            StringTokenizer st =
  +                                                  new StringTokenizer(s,
" ");
  +                                            while(st.hasMoreTokens())
  +                                            {
  +                                                String t = st.
nextToken();
  +                                                classpath.append(base +
  +                                                      File.separatorChar
+ t);
  +                                                classpath.append(
  +                                                      File.
pathSeparatorChar);
  +                                            }
  +                                        }
  +                                    }
  +                                }
  +                            }
  +                        }
  +                        catch(IOException ioe)
  +                        {
  +                            if(fis != null)
  +                                try {
  +                                    fis.close();
  +                                } catch (IOException ioe2) {}
  +                        }
  +                    }
  +                }
  +            }
  +
  +            cl = cl.getParent();
  +        }
  +
  +        // Just to be safe (the above doesn't seem to return the webapp
  +        // classpath in all cases), manually do this:
  +
  +        String webBase = (String)msgContext.getProperty(
  +                                         HTTPConstants.
MC_HTTP_SERVLETLOCATION);
  +        if (webBase != null) {
  +            classpath.append(webBase + File.separatorChar + "classes" +
  +                             File.pathSeparatorChar);
  +            try {
  +                String libBase = webBase + File.separatorChar + "lib";
  +                File libDir = new File(libBase);
  +                String [] jarFiles = libDir.list();
  +                for (int i = 0; i < jarFiles.length; i++) {
  +                    String jarFile = jarFiles[i];
  +                    if (jarFile.endsWith(".jar")) {
  +                        classpath.append(libBase +
  +                                         File.separatorChar +
  +                                         jarFile +
  +                                         File.pathSeparatorChar);
  +                    }
  +                }
  +            } catch (Exception e) {
  +                // Oh well.  No big deal.
  +            }
  +        }
  +
  +        // boot classpath isn't found in above search
  +        String bootClassPath = AxisProperties.getProperty("sun.boot.
class.path");
  +        if( bootClassPath != null) {
  +            classpath.append(bootClassPath);
  +        }
  +
  +        return classpath.toString();
       }
  +
  +    // an exception or emptiness signifies not a jar
  +    public static boolean isJar(InputStream is) {
  +        try {
  +            JarInputStream jis = new JarInputStream(is);
  +            if (jis.getNextEntry() != null) {
  +                return true;
  +            }
  +        } catch (IOException ioe) {
  +        }

  -    /**
  -     * Propagate options set on this handler into the processor.
  -     */
  -    public void setOptions(Hashtable opts) {
  -        super.setOptions(opts);
  -        jws.setOptions(opts);
  +        return false;
  +    }
  +
  +    public void generateWSDL(MessageContext msgContext) throws AxisFault
{
  +        try {
  +            setupService(msgContext);
  +        } catch (Exception e) {
  +            log.error( JavaUtils.getMessage("exception00"), e );
  +            throw AxisFault.makeFault(e);
  +        }
       }
   }



  1.50      +22 -11    xml-
axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java

  Index: DeserializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DeserializationContextImpl.java            19 Aug 2002 19:13:53 -0000
       1.49
  +++ DeserializationContextImpl.java            23 Aug 2002 15:08:56 -0000
       1.50
  @@ -409,19 +409,18 @@
       }

       /**
  -     * Convenience method to get the Deserializer for a specific
  -     * xmlType.
  -     * @param xmlType is QName for a type to deserialize
  -     * @return Deserializer
  -     */
  -    public final Deserializer getDeserializerForType(QName xmlType) {
  +     * Get a Deserializer which can turn a given xml type into a given
  +     * Java type
  +     */
  +    public final Deserializer getDeserializer(Class cls, QName xmlType)
{
           if (xmlType == null)
               return null;
  -
  +
           DeserializerFactory dserF = null;
           Deserializer dser = null;
  -        try {
  -            dserF = (DeserializerFactory) getTypeMapping().
getDeserializer(xmlType);
  +        try {
  +            dserF = (DeserializerFactory) getTypeMapping().
  +                    getDeserializer(cls, xmlType);
           } catch (JAXRPCException e) {
               log.error(JavaUtils.getMessage("noFactory00", xmlType.
toString()));
           }
  @@ -432,7 +431,17 @@
                   log.error(JavaUtils.getMessage("noDeser00", xmlType.
toString()));
               }
           }
  -        return dser;
  +        return dser;
  +    }
  +
  +    /**
  +     * Convenience method to get the Deserializer for a specific
  +     * xmlType.
  +     * @param xmlType is QName for a type to deserialize
  +     * @return Deserializer
  +     */
  +    public final Deserializer getDeserializerForType(QName xmlType) {
  +        return getDeserializer(null, xmlType);
       }

       /**
  @@ -921,7 +930,9 @@
           } finally {
               if (curElement != null)
                   curElement = (MessageElement)curElement.
getParentElement();
  -
  +
  +            namespaces.pop();
  +
                     if (log.isDebugEnabled()) {
                   String name = curElement != null ?
                           curElement.getClass().getName() + ":" +



  1.48      +6 -0      xml-
axis/java/src/org/apache/axis/encoding/DeserializationContext.java

  Index: DeserializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-
axis/java/src/org/apache/axis/encoding/DeserializationContext.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- DeserializationContext.java          16 Aug 2002 17:04:55 -0000
 1.47
  +++ DeserializationContext.java          23 Aug 2002 15:08:56 -0000
 1.48
  @@ -160,6 +160,12 @@
       public boolean isNil(Attributes attrs);

       /**
  +     * Get a Deserializer which can turn a given xml type into a given
  +     * Java type
  +     */
  +    public Deserializer getDeserializer(Class cls, QName xmlType);
  +
  +    /**
        * Convenience method to get the Deserializer for a specific
        * xmlType.
        * @param xmlType is QName for a type to deserialize



  1.50      +2 -0      xml-axis/java/src/org/apache/axis/utils/axisNLS.
properties

  Index: axisNLS.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/axisNLS.
properties,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- axisNLS.properties             21 Aug 2002 03:36:33 -0000
1.49
  +++ axisNLS.properties             23 Aug 2002 15:08:56 -0000
1.50
  @@ -995,3 +995,5 @@
   wsddServiceName00=The WSDD service name defaults to the port name.
   rpcProviderOperAssert00=The OperationDesc for {0} was not found in the
ServiceDesc.
   serviceDescOperSync00=The OperationDesc for {0} was not syncronized to a
method of {1}.
  +
  +noServiceClass=No service class was found!  Are you missing a className
option?








Mime
View raw message