axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/handlers/soap SOAPService.java
Date Tue, 27 Nov 2001 04:08:59 GMT
gdaniels    01/11/26 20:08:59

  Modified:    java/src/org/apache/axis MessageContext.java
               java/src/org/apache/axis/client Service.java
               java/src/org/apache/axis/handlers/soap SOAPService.java
  Added:       java/src/org/apache/axis/client AxisClientFactory.java
  Log:
  * Introduce AxisClientFactory, a helper class which shields Service
    from the details of locating and initializing an appropriate AxisClient.
  
    If JNDI is available, the AxisClientFactory will look for a name passed
    to its getClient() method, hoping to find an AxisClient there.  If it doesn't
    find one, it creates one (using either an explicit ConfigurationProvider or
    going through a short default configuration algorithm) and binds it to the
    given name so it can be found next time.
  
    Right now Service uses a hardcoded (and rather silly) name.  We need
    to figure out an appropriate way to generate names, and how to deal if
    we don't pass a name at all (skip the JNDI steps?).  For EJB clients, it
    might be feasible to use the EJB name here, but we need some more
    input from the EJB experts on this pattern.
  
  * Fix bug where no one was setting the ISRPC property on MessageContext,
    even though it was getting checked.  Now we appropriately create plain
    SOAPBodyElements for document-oriented services
  
  Revision  Changes    Path
  1.66      +1 -0      xml-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- MessageContext.java	2001/11/26 02:21:38	1.65
  +++ MessageContext.java	2001/11/27 04:08:59	1.66
  @@ -384,6 +384,7 @@
               SOAPService service = (SOAPService)sh;
               TypeMappingRegistry tmr = service.getTypeMappingRegistry();
               setTypeMappingRegistry(tmr);
  +            setProperty(ISRPC, new Boolean(service.isRPC()));
           }
       }
       
  
  
  
  1.26      +30 -19    xml-axis/java/src/org/apache/axis/client/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Service.java	2001/11/25 19:11:59	1.25
  +++ Service.java	2001/11/27 04:08:59	1.26
  @@ -59,6 +59,7 @@
   import org.apache.axis.AxisEngine;
   import org.apache.axis.Constants;
   import org.apache.axis.ConfigurationProvider;
  +import org.apache.axis.AxisFault;
   import org.apache.axis.configuration.FileProvider;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.XMLUtils;
  @@ -101,8 +102,7 @@
       private Definition          wsdlDefinition = null ;
       private javax.wsdl.Service  wsdlService    = null ;
   
  -    private static FileProvider defaultConfigProvider =
  -                           new FileProvider(Constants.CLIENT_CONFIG_FILE);
  +    private ConfigurationProvider configProvider = null;
   
       Definition getWSDLDefinition() {
           return( wsdlDefinition );
  @@ -112,6 +112,16 @@
           return( wsdlService );
       }
   
  +    protected AxisClient getAxisClient() throws JAXRPCException
  +    {
  +        String name = "some name";
  +        try {
  +            return AxisClientFactory.getClient(name, configProvider);
  +        } catch (AxisFault fault) {
  +            throw new JAXRPCException(fault.getMessage());
  +        }
  +    }
  +
       /**
        * Constructs a new Service object - this assumes the caller will set
        * the appropriate fields by hand rather than getting them from the
  @@ -119,8 +129,8 @@
        *
        * @exception JAXRPCException If there's an error
        */
  -    public Service() throws JAXRPCException { 
  -        engine = new AxisClient(defaultConfigProvider);
  +    public Service() throws JAXRPCException {
  +        engine = getAxisClient();
       }
   
       /**
  @@ -130,11 +140,12 @@
        */
       public Service(ConfigurationProvider configProvider)
               throws JAXRPCException {
  -        engine = new AxisClient(configProvider);
  +        this.configProvider = configProvider;
  +        engine = getAxisClient();
       }
   
       /**
  -     * Constructs a new Service object for the service in the WSDL document 
  +     * Constructs a new Service object for the service in the WSDL document
        * pointed to by the wsdlDoc URL and serviceName parameters.
        *
        * @param wsdlDoc          URL of the WSDL document
  @@ -142,7 +153,7 @@
        * @throws JAXRPCExceptionIif there's an error finding or parsing the WSDL
        */
       public Service(URL wsdlDoc, QName serviceName) throws JAXRPCException {
  -        engine = new AxisClient(defaultConfigProvider);
  +        engine = getAxisClient();
           Document doc = XMLUtils.newDocument(wsdlDoc.toString());
           initService(doc, serviceName);
       }
  @@ -150,7 +161,7 @@
       /**
        * Constructs a new Service object for the service in the WSDL document
        * pointed to by the wsdlLocation and serviceName parameters.  This is
  -     * just like the previous constructor but instead of URL the 
  +     * just like the previous constructor but instead of URL the
        * wsdlLocation parameter points to a file on the filesystem relative
        * to the current directory.
        *
  @@ -158,9 +169,9 @@
        * @param  serviceName     Qualified name of the desired service
        * @throws JAXRPCException If there's an error finding or parsing the WSDL
        */
  -    public Service(String wsdlLocation, QName serviceName) 
  +    public Service(String wsdlLocation, QName serviceName)
                              throws JAXRPCException {
  -        engine = new AxisClient(defaultConfigProvider);
  +        engine = getAxisClient();
           try {
               // Start by reading in the WSDL using WSDL4J
               FileInputStream      fis = new FileInputStream(wsdlLocation);
  @@ -183,21 +194,21 @@
        * @param  serviceName     Qualified name of the desired service
        * @throws JAXRPCException If there's an error finding or parsing the WSDL
        */
  -    public Service(InputStream wsdlInputStream, QName serviceName) 
  +    public Service(InputStream wsdlInputStream, QName serviceName)
                              throws JAXRPCException {
  -        engine = new AxisClient(defaultConfigProvider);
  +        engine = getAxisClient();
           Document doc = XMLUtils.newDocument(wsdlInputStream);
           initService(doc, serviceName);
       }
   
       /**
        * Common code for building up the Service from a WSDL document
  -     * 
  +     *
        * @param doc               A DOM document containing WSDL
        * @param serviceName       Qualified name of the desired service
        * @throws JAXRPCException  If there's an error finding or parsing the WSDL
  -     */ 
  -    private void initService(Document doc, QName serviceName) 
  +     */
  +    private void initService(Document doc, QName serviceName)
               throws JAXRPCException {
           try {
               // Start by reading in the WSDL using WSDL4J
  @@ -210,7 +221,7 @@
               String           ns = serviceName.getNamespaceURI();
               String           lp = serviceName.getLocalPart();
               javax.wsdl.QName qn = new javax.wsdl.QName( ns, lp );
  - 
  +
               this.wsdlService    = def.getService( qn );
               if ( this.wsdlService == null )
                   throw new JAXRPCException(
  @@ -243,7 +254,7 @@
        * @return Call            Used for invoking the Web Service
        * @throws JAXRPCException If there's an error
        */
  -    public javax.xml.rpc.Call createCall(QName portName) 
  +    public javax.xml.rpc.Call createCall(QName portName)
                               throws JAXRPCException {
           javax.wsdl.QName qn = new javax.wsdl.QName( portName.getNamespaceURI(),
                                                       portName.getLocalPart() );
  @@ -267,7 +278,7 @@
           List list = port.getExtensibilityElements();
           for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
               Object obj = list.get(i);
  -            if ( obj instanceof SOAPAddress ) { 
  +            if ( obj instanceof SOAPAddress ) {
                   try {
                       SOAPAddress addr = (SOAPAddress) obj ;
                       URL         url  = new URL(addr.getLocationURI());
  @@ -293,7 +304,7 @@
        * @return Call            Used for invoking the Web Service
        * @throws JAXRPCException If there's an error
        */
  -    public javax.xml.rpc.Call createCall(QName portName, 
  +    public javax.xml.rpc.Call createCall(QName portName,
                                            String operationName)
                              throws JAXRPCException {
   
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/client/AxisClientFactory.java
  
  Index: AxisClientFactory.java
  ===================================================================
  package org.apache.axis.client;
  
  import org.apache.axis.ConfigurationProvider;
  import org.apache.axis.AxisFault;
  import org.apache.axis.Constants;
  import org.apache.axis.configuration.FileProvider;
  
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  /**
   * Helper class for obtaining AxisClients, which hides the complexity
   * of JNDI accesses, etc.
   *
   * !!! QUESTION : Does this class need to play any ClassLoader tricks?
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   */ 
  
  public class AxisClientFactory {
      private static FileProvider defaultConfigProvider =
                             new FileProvider(Constants.CLIENT_CONFIG_FILE);
  
      /**
       * Obtain an AxisClient reference, using JNDI if possible, otherwise
       * creating one using the standard Axis configuration pattern.  If we
       * end up creating one and do have JNDI access, bind it to the passed
       * name so we find it next time.
       *
       * @param name the JNDI name we're interested in
       * @param configProvider a ConfigurationProvider which should be used
       *                       to configure any engine we end up creating, or
       *                       null to use the default configuration pattern.
       */
      static public AxisClient getClient(String name,
                                         ConfigurationProvider configProvider)
          throws AxisFault
      {
          AxisClient client = null;
          InitialContext context = null;
  
          // First check to see if JNDI works
          // !!! Might we need to set up context parameters here?
          try {
              context = new InitialContext();
          } catch (NamingException e) {
          }
          
          if (context != null) {
              // We've got JNDI, so try to find an AxisClient at the
              // specified name.
              try {
                  client = (AxisClient)context.lookup(name);
                  System.err.println("found client : " + client);
              } catch (NamingException e) {
                  // Didn't find it.
                  client = createNewClient(configProvider);
                  try {
                      context.bind(name, client);
                  } catch (NamingException e1) {
                      // !!! Couldn't do it, what should we do here?
                  }
              }
          } else {
              client = createNewClient(configProvider);
          }
  
          return client;
      }
  
      /**
       * Do the actual work of creating a new AxisClient, using the passed
       * configuration provider, or going through the default configuration
       * steps if null is passed.
       *
       * @return a shiny new AxisClient, ready for use.
       */
      static private AxisClient createNewClient(ConfigurationProvider provider)
      {
          // Just use the passed provider if there is one.
          if (provider != null) {
              return new AxisClient(provider);
          }
  
          // Default configuration steps...
          //
          // 1. Check for a system property telling us which Configuration
          //    Provider to use.  If we find it, try creating one.
          String configClass = System.getProperty("axis.configProviderClass");
          if (configClass != null) {
              // Got one - so try to make it (which means it had better have
              // a default constructor - may make it possible later to pass in
              // some kind of environmental parameters...)
              try {
                  Class cls = Class.forName(configClass);
                  provider = (ConfigurationProvider)cls.newInstance();
              } catch (ClassNotFoundException e) {
                  // Fall through???
              } catch (InstantiationException e) {
                  // Fall through???
              } catch (IllegalAccessException e) {
                  // Fall through???
              }
          }
  
          // 2. If we couldn't make one above, use the default one.
          // !!! May want to add options here for getting another system
          //     property which is the config file name...
          if (provider == null) {
              provider = defaultConfigProvider;
          }
  
          // 3. Create an AxisClient using the appropriate provider
          return new AxisClient(provider);
      }
  }
  
  
  
  1.35      +14 -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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- SOAPService.java	2001/11/15 14:07:39	1.34
  +++ SOAPService.java	2001/11/27 04:08:59	1.35
  @@ -61,6 +61,7 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.SimpleTargetedChain;
  +import org.apache.axis.providers.java.MsgProvider;
   import org.apache.axis.encoding.DeserializerFactory;
   import org.apache.axis.encoding.SOAPTypeMappingRegistry;
   import org.apache.axis.encoding.Serializer;
  @@ -136,7 +137,19 @@
       {
         typeMap.setParent(engine.getTypeMappingRegistry());
       }
  -    
  +
  +    /**
  +     * Is this an RPC service?  Right now, we default to yes, unless
  +     * the provider is in fact a MsgProvider.
  +     *
  +     * @return true if the service is RPC, false if document-oriented
  +     */
  +    public boolean isRPC()
  +    {
  +        return ((pivotHandler != null) &&
  +                (pivotHandler.getClass() != MsgProvider.class));
  +    }
  +
       public boolean availableFromTransport(String transportName)
       {
           if (validTransports != null) {
  
  
  

Mime
View raw message