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/utils Admin.java
Date Tue, 01 May 2001 15:42:41 GMT
gdaniels    01/05/01 08:42:41

  Modified:    java/src/org/apache/axis/registries
                        DefaultHandlerRegistry.java
                        DefaultServiceRegistry.java
               java/src/org/apache/axis/server AxisServer.java
               java/src/org/apache/axis/utils Admin.java
  Added:       java/src/org/apache/axis/handlers/soap SOAPService.java
  Removed:     java/src/org/apache/axis/handlers SOAPServerHandler.java
  Log:
  Use SOAPService rather than SimpleTargetedChain.  This cleans up the
  code and does less registry lookups.
  
  Revision  Changes    Path
  1.1                  xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
  
  Index: SOAPService.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.handlers.soap;
  
  import org.apache.axis.*;
  import org.apache.axis.utils.Debug;
  import org.apache.axis.transport.http.HTTPConstants;
  import org.apache.axis.registries.* ;
  
  /** A <code>SOAPService</code> is a Handler which encapsulates a SOAP
   * invocation.  It has an input chain, an output chain, and a pivot-point,
   * and handles the SOAP semantics when invoke()d.
   * 
   * @author Glen Daniels (gdaniels@macromedia.com) 
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class SOAPService extends SimpleTargetedChain
  {
      public static final String OPTION_PIVOT = "pivot";
      
      /** Standard, no-arg constructor.
       */
      public SOAPService()
      {
      }
      
      /** Convenience constructor for wrapping SOAP semantics around
       * "service handlers" which actually do work.
       */
      public SOAPService(Handler serviceHandler, String pivotName)
      {
          super();
          setPivotHandler(serviceHandler);
          addOption(OPTION_PIVOT, pivotName);
      }
      
      public void invoke(MessageContext msgContext) throws AxisFault
      {
          Debug.Print( 1, "Enter: SOAPService::invoke" );
          
          msgContext.setProperty( MessageContext.SVC_HANDLER, this );
          
          Handler h = getInputChain() ;
          if ( h != null ) {
              Debug.Print( 2, "Invoking input chain" );
              h.invoke(msgContext);
          } else {
              Debug.Print( 3, "No input chain" );
          }
  
          // Do SOAP semantics here
          Debug.Print( 2, "Doing SOAP semantic checks...");
  
          h = getPivotHandler();
          if ( h != null ) {
              Debug.Print( 2, "Invoking service/pivot" );
              h.invoke(msgContext);
          } else {
              Debug.Print( 3, "No service/pivot" );
          }
          
          h = getOutputChain();
          if ( h != null ) {
              Debug.Print( 2, "Invoking output chain" );
              h.invoke(msgContext);
          } else {
              Debug.Print( 3, "No output chain" );
          }
  
          Debug.Print( 1, "Exit : SOAPService::invoke" );
      }
  
      public void undo(MessageContext msgContext) 
      {
          Debug.Print( 1, "Enter: SOAPService::undo" );
          Debug.Print( 1, "Exit: SOAPService::undo" );
      }
  }
  
  
  
  1.7       +1 -1      xml-axis/java/src/org/apache/axis/registries/DefaultHandlerRegistry.java
  
  Index: DefaultHandlerRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/DefaultHandlerRegistry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultHandlerRegistry.java	2001/04/29 16:45:54	1.6
  +++ DefaultHandlerRegistry.java	2001/05/01 15:42:35	1.7
  @@ -116,7 +116,7 @@
   
       if ( onServer ) {
         this.add( "debug"        , new DebugHandler() );
  -      this.add( "SOAPServer"   , new SOAPServerHandler() );
  +      //this.add( "SOAPServer"   , new SOAPServerHandler() );
         this.add( "MsgDispatcher", new MsgDispatchHandler() );
         this.add( "RPCDispatcher", new RPCDispatchHandler() );
         this.add( "HTTPSender"   , new HTTPDispatchHandler() );
  
  
  
  1.7       +15 -11    xml-axis/java/src/org/apache/axis/registries/DefaultServiceRegistry.java
  
  Index: DefaultServiceRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/DefaultServiceRegistry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultServiceRegistry.java	2001/04/29 16:45:54	1.6
  +++ DefaultServiceRegistry.java	2001/05/01 15:42:36	1.7
  @@ -63,6 +63,7 @@
   import org.apache.axis.utils.Admin ;
   import org.apache.axis.utils.XMLUtils ;
   import org.apache.axis.handlers.* ;
  +import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.suppliers.* ;
   import org.apache.axis.registries.* ;
   
  @@ -115,19 +116,22 @@
       msgContext.setProperty(Constants.HANDLER_REGISTRY, handlerRegistry);
       msgContext.setProperty(Constants.SERVICE_REGISTRY, this);
   
  -    SimpleTargetedChain  cc = null ;
  -
       if ( onServer ) {
  -      this.add( "JWSProcessor", handlerRegistry.find( "JWSProcessor" ) );
  -
  -      cc = new SimpleTargetedChain();
  -      cc.setPivotHandler( handlerRegistry.find( "MsgDispatcher" ) );
  -      cc.addOption( "className", "org.apache.axis.utils.Admin" );
  -      cc.addOption( "methodName", "AdminService" );
  -      handlerRegistry.add( "AdminService", cc );
  -      this.add( "AdminService", cc );
  +      Handler h = handlerRegistry.find( "JWSProcessor" );
  +      if (h != null)
  +        this.add( "JWSProcessor",  new SOAPService(h, "JWSProcessor"));
  +
  +      SOAPService service = new SOAPService();
  +      service.setPivotHandler( handlerRegistry.find( "MsgDispatcher" ) );
  +      service.addOption(SOAPService.OPTION_PIVOT, "MsgDispatcher");
  +      service.addOption( "className", "org.apache.axis.utils.Admin" );
  +      service.addOption( "methodName", "AdminService" );
  +      handlerRegistry.add( "AdminService", service ); // ???
  +      this.add( "AdminService", service );
         
  -      this.add( "EchoService", handlerRegistry.find( "EchoHandler" ) );
  +      h = handlerRegistry.find( "EchoHandler" );
  +      if (h != null)
  +        this.add( "EchoService",  new SOAPService(h, "EchoHandler"));
       }
       else {
         // Do nothing
  
  
  
  1.5       +9 -0      xml-axis/java/src/org/apache/axis/server/AxisServer.java
  
  Index: AxisServer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AxisServer.java	2001/03/22 14:49:06	1.4
  +++ AxisServer.java	2001/05/01 15:42:38	1.5
  @@ -183,8 +183,17 @@
         
                 /* Process the Protocol Specific-Handler/Chain */
                 /***********************************************/
  +              /*
                 hName = msgContext.getStrProp(MessageContext.PROTOCOL_HANDLER);
                 if ( hName == null ) hName = "SOAPServer" ;
  +              if ( hName != null && (h = hr.find( hName )) != null )
  +                h.invoke(msgContext);
  +              else
  +                throw new AxisFault( "Server.error",
  +                                     "Can't find '" + hName + "' handler", 
  +                                     null, null );
  +              */
  +              hName = msgContext.getTargetService();
                 if ( hName != null && (h = hr.find( hName )) != null )
                   h.invoke(msgContext);
                 else
  
  
  
  1.28      +24 -12    xml-axis/java/src/org/apache/axis/utils/Admin.java
  
  Index: Admin.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Admin.java	2001/04/30 05:25:50	1.27
  +++ Admin.java	2001/05/01 15:42:40	1.28
  @@ -60,6 +60,7 @@
   import org.apache.axis.* ;
   import org.apache.axis.registries.* ;
   import org.apache.axis.handlers.* ;
  +import org.apache.axis.handlers.soap.SOAPService;
   import org.apache.axis.utils.* ;
   import org.apache.axis.suppliers.*;
   
  @@ -165,8 +166,16 @@
               if ( loop == 1 ) {
                 Element tmpElem = doc.createElement( "service" );
                 NodeList list = elem.getChildNodes();
  -              for ( int ii = 0 ; ii < list.getLength() ; ii++ )
  +              for ( int ii = 0 ; ii < list.getLength() ; ii++ ) {
  +                // Not the cleanest way to do this, but this code will be
  +                // replaced anyhow...
  +                if (h instanceof SOAPService) {
  +                  tmpElem.setAttribute(SOAPService.OPTION_PIVOT, (String)h.getOption("pivot"));
  +                }
  +                
  +                
                   tmpElem.appendChild( doc.importNode(list.item(ii),true) );
  +              }
                 elem = tmpElem ;
               }
   
  @@ -320,7 +329,7 @@
           else if ( type.equals( "service" ) ) {
             Debug.Print( 2, "Deploying service: " + name );
             StringTokenizer      st = null ;
  -          SimpleTargetedChain  cc = null ;
  +          SOAPService     service = null ;
             Chain                c  = null ;
   
             if ( pivot == null && input == null && output == null )
  @@ -328,17 +337,17 @@
                                    "Services must use targeted chains", 
                                    null, null );
   
  -          cc = (SimpleTargetedChain) hr.find( name );
  +          service = (SOAPService) hr.find( name );
   
  -          if ( cc == null ) cc = new SimpleTargetedChain();
  -          else              cc.clear();
  +          if ( service == null ) service = new SOAPService();
  +          else              service.clear();
     
             if ( input != null && !"".equals(input) ) {
               st = new StringTokenizer( input, " \t\n\r\f," );
               c  = null ;
               while ( st.hasMoreElements() ) {
                 if ( c == null )
  -                cc.setInputChain( c = new SimpleChain() );
  +                service.setInputChain( c = new SimpleChain() );
                 hName = st.nextToken();
                 tmpH = hr.find( hName );
                 if ( tmpH == null )
  @@ -349,15 +358,18 @@
               }
             }
             
  -          if ( pivot != null && !"".equals(pivot) )
  -            cc.setPivotHandler( hr.find( pivot ) );
  +          if ( pivot != null && !"".equals(pivot) ) {
  +            service.setPivotHandler( hr.find( pivot ) );
  +            // Save pivot name so we can list it later.
  +            service.addOption("pivot", pivot);
  +          }
     
             if ( output != null && !"".equals(output) ) {
               st = new StringTokenizer( output, " \t\n\r\f," );
               c  = null ;
               while ( st.hasMoreElements() ) {
                 if ( c == null )
  -                cc.setOutputChain( c = new SimpleChain() );
  +                service.setOutputChain( c = new SimpleChain() );
                 hName = st.nextToken();
                 tmpH = hr.find( hName );
                 if ( tmpH == null )
  @@ -367,9 +379,9 @@
                 c.addHandler( tmpH );
               }
             }
  -          getOptions( elem, cc );
  -          hr.add( name, cc );
  -          sr.add( name, cc );
  +          getOptions( elem, service );
  +          hr.add( name, service ); // ???
  +          sr.add( name, service );
           }
           else 
             throw new AxisFault( "Admin.error", 
  
  
  

Mime
View raw message