axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/webapps/axis/WEB-INF web.xml
Date Tue, 20 Feb 2001 14:25:01 GMT
dug         01/02/20 06:24:59

  Modified:    java/samples/stock deploy.xml
               java/samples/xml init.xml
               java/src/org/apache/axis Constants.java
               java/src/org/apache/axis/handlers DebugHandler.java
                        HTTPActionHandler.java RPCDispatchHandler.java
               java/webapps/axis/WEB-INF web.xml
  Added:       java/samples/stock StockQuoteService.jws
               java/src/org/apache/axis/handlers JWSProcessor.java
  Log:
  Added support for *.jws files.
  This allows you to place a *.jws file (a Java Web Service) file in your
  webapp dir and Axis will copy it to a *.java file, compile it and then
  use the RPCDispatchHandler to invoke it.  Using this you can deploy
  new webserivces by simply placing the java/jws file in your web app
  dir and Axis does the rest.  To access you just need to make sure the
  URL is correct.  For example, I took the StockQuoteService.java file
  and renamed it to StockQuoteService.jws, placed it in the webapps/axis
  dir (oh, also removed the package line).  Then to test it I ran:
    java samples.stock.GetQuote -lhttp://localhost:8080/axis/StockQuoteService.jws IBM
  
  Revision  Changes    Path
  1.5       +1 -2      xml-axis/java/samples/stock/deploy.xml
  
  Index: deploy.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/stock/deploy.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- deploy.xml	2001/02/06 19:51:42	1.4
  +++ deploy.xml	2001/02/20 14:24:43	1.5
  @@ -8,11 +8,10 @@
   <!-- This file will be replaced by WSDD once it's ready         -->
   
   <deploy>
  -  <handler name="debug"   class="org.apache.axis.handlers.DebugHandler" />
     <handler name="authen"  class="org.apache.axis.handlers.SimpleAuthenticationHandler"
/>
     <handler name="author"  class="org.apache.axis.handlers.SimpleAuthorizationHandler"
