You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@apache.org on 2001/05/17 19:45:55 UTC

cvs commit: xml-soap/java/src/org/apache/soap/server RPCRouter.java

dug         01/05/17 10:45:55

  Modified:    java/src/org/apache/soap/providers RPCJavaProvider.java
               java/src/org/apache/soap/server RPCRouter.java
  Log:
  When looking for a Java method if we don't find it, before we fault
  look for the same method name with an additional parameter (1st)
  of type SOAPContext.  If found call it.  This allows services to
  get access to the request SOAPContext which contains a bag of
  properties that has things like the Servlet info (in the http case).
  
  If we get the DD.xml file to the point where each method can have
  its own options then we can add a flag to tell us to skip the
  1st check and search only for the one with the SOAPContext arg.
  
  Revision  Changes    Path
  1.5       +2 -1      xml-soap/java/src/org/apache/soap/providers/RPCJavaProvider.java
  
  Index: RPCJavaProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/providers/RPCJavaProvider.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RPCJavaProvider.java	2001/05/02 13:34:11	1.4
  +++ RPCJavaProvider.java	2001/05/17 17:45:46	1.5
  @@ -126,7 +126,8 @@
                  throws SOAPException {
         // invoke the method on the target object
         try {
  -        Response resp = RPCRouter.invoke( dd, call, targetObject, resContext );
  +        Response resp = RPCRouter.invoke( dd, call, targetObject, 
  +                                          reqContext, resContext );
           Envelope env = resp.buildEnvelope();
           StringWriter  sw = new StringWriter();
           env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
  
  
  
  1.12      +24 -4     xml-soap/java/src/org/apache/soap/server/RPCRouter.java
  
  Index: RPCRouter.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/RPCRouter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RPCRouter.java	2001/04/02 19:42:12	1.11
  +++ RPCRouter.java	2001/05/17 17:45:51	1.12
  @@ -72,7 +72,7 @@
      */
     public static Response invoke (DeploymentDescriptor dd,
                                    Call call, Object targetObject,
  -                                 SOAPContext ctx ) 
  +                                 SOAPContext reqCtx, SOAPContext resCtx ) 
          throws SOAPException {
       byte providerType = dd.getProviderType ();
   
  @@ -105,8 +105,28 @@
       try {
         if (providerType == DeploymentDescriptor.PROVIDER_JAVA ||
             providerType == DeploymentDescriptor.PROVIDER_USER_DEFINED) {
  -        Method m = MethodUtils.getMethod (targetObject, call.getMethodName (),
  -                                          argTypes);
  +        Method m = null ;
  +        try {
  +          m = MethodUtils.getMethod (targetObject,call.getMethodName(),argTypes);
  +        }
  +        catch( Exception e ) {
  +          if ( !(e instanceof NoSuchMethodException) ) throw e ;
  +          int paramsCount = 0 ;
  +          if ( params != null ) paramsCount = params.size();
  +          Class[]   tmpArgTypes = new Class[paramsCount+1];
  +          Object[]  tmpArgs     = new Object[paramsCount+1];
  +          for ( int i = 0 ; i < paramsCount ; i++ )
  +            tmpArgTypes[i+1] = argTypes[i] ;
  +          argTypes = tmpArgTypes ;
  +          argTypes[0] = SOAPContext.class ;
  +          m = MethodUtils.getMethod (targetObject,call.getMethodName(),
  +                                     argTypes);
  +          for ( int i = 0 ; i < paramsCount ; i++ )
  +            tmpArgs[i+1] = args[i] ;
  +          tmpArgs[0] = reqCtx ;
  +          args = tmpArgs ;
  +        }
  +
           result = new Bean (m.getReturnType (), m.invoke (targetObject, args));
         } else {
           // find the class that provides the BSF services (done
  @@ -141,6 +161,6 @@
                              result.value, null);
       }
       return new Response (call.getTargetObjectURI (), call.getMethodName (),
  -                         ret, null, null, respEncStyle, ctx);
  +                         ret, null, null, respEncStyle, resCtx);
     }
   }