You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2002/09/02 20:20:05 UTC

cvs commit: xml-axis/java/tools build.xml

gdaniels    2002/09/02 11:20:05

  Modified:    java/samples/echo deploy.wsdd deployA.wsdd deployB.wsdd
               java/src/org/apache/axis/providers/java JavaProvider.java
               java/tools build.xml
  Log:
  JavaProvider changes:
  
  * Synchronize on the objects which need to be protected, not the JavaProvider
    itself
  
  * Make the WSDL namespace generation smarter, use the namespace in the
    ServiceDesc if present when figuring it out
  
  * Comment a bit better
  
  * Remove (now unneeded) parameters from echo WSDDs
  
  Revision  Changes    Path
  1.23      +0 -1      xml-axis/java/samples/echo/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/echo/deploy.wsdd,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- deploy.wsdd	27 Aug 2002 14:10:00 -0000	1.22
  +++ deploy.wsdd	2 Sep 2002 18:20:05 -0000	1.23
  @@ -12,7 +12,6 @@
   			xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
     <service name="echo" provider="java:RPC" >
       <namespace>http://soapinterop.org/</namespace>
  -    <parameter name="wsdlTargetNamespace" value="http://soapinterop.org/" />
       <parameter name="className" value="samples.echo.InteropTestSoapBindingImpl" />
       <parameter name="allowedMethods" value="*" />
   
  
  
  
  1.3       +0 -1      xml-axis/java/samples/echo/deployA.wsdd
  
  Index: deployA.wsdd
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/echo/deployA.wsdd,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- deployA.wsdd	27 Aug 2002 14:10:00 -0000	1.2
  +++ deployA.wsdd	2 Sep 2002 18:20:05 -0000	1.3
  @@ -12,7 +12,6 @@
   			xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
     <service name="echoA" provider="java:RPC" >
       <namespace>http://soapinterop.org/</namespace>
  -    <parameter name="wsdlTargetNamespace" value="http://soapinterop.org/" />
       <parameter name="className" value="samples.echo.InteropTestSoapBindingImpl" />
       <parameter name="allowedMethods" value="echoString 
           echoStringArray 
  
  
  
  1.3       +0 -1      xml-axis/java/samples/echo/deployB.wsdd
  
  Index: deployB.wsdd
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/echo/deployB.wsdd,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- deployB.wsdd	27 Aug 2002 14:10:00 -0000	1.2
  +++ deployB.wsdd	2 Sep 2002 18:20:05 -0000	1.3
  @@ -12,7 +12,6 @@
   			xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
     <service name="echoB" provider="java:RPC" >
       <namespace>http://soapinterop.org/</namespace>
  -    <parameter name="wsdlTargetNamespace" value="http://soapinterop.org/" />
       <parameter name="className" value="samples.echo.InteropTestSoapBindingImpl" />
       <parameter name="allowedMethods" value="echoStructAsSimpleTypes 
           echoSimpleTypesAsStruct 
  
  
  
  1.77      +75 -39    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.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- JavaProvider.java	2 Sep 2002 00:13:21 -0000	1.76
  +++ JavaProvider.java	2 Sep 2002 18:20:05 -0000	1.77
  @@ -74,12 +74,20 @@
   import org.apache.axis.utils.cache.ClassCache;
   import org.apache.axis.utils.cache.JavaClass;
   import org.apache.axis.wsdl.fromJava.Emitter;
  +import org.apache.axis.encoding.TypeMapping;
  +import org.apache.axis.enum.Style;
  +import org.apache.axis.enum.Scope;
  +import org.apache.axis.Constants;
  +import org.apache.axis.session.Session;
  +import org.apache.axis.description.ServiceDesc;
  +import org.apache.axis.handlers.soap.SOAPService;
  +
  +import org.apache.axis.components.logger.LogFactory;
   import org.apache.commons.logging.Log;
   import org.w3c.dom.Document;
   
   import javax.xml.rpc.holders.IntHolder;
   import javax.xml.rpc.server.ServiceLifecycle;
  -import java.net.URL;
   import java.util.ArrayList;
   import java.util.StringTokenizer;
   
  @@ -128,7 +136,7 @@
           // scope can be "Request", "Session", "Application"
           // (as with Apache SOAP)
           Scope scope = Scope.getScope((String)service.getOption(OPTION_SCOPE), Scope.DEFAULT);
  -        
  +
           scopeHolder.value = scope.getValue();
   
           if (scope == Scope.REQUEST) {
  @@ -140,14 +148,15 @@
                   serviceName = msgContext.getService().toString();
   
               // look in incoming session
  -            if (msgContext.getSession() != null) {
  +            Session session = msgContext.getSession();
  +            if (session != null) {
                   // This part isn't thread safe...
  -                synchronized (this) {
  +                synchronized (session) {
                       // store service objects in session, indexed by class name
  -                    Object obj = msgContext.getSession().get(serviceName);
  +                    Object obj = session.get(serviceName);
                       if (obj == null) {
                           obj = getNewServiceObject(msgContext, clsName);
  -                        msgContext.getSession().set(serviceName, obj);
  +                        session.set(serviceName, obj);
                       }
                       return obj;
                   }
  @@ -159,15 +168,15 @@
           } else if (scope == Scope.APPLICATION) {
               // MUST be AxisEngine here!
               AxisEngine engine = msgContext.getAxisEngine();
  -            if (engine.getApplicationSession() != null) {
  +            Session appSession = engine.getApplicationSession();
  +            if (appSession != null) {
                   // This part isn't thread safe
  -                synchronized (this) {
  +                synchronized (appSession) {
                       // store service objects in session, indexed by class name
  -                    Object obj =
  -                            engine.getApplicationSession().get(serviceName);
  +                    Object obj = appSession.get(serviceName);
                       if (obj == null) {
                           obj = getNewServiceObject(msgContext, clsName);
  -                        engine.getApplicationSession().set(serviceName, obj);
  +                        appSession.set(serviceName, obj);
                       }
                       return obj;
                   }
  @@ -185,7 +194,7 @@
   
       /**
        * Return a new service object which, if it implements the ServiceLifecycle
  -     * interface, has been init()ed. 
  +     * interface, has been init()ed.
        *
        * @param msgContext the MessageContext
        * @param clsName the name of the class to instantiate
  @@ -301,38 +310,65 @@
           SOAPService service = msgContext.getService();
           ServiceDesc serviceDesc = service.getInitializedServiceDesc(msgContext);
   
  +        // Calculate the appropriate namespaces for the WSDL we're going
  +        // to put out.
  +        //
  +        // If we've been explicitly told which namespaces to use, respect
  +        // that.  If not:
  +        //
  +        // The "interface namespace" should be either:
  +        // 1) The namespace of the ServiceDesc
  +        // 2) The transport URL (if there's no ServiceDesc ns)
  +
           try {
  -            String url = msgContext.getStrProp(MessageContext.TRANS_URL);
  -            String interfaceNamespace = 
  -                    msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
  -            if (interfaceNamespace == null) {
  -                interfaceNamespace = url;
  -            }
  -            String locationUrl = 
  +            // Location URL is whatever is explicitly set in the MC
  +            String locationUrl =
                       msgContext.getStrProp(MessageContext.WSDLGEN_SERV_LOC_URL);
   
               if (locationUrl == null) {
  +                // If nothing, try what's explicitly set in the ServiceDesc
                   locationUrl = serviceDesc.getEndpointURL();
               }
   
               if (locationUrl == null) {
  -                locationUrl = url;
  -            } else {
  -                try {
  -                    URL urlURL = new URL(url);
  -                    URL locationURL = new URL(locationUrl);
  -                    URL urlTemp = new URL(urlURL.getProtocol(),
  -                            locationURL.getHost(),
  -                            locationURL.getPort(),
  -                            urlURL.getFile());
  -                    interfaceNamespace += urlURL.getFile();
  -                    locationUrl = urlTemp.toString();
  -                } catch (Exception e) {
  -                    locationUrl = url;
  -                    interfaceNamespace = url;
  -                }
  +                // If nothing, use the actual transport URL
  +                locationUrl = msgContext.getStrProp(MessageContext.TRANS_URL);
               }
   
  +            // Interface namespace is whatever is explicitly set
  +            String interfaceNamespace =
  +                    msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
  +
  +            if (interfaceNamespace == null) {
  +                // If nothing, use the default namespace of the ServiceDesc
  +                interfaceNamespace = serviceDesc.getDefaultNamespace();
  +            }
  +
  +            if (interfaceNamespace == null) {
  +                // If nothing still, use the location URL determined above
  +                interfaceNamespace = locationUrl;
  +            }
  +
  +//  Do we want to do this?
  +//
  +//            if (locationUrl == null) {
  +//                locationUrl = url;
  +//            } else {
  +//                try {
  +//                    URL urlURL = new URL(url);
  +//                    URL locationURL = new URL(locationUrl);
  +//                    URL urlTemp = new URL(urlURL.getProtocol(),
  +//                            locationURL.getHost(),
  +//                            locationURL.getPort(),
  +//                            urlURL.getFile());
  +//                    interfaceNamespace += urlURL.getFile();
  +//                    locationUrl = urlTemp.toString();
  +//                } catch (Exception e) {
  +//                    locationUrl = url;
  +//                    interfaceNamespace = url;
  +//                }
  +//            }
  +
               Emitter emitter = new Emitter();
   
               // service alias may be provided if exact naming is required,
  @@ -344,15 +380,15 @@
                                ? Emitter.MODE_RPC
                                : Emitter.MODE_DOCUMENT);
   
  -            emitter.setClsSmart(serviceDesc.getImplClass(),url);
  +            emitter.setClsSmart(serviceDesc.getImplClass(), locationUrl);
   
               // If a wsdl target namespace was provided, use the targetNamespace.
               // Otherwise use the interfaceNamespace constructed above.
               String targetNamespace = (String) service.getOption(OPTION_WSDL_TARGETNAMESPACE);
  -            if (targetNamespace == null || 
  +            if (targetNamespace == null ||
                   targetNamespace.length() == 0) {
                   targetNamespace = interfaceNamespace;
  -            }            
  +            }
               emitter.setIntfNamespace(targetNamespace);
   
               emitter.setLocationUrl(locationUrl);
  @@ -485,7 +521,7 @@
        * right place.
        */
       public void initServiceDesc(SOAPService service, MessageContext msgContext)
  -            throws AxisFault 
  +            throws AxisFault
       {
           // Set up the Implementation class for the service
   
  @@ -511,5 +547,5 @@
   
           serviceDescription.loadServiceDescByIntrospection(cls);
       }
  -    
  +
   }
  
  
  
  1.4       +1 -1      xml-axis/java/tools/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/tools/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml	30 Aug 2002 19:42:42 -0000	1.3
  +++ build.xml	2 Sep 2002 18:20:05 -0000	1.4
  @@ -66,7 +66,7 @@
       </javac>
   
       <!-- build the wsdl2java and java2wsdl tasks -->
  -    <echo message="wsdl2java and java2wsdl" />
  +    <echo message="Building WSDL tasks" />
       <javac srcdir="${axis.home}/tools/${componentName}/wsdl" destdir="${build.dir}/tools">
         <classpath>
           <pathelement location="${build.lib}/${name}.jar"/>