/>
     <chain   name="checks"  flow="authen,author" />
  -  <chain   name="rpc"     flow="debug,checks,RPCDispatcher" />
  +  <chain   name="rpc"     flow="checks,RPCDispatcher" />
   
     <service name="urn:xmltoday-delayed-quotes" handler="rpc" >
       <option name="className" value="samples.stock.StockQuoteService" />
  
  
  
  1.1                  xml-axis/java/samples/stock/StockQuoteService.jws
  
  Index: StockQuoteService.jws
  ===================================================================
  /*
   * 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/>.
   */
  
  import java.io.*;
  import java.net.URL;
  
  import org.w3c.dom.*;
  import org.xml.sax.InputSource ;
  import org.apache.xerces.parsers.* ;
  import org.apache.xerces.framework.* ;
  
  /**
   * See \samples\stock\readme for info.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class StockQuoteService {
    public float getQuote (String symbol) throws Exception {
      // get a real (delayed by 20min) stockquote from 
      // http://www.xmltoday.com/examples/stockquote/. The IP addr 
      // below came from the host that the above form posts to ..
  
      if ( symbol.equals("XXX") ) return( (float) 55.25 );
  
      URL          url = new URL( "http://www.xmltoday.com/examples/" +
                                  "stockquote/getxmlquote.vep?s="+symbol );
  
      DOMParser    parser = new DOMParser();
      InputSource  inp    = new InputSource( url.openStream() );
  
      parser.parse( inp );
  
      Document     doc  = parser.getDocument();
      Element      elem = doc.getDocumentElement ();
      NodeList     list = elem.getElementsByTagName( "price" );
  
      elem = (Element) list.item( 0 );
      String quoteStr = elem.getAttribute ("value");
      try {
        return Float.valueOf(quoteStr).floatValue();
      } catch (NumberFormatException e1) {
        // maybe its an int?
        try {
          return Integer.valueOf(quoteStr).intValue() * 1.0F;
        } catch (NumberFormatException e2) {
          return -1.0F;
        }
      }
    }
  }
  
  
  
  1.5       +8 -2      xml-axis/java/samples/xml/init.xml
  
  Index: init.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/xml/init.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- init.xml	2001/02/09 02:03:14	1.4
  +++ init.xml	2001/02/20 14:24:46	1.5
  @@ -4,6 +4,8 @@
   <!-- This file will be replaced by WSDD once it's ready -->
   
   <deploy>
  +  <handler name="debug"   class="org.apache.axis.handlers.DebugHandler" />
  +
     <handler name="MsgDispatcher"
              class="org.apache.axis.handlers.MsgDispatchHandler" />
   
  @@ -11,11 +13,15 @@
              class="org.apache.axis.handlers.RPCDispatchHandler" />
   
     <handler name="router" class="org.apache.axis.handlers.Router" />
  +  <handler name="jwsprocessor" class="org.apache.axis.handlers.JWSProcessor" />
   
     <handler name="HTTPAction" 
              class="org.apache.axis.handlers.HTTPActionHandler" />
  -  <chain name="HTTPTransport" flow="HTTPAction,router" />
  -  <service name="AxisServlet" handler="HTTPTransport" />
  +
  +  <chain name="HTTPTransport" flow="debug,HTTPAction,router" />
  +
  +  <service name="JWSProcessor" handler="jwsprocessor" />
  +  <service name="AxisServlet"  handler="HTTPTransport" />
   
     <service name="AdminService" handler="MsgDispatcher">
       <option name="className" value="org.apache.axis.utils.Admin" />
  
  
  
  1.5       +2 -0      xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Constants.java	2001/02/12 01:11:11	1.4
  +++ Constants.java	2001/02/20 14:24:49	1.5
  @@ -106,4 +106,6 @@
     /** For demonstration purposes only... --Glen
      */
     public static String SERVLET_TARGET = "AxisServlet";
  +
  +  public static String JWSPROCESSOR_TARGET = "JWSProcessor" ;
   }
  
  
  
  1.4       +1 -1      xml-axis/java/src/org/apache/axis/handlers/DebugHandler.java
  
  Index: DebugHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/DebugHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DebugHandler.java	2001/02/10 04:39:55	1.3
  +++ DebugHandler.java	2001/02/20 14:24:52	1.4
  @@ -84,7 +84,7 @@
                   if ( node != null ) {
                       String  value    = node.getNodeValue();
                       int     debugVal = Integer.parseInt( value );
  -                    Debug.Print( 1, "Settng debug level to: " + debugVal );
  +                    Debug.Print( 1, "Setting debug level to: " + debugVal );
                       Debug.setDebugLevel( debugVal );
                       header.setProcessed( true );
                   }
  
  
  
  1.6       +27 -6     xml-axis/java/src/org/apache/axis/handlers/HTTPActionHandler.java
  
  Index: HTTPActionHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/HTTPActionHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HTTPActionHandler.java	2001/02/17 18:02:17	1.5
  +++ HTTPActionHandler.java	2001/02/20 14:24:53	1.6
  @@ -58,6 +58,9 @@
   import org.apache.axis.utils.Debug;
   import org.apache.axis.transport.http.HTTPConstants;
   
  +import javax.servlet.* ;
  +import javax.servlet.http.* ;
  +
   /** An <code>HTTPActionHandler</code> simply sets the context's TargetService
    * property from the HTTPAction property.  We expect there to be a
    * Router on the chain after us, to dispatch to the service named in
  @@ -74,13 +77,31 @@
       public void invoke(MessageContext msgContext) throws AxisFault
       {
           Debug.Print( 1, "Enter: HTTPActionHandler::invoke" );
  -        String action = (String) msgContext.getProperty(
  +        String action = null ;
  +        HttpServlet        servlet = (HttpServlet) msgContext.getProperty(
  +                                             HTTPConstants.MC_HTTP_SERVLET);
  +        ServletConfig      config  = servlet.getServletConfig();
  +        ServletContext     context = config.getServletContext();
  +        HttpServletRequest req = (HttpServletRequest) msgContext.getProperty(
  +                                        HTTPConstants.MC_HTTP_SERVLETREQUEST);
  +        String URL = req.getServletPath();
  +        Debug.Print(3, "URL: " + URL );
  +
  +        if ( URL.endsWith(".jws") ) {
  +            String pathName = context.getRealPath( URL );
  +            Debug.Print(2, "Path: " + pathName );
  +            msgContext.setProperty( "JWSFileName", pathName );
  +            action = Constants.JWSPROCESSOR_TARGET ;
  +        }
  +        else {
  +            action = (String) msgContext.getProperty(
                                                HTTPConstants.MC_HTTP_SOAPACTION);
  -        Debug.Print( 2, "  HTTP SOAPAction: " + action );
  -        if (action == null)
  -            throw new AxisFault( "Server.NoHTTPAction",
  -                                 "No HTTPAction property in context",
  -                                 null, null );
  +            Debug.Print( 2, "  HTTP SOAPAction: " + action );
  +            if (action == null)
  +                throw new AxisFault( "Server.NoHTTPAction",
  +                                     "No HTTPAction property in context",
  +                                     null, null );
  +        }
   
           msgContext.setTargetService( action );
           Debug.Print( 1, "Exit : HTTPActionHandler::invoke" );
  
  
  
  1.12      +1 -1      xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java
  
  Index: RPCDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RPCDispatchHandler.java	2001/02/17 16:44:02	1.11
  +++ RPCDispatchHandler.java	2001/02/20 14:24:53	1.12
  @@ -100,7 +100,7 @@
           String       mName = body.getMethodName();
           Vector       args  = body.getArgs();        //RPCArg's
     
  -        if ( !methodName.equals(mName) )
  +        if ( methodName != null && !methodName.equals(mName) )
             throw new AxisFault( "AxisServier.error", 
                                  "Method names don't match\n" +
                                    "Body name=" + mName + "\n" +
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
  
  Index: JWSProcessor.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;
  
  import java.io.* ;
  
  import org.apache.axis.*;
  import org.apache.axis.utils.Debug;
  
  /** 
   * This handler will use the JWSFileName property of the MsgContext to
   * locate a *.jws (JavaWebService) file.  If found it will copy it to a
   * *.java file, compile it and then run it using the RPCDispatchHandler.
   *
   * Todo:
   *   support msg instead of just rpc
   *   allow configurable handler (not just RPCDispatchHandler)
   * 
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class JWSProcessor extends BasicHandler
  {
    public void invoke(MessageContext msgContext) throws AxisFault
    {
      Debug.Print( 1, "Enter: JWSProcessor::invoke" );
      try {
        /* Grab the *.jws filename from the context - should have been */
        /* placed there by another handler (ie. HTTPActionHandler)     */
        /***************************************************************/
        Runtime  rt      = Runtime.getRuntime();
        String   jwsFile = (String)msgContext.getProperty( "JWSFileName" );
        Debug.Print( 2, "jwsFile: " + jwsFile );
        String   jFile   = jwsFile.substring(0, jwsFile.length()-3) + "java" ;
        String   cFile   = jwsFile.substring(0, jwsFile.length()-3) + "class" ;
        Debug.Print( 2, "jFile: " + jFile );
        Debug.Print( 2, "cFile: " + cFile );
    
        File  f1 = new File( cFile );
        File  f2 = new File( jwsFile );
    
        /* 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               */
          /***********************************************************/
          Debug.Print(3, "copy " + 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 */
          /************************************/
          Debug.Print(2, "javac " + jFile );
          Process proc = rt.exec( "javac " + jFile );
          proc.waitFor();
  
          /* Delete the temporary *.java file and check the return code */
          /**************************************************************/
          (new File(jFile)).delete();
  
          if ( proc.exitValue() != 0 ) {
            /* 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();
            throw new AxisFault( "Server.compileError",
                                 "Error while compiling: " + jFile + 
                                 " rc=" + proc.exitValue(),
                                 null, null );
          }
        }
  
        /* Load the class */
        /******************/
        ClassLoader cl = ClassLoader.getSystemClassLoader();
        String clsName = f2.getName();
        clsName = clsName.substring( 0, clsName.length()-4 );
        Debug.Print( 2, "ClsName: " + clsName );
        Class c = cl.loadClass( clsName );
  
        /* Create a new RPCDispatchHandler - this will be the "service"   */
        /* that we invoke.                                                */
        /******************************************************************/
        RPCDispatchHandler rpc = new RPCDispatchHandler();
        msgContext.setProperty( MessageContext.SVC_HANDLER, rpc );
  
        rpc.addOption( "className", clsName );
  
        rpc.init();   // ??
        rpc.invoke( msgContext );
        rpc.cleanup();  // ??
      }
      catch( Exception e ) {
        Debug.Print( 1, e );
        if ( !(e instanceof AxisFault) ) e = new AxisFault( e );
        throw (AxisFault) e ;
      }
  
      Debug.Print( 1, "Exit : JWSProcessor::invoke" );
    }
  
    public void undo(MessageContext msgContext)
    {
      Debug.Print( 1, "Enter: JWSProcessor::undo" );
      Debug.Print( 1, "Exit: JWSProcessor::undo" );
    }
  }
  
  
  
  1.3       +1 -0      xml-axis/java/webapps/axis/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/webapps/axis/WEB-INF/web.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- web.xml	2001/02/07 14:58:49	1.2
  +++ web.xml	2001/02/20 14:24:57	1.3
  @@ -17,6 +17,7 @@
     <servlet-mapping>
       <servlet-name>AxisServlet</servlet-name>
       <url-pattern>servlet/AxisServlet</url-pattern>
  +    <url-pattern>*.jws</url-pattern>
     </servlet-mapping>
   
   </web-app>
  
  
  

Mime
View raw message