You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/10/30 12:54:12 UTC

cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot test1.txt

jstrachan    2002/10/30 03:54:12

  Modified:    jelly    project.xml
               jelly/src/java/org/apache/commons/jelly jelly.properties
               jelly/src/test/org/apache/commons/jelly/http http.jelly
  Added:       jelly/src/java/org/apache/commons/jelly/tags/jetty
                        package.html SocketListenerTag.java
                        ResponseBodyTag.java JellyResourceHandlerTag.java
                        ResponseHeaderTag.java JettyHttpServerTag.java
                        ResourceHandlerTag.java RealmTag.java
                        PutRequestTag.java NotFoundHandlerTag.java
                        PostRequestTag.java JellyResourceHttpHandler.java
                        SecurityHandlerTag.java HttpContextTag.java
                        AbstractMethodHandlerTag.java JettyTagLibrary.java
                        GetRequestTag.java DeleteRequestTag.java
               jelly/src/test/org/apache/commons/jelly/jetty
                        httpContext.jelly securityHandlerUnauthorized.jelly
                        securityHandlerForbidden.jelly
                        jellyResourceHandler.jelly resourceHandler.jelly
                        securityHandler.jelly socketListener.jelly
                        defaultServer.jelly TestJettyHttpServerTags.java
               jelly/src/test/org/apache/commons/jelly/jetty/setup
                        demoRealm.properties
               jelly/src/test/org/apache/commons/jelly/jetty/docRoot/contextTest
                        contextTest.txt
               jelly/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHandlerTest
                        resourceHandlerTest.txt
               jelly/src/test/org/apache/commons/jelly/jetty/docRoot
                        test1.txt
  Log:
  Committed patch supplied by Robert Leftwich which creates a Jetty tag library for creating HTTP servers for testing web requests using an embedded Jetty instance.
  
  It could be that there is some crossover with 
  
  Latka
  http://jakarta.apache.org/commons/latka/index.html
  
  Anteater
  http://aft.sourceforge.net/
  
  or Cactus
  http://jakarta.apache.org/cactus/
  
  I'm not personally expert enough to know what should be done in this area. So I'm committing this and then the discussion between the various groups can start. 
  It might be that one of the above projects could be a better home for the above code - lets see what the community at large thinks.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Tags for starting Jetty HTTP servers and procesing HTTP requests using Jelly scripts
    </p>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/SocketListenerTag.java
  
  Index: SocketListenerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SocketListenerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.SocketListener;
  import org.mortbay.util.InetAddrPort;
  
  /**
   * Declare a socket listener for a Jetty http server
   *
   * @author  rtl
   * @version $Id: SocketListenerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class SocketListenerTag extends TagSupport {
  
      /** parameter port with default*/
      private int _port = JettyHttpServerTag.DEFAULT_PORT;
  
      /** parameter host, with default */
      private String _host = JettyHttpServerTag.DEFAULT_HOST;
  
      /** Creates a new instance of SocketListenerTag */
      public SocketListenerTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, add a socket listener
       * for the specified host and port to the parent server,
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass(
              JettyHttpServerTag.class);
          if ( httpserver == null ) {
              throw new JellyException( "<socketListener> tag must be enclosed inside a <server> tag" );
          }
          httpserver.addListener(
              new SocketListener(new InetAddrPort(getHost(), getPort())));
          invokeBody(xmlOutput);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
      /**
       * Getter for property port.
       *
       * @return value of property port.
       */
      public int getPort() {
          return _port;
      }
  
      /**
       * Setter for property port.
       *
       * @param port New value of property port.
       */
      public void setPort(int port) {
          _port = port;
      }
  
      /**
       * Getter for property host.
       *
       * @return value of property host.
       */
      public String getHost() {
          return _host;
      }
  
      /**
       * Setter for property host.
       *
       * @param host New value of property host.
       */
      public void setHost(String host) {
          _host = host;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResponseBodyTag.java
  
  Index: ResponseBodyTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ResponseBodyTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpResponse;
  import org.mortbay.util.ByteArrayISO8859Writer;
  
  /**
   * Set the response body in a response handler for a Jetty http server
   *
   * @author  rtl
   */
  public class ResponseBodyTag extends TagSupport {
  
      /**
       * Perform the tag functionality. In this case, set the body of a
       * http response found in the jelly context
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
  
          // get the response from the context
          HttpResponse httpResponse = (HttpResponse) getContext().getVariable("response");
          if (null == httpResponse) {
              throw new JellyException("HttpResponse variable not available in Jelly context");
          }
  
          ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500);
          writer.write(getBodyText());
          writer.flush();
          httpResponse.setContentLength(writer.length());
          writer.writeTo(httpResponse.getOutputStream());
  
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JellyResourceHandlerTag.java
  
  Index: JellyResourceHandlerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * A resource handler that uses Jelly scripts to provide resources
   * to a context in a Jetty http server
   *
   * @author  rtl
   * @version $Id: JellyResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class JellyResourceHandlerTag extends TagSupport {
  
      /** The http handler that calls the body of the tag. */
      private JellyResourceHttpHandler _jellyResourceHttpHandler;
  
      /** Creates a new instance of JellyResourceHandlerTag */
      public JellyResourceHandlerTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, add an http handler
       * to the parent context that runs the script in the body of this tag
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass(
              HttpContextTag.class);
          if ( httpContext == null ) {
              throw new JellyException( "<jellyResourceHandler> tag must be enclosed inside a <httpContext> tag" );
          }
  
          _jellyResourceHttpHandler =
              new JellyResourceHttpHandler(xmlOutput);
  
          httpContext.addHandler(_jellyResourceHttpHandler);
  
          // process any child method handlers
          invokeBody(xmlOutput);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
      protected JellyResourceHttpHandler getJellyResourceHttpHandler() {
          return _jellyResourceHttpHandler;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResponseHeaderTag.java
  
  Index: ResponseHeaderTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ResponseHeaderTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpResponse;
  
  /**
   * Set a response header in the request handler of a Jetty http server
   *
   * @author  rtl
   */
  public class ResponseHeaderTag extends TagSupport {
  
      /** parameter name */
      private String _name;
  
      /** parameter value */
      private String _value;
  
      /**
       * Perform the tag functionality. In this case, set a header in the
       * http response found in the jelly context
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
  
          if (null == getName()) {
              throw new JellyException("<responseHeader> tag must have a name");
          }
  
          // get the response from the context
          HttpResponse httpResponse = (HttpResponse) getContext().getVariable("response");
          if (null == httpResponse) {
              throw new JellyException("HttpResponse variable not available in Jelly context");
          }
  
          // if value is valid then set it
          // otherwise remove the field
          if (null != getValue()) {
              httpResponse.setField(getName(), getValue());
          } else {
              httpResponse.removeField(getName());
          }
  
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
      /**
       * Getter for property context path.
       *
       * @return value of property context path.
       */
      public String getName() {
          return _name;
      }
  
      /**
       * Setter for property context path.
       *
       * @param path New value of property context path.
       */
      public void setName(String name) {
          _name = name;
      }
  
      /**
       * Getter for property value.
       *
       * @return value of property value.
       */
      public String getValue() {
          return _value;
      }
  
      /**
       * Setter for property value.
       *
       * @param value New value of property value.
       */
      public void setValue(String value) {
          _value = value;
      }
  
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JettyHttpServerTag.java
  
  Index: JettyHttpServerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JettyHttpServerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpContext;
  import org.mortbay.http.HttpListener;
  import org.mortbay.http.HttpServer;
  import org.mortbay.http.SocketListener;
  import org.mortbay.http.UserRealm;
  import org.mortbay.http.handler.NotFoundHandler;
  import org.mortbay.http.handler.ResourceHandler;
  import org.mortbay.util.Resource;
  
  import java.net.URL;
  
  /**
   * Declare an instance of a Jetty http server
   *
   * @author  rtl
   * @version $Id: JettyHttpServerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class JettyHttpServerTag extends TagSupport {
  
      /** default port to create listeners for */
      public static final int DEFAULT_PORT = 8100;
  
      /** default host to create listeners/context for */
      public static final String DEFAULT_HOST = "localhost";
  
      /** default context to create context for */
      public static final String DEFAULT_CONTEXT_PATH = "/";
  
      /** default resource base to use for context */
      public static final String DEFAULT_RESOURCE_BASE = "./docRoot";
  
      /** unique identifier of the tag/ variable to store result in */
      private String _var;
  
      /** the http server for this tag */
      private HttpServer _server;
  
      /** Creates a new instance of JettyHttpServerTag */
      public JettyHttpServerTag() {
          // Create the server
          _server=new HttpServer();
  
          // turn off alias checking in Jetty's FileResource,
          // so that we don't need exact case in resource names
          System.setProperty("org.mortbay.util.FileResource.checkAliases", "false");
      }
  
      /**
       * Perform the tag functionality. In this case, create an http server after
       * making sure that it has at least one context and associated http handler,
       * creating defaults if it doesn't
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
  
          // allow nested tags first, e.g body
          invokeBody(xmlOutput);
  
          // if no listeners create a default port listener
          if (_server.getListeners().length == 0) {
              SocketListener listener=new SocketListener();
              listener.setPort(DEFAULT_PORT);
              listener.setHost(DEFAULT_HOST);
              _server.addListener(listener);
          }
  
          // if no context/s create a default context
          if (_server.getContexts().length == 0) {
              // Create a context
              HttpContext context = _server.getContext(DEFAULT_HOST,
                                                      DEFAULT_CONTEXT_PATH);
  
              // Serve static content from the context
              URL baseResourceURL = getContext().getResource(DEFAULT_RESOURCE_BASE);
              Resource resource = Resource.newResource(baseResourceURL);
              context.setBaseResource(resource);
              _server.addContext(context);
          }
  
          // check that all the contexts have at least one handler
          // if not then add a default resource handler and a not found handler
          HttpContext[] allContexts = _server.getContexts();
          for (int i = 0; i < allContexts.length; i++) {
              HttpContext currContext = allContexts[i];
              if (currContext.getHandlers().length == 0) {
                  currContext.addHandler(new ResourceHandler());
                  currContext.addHandler(new NotFoundHandler());
              }
          }
  
          // Start the http server
          _server.start();
  
          // set variable to value if required
          if (getVar() != null) {
              getContext().setVariable(getVar(), _server);
          }
      }
  
      /**
       * Add an http listener to the server instance
       *
       * @param listener the listener to add
       */
      public void addListener(HttpListener listener) {
          _server.addListener(listener);
      }
  
      /**
       * Add an http context to the server instance
       *
       * @param context the context to add
       */
      public void addContext(HttpContext context) {
          _server.addContext(context);
      }
  
      /* ------------------------------------------------------------ */
      /**
       * Add a user authentication realm to the server instance
       *
       * @param realm the realm to add
       * @return the realm added
       */
      public UserRealm addRealm(UserRealm realm)
      {
          return _server.addRealm(realm);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
      /**
       * Getter for property var.
       *
       * @return Value of property var.
       */
      public String getVar() {
          return _var;
      }
  
      /**
       * Setter for property var.
       *
       * @param var New value of property var.
       */
      public void setVar(String var) {
          _var = var;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResourceHandlerTag.java
  
  Index: ResourceHandlerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.handler.ResourceHandler;
  
  import java.util.StringTokenizer;
  
  /**
   * Declare a static file resource handler for a Jetty http server
   *
   * @author  rtl
   * @version $Id: ResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class ResourceHandlerTag extends TagSupport {
  
      /** parameter allowed methods */
      private String _allowedMethods;
  
      /** Creates a new instance of ResourceHandlerTag */
      public ResourceHandlerTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, add a resource handler
       * to the parent context, setting the allowed methods if required
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass(
              HttpContextTag.class);
          if ( httpContext == null ) {
              throw new JellyException( "<resourceHandler> tag must be enclosed inside a <httpContext> tag" );
          }
          ResourceHandler resourceHandler = new ResourceHandler();
          if (getAllowedMethods() != null) {
              // split comma-separated list up into tokens and convert to an array
              StringTokenizer tokenizer =
                  new StringTokenizer( getAllowedMethods(), " ," );
              String[] allowedMethods = new String[tokenizer.countTokens()];
              for (int i = 0; i < allowedMethods.length; i++) {
                  allowedMethods[i] = tokenizer.nextToken();
              }
              resourceHandler.setAllowedMethods(allowedMethods);
          }
          httpContext.addHandler(resourceHandler);
          invokeBody(xmlOutput);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
      /**
       * Getter for property allowedMethods.
       *
       * @return value of property allowedMethods.
       */
      public String getAllowedMethods() {
          return _allowedMethods;
      }
  
      /**
       * Setter for property allowedMethods.
       *
       * @param allowedMethods Comma separated list of allowed methods.
       */
      public void setAllowedMethods(String allowedMethods) {
          _allowedMethods = allowedMethods;
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/RealmTag.java
  
  Index: RealmTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/RealmTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HashUserRealm;
  
  import java.net.URL;
  
  /**
   * Declare a user realm for a Jetty http server
   *
   * @author  rtl
   * @version $Id: RealmTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class RealmTag extends TagSupport {
  
      /** parameter name with default*/
      private String _name;
  
      /** parameter config, with default */
      private String _config;
  
      /** Creates a new instance of RealmTag */
      public RealmTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, add a realm with the
       * specified name using the specified config (preperties) file to the
       * parent server,
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass(
              JettyHttpServerTag.class);
          if ( httpserver == null ) {
              throw new JellyException( "<realm> tag must be enclosed inside a <server> tag" );
          }
          if (null == getName() || null == getConfig()) {
              throw new JellyException( "<realm> tag must have a name and a config" );
          }
  
          // convert the config string to a URL
          // (this makes URL's relative to the location of the script
          URL configURL = getContext().getResource(getConfig());
          httpserver.addRealm( new HashUserRealm(getName(), configURL.toString() ) );
          invokeBody(xmlOutput);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
      /**
       * Getter for property name.
       *
       * @return value of property name.
       */
      public String getName() {
          return _name;
      }
  
      /**
       * Setter for property name.
       *
       * @param name New value of property name.
       */
      public void setName(String name) {
          _name = name;
      }
  
      /**
       * Getter for property config.
       *
       * @return value of property config.
       */
      public String getConfig() {
          return _config;
      }
  
      /**
       * Setter for property config.
       *
       * @param config New value of property config.
       */
      public void setConfig(String config) {
          _config = config;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/PutRequestTag.java
  
  Index: PutRequestTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  /**
   * Respond to a PUT request to a Jetty http server
   *
   * @author  rtl
   * @version $Id: PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  /** A tag for the http PUT method */
  public class PutRequestTag extends AbstractMethodHandlerTag {
  
      /** return the name of the http method handled by this tag */
      public String getMethodHandled() {
          return "PUT";
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/NotFoundHandlerTag.java
  
  Index: NotFoundHandlerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/NotFoundHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.handler.NotFoundHandler;
  
  import java.util.StringTokenizer;
  
  /**
   * Declare a not found resource handler for a Jetty http server
   *
   * @author  rtl
   * @version $Id: NotFoundHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class NotFoundHandlerTag extends TagSupport {
  
      /** Creates a new instance of NotFoundHandlerTag */
      public NotFoundHandlerTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, add a resource handler
       * to the parent context, setting the allowed methods if required
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass(
              HttpContextTag.class);
          if ( httpContext == null ) {
              throw new JellyException( "<notFoundHandler> tag must be enclosed inside a <httpContext> tag" );
          }
          NotFoundHandler notFoundHandler = new NotFoundHandler();
          httpContext.addHandler(notFoundHandler);
          invokeBody(xmlOutput);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/PostRequestTag.java
  
  Index: PostRequestTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/PostRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  /**
   * Respond to a POST request to a Jetty http server
   *
   * @author  rtl
   * @version $Id: PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class PostRequestTag extends AbstractMethodHandlerTag {
  
      /** return the name of the http method handled by this tag */
      public String getMethodHandled() {
          return "POST";
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JellyResourceHttpHandler.java
  
  Index: JellyResourceHttpHandler.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHttpHandler.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpException;
  import org.mortbay.http.HttpRequest;
  import org.mortbay.http.HttpResponse;
  import org.mortbay.http.handler.AbstractHttpHandler;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * The actual http handler implementation for an http context in an http server
   *
   * @author  rtl
   * @version $Id: JellyResourceHttpHandler.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  class JellyResourceHttpHandler extends AbstractHttpHandler {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(JellyResourceHttpHandler.class);
  
      /** The name of the var to check if setHandled should not be set to true . */
      private static final String OVERRIDE_SET_HANDLED_VAR = "overrideSetHandled";
  
      /** The list of  tags registered to handle a request method  */
      private Map _tagMap;
  
      /** The place where to output the results of the tag body */
      private XMLOutput _xmlOutput;
  
      /** Creates a new instance of JellyResourceHttpHandler */
      public JellyResourceHttpHandler( XMLOutput xmlOutput ) {
          _tagMap = new HashMap();
          _xmlOutput = xmlOutput;
      }
  
      /*
       * register this tag as the handler for the specified method
       *
       * @param tag the tag to be registered
       * @param method the name of the http method which this tag processes
       */
      public void registerTag(Tag tag, String method){
          _tagMap.put(method.toLowerCase(), tag);
      }
  
      /*
       * handle an http request
       *
       * @param pathInContext the path of the http request
       * @param pathParams the parameters (if any) of the http request
       * @param request the actual http request
       * @param response the place for any response
       *
       * @throws HttpException when an error occurs
       * @throws IOException when an error occurs
       */
      public void handle(String pathInContext,
                         String pathParams,
                         HttpRequest request,
                         HttpResponse response)
          throws HttpException, IOException
      {
          Tag handlerTag = (Tag) _tagMap.get(request.getMethod().toLowerCase());
          if (null != handlerTag) {
              // setup the parameters in the jelly context
              JellyContext jellyContext = handlerTag.getContext();
              jellyContext.setVariable( "pathInContext", pathInContext);
              jellyContext.setVariable( "pathParams", pathParams);
              jellyContext.setVariable( "request", request);
              jellyContext.setVariable( "response", response);
  
              try {
                  handlerTag.invokeBody(_xmlOutput);
                  // only call set handled if tag has not requested an override
                  // if it has requested an override then reset the request
                  if (null == jellyContext.getVariable(OVERRIDE_SET_HANDLED_VAR)) {
                      request.setHandled(true);
                  } else {
                      jellyContext.removeVariable(OVERRIDE_SET_HANDLED_VAR);
                  }
              } catch (Exception ex ) {
                  throw new HttpException(HttpResponse.__500_Internal_Server_Error,
                                          "Error invoking method handler tag: " + ex.getLocalizedMessage());
              }
          } else {
              log.info("No handler for request:" +
                        request.getMethod() + " path:" +
                        response.getHttpContext().getContextPath() +
                        pathInContext);
          }
  
          return;
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/SecurityHandlerTag.java
  
  Index: SecurityHandlerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SecurityHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.BasicAuthenticator;
  import org.mortbay.http.ClientCertAuthenticator;
  import org.mortbay.http.DigestAuthenticator;
  import org.mortbay.http.SecurityConstraint.Authenticator;
  import org.mortbay.http.SecurityConstraint;
  import org.mortbay.http.handler.SecurityHandler;
  import org.mortbay.jetty.servlet.FormAuthenticator;
  import org.mortbay.util.Code;
  import org.mortbay.xml.XmlParser;
  
  import org.xml.sax.InputSource;
  
  import java.io.StringReader;
  import java.util.Iterator;
  
  /**
   * Declare a security handler for a Jetty http server
   *
   * @author  rtl
   * @version $Id: SecurityHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class SecurityHandlerTag extends TagSupport {
  
      /** a form authenticator used by this tag */
      private transient FormAuthenticator _formAuthenticator;
  
      /** parameter authentication method, defaults to BASIC in Jetty */
      private String _authenticationMethod;
  
      /** Creates a new instance of SecurityHandlerTag */
      public SecurityHandlerTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, add a security handler
       * to the parent context, setting the authentication method if required
       * The security constraints should be specified as the body of this tag
       * using the same format as a web.xml file wrapped in a single
       * <constraints> tag to allow parsing of a well-formed snippet, e.g.
       *
       * <constraints>
       *   <security-constraint>
       *    <web-resource-collection>
       *     <web-resource-name>Default</web-resource-name>
       *      <url-pattern>/</url-pattern>
       *    </web-resource-collection>
       *    <auth-constraint/>
       *   </security-constraint>
       *
       *   <security-constraint>
       *     <web-resource-collection>
       *       <url-pattern>/docRoot/resourceHandlerTest/*</url-pattern>
       *       <http-method>GET</http-method>
       *       <http-method>HEAD</http-method>
       *     </web-resource-collection>
       *     <auth-constraint>
       *       <role-name>*</role-name>
       *     </auth-constraint>
       *   </security-constraint>
       *
       *   <login-config>
       *     <auth-method>BASIC</auth-method>
       *     <realm-name>Jetty Demo Realm</realm-name>
       *   </login-config>
       *
       * </constraints>
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass(
              HttpContextTag.class);
          if ( httpContext == null ) {
              throw new JellyException( "<securityHandler> tag must be enclosed inside a <httpContext> tag" );
          }
          SecurityHandler securityHandler = new SecurityHandler();
          if (getauthenticationMethod() != null) {
              securityHandler.setAuthMethod(getauthenticationMethod());
          }
          httpContext.addHandler(securityHandler);
  
          // get the security constraints from the body of this tag
          // by parsing the body of the parent (so it will be well formed)
          String bodyText = getBodyText();
          StringReader reader = new StringReader(bodyText);
          InputSource inputSource = new InputSource(reader);
  
          // crate a non-validating parser
          XmlParser xmlParser = new XmlParser(false);
  
          XmlParser.Node node = xmlParser.parse(inputSource);
  
          Iterator iter=node.iterator();
          XmlParser.Node currNode = null;
          while (iter.hasNext())
          {
                  Object o = iter.next();
                  if (!(o instanceof XmlParser.Node))
                      continue;
  
                  currNode=(XmlParser.Node)o;
                  String name=currNode.getTag();
  
                  if ("security-constraint".equals(name)) {
                      initSecurityConstraint(currNode, httpContext);
                  } else if ("login-config".equals(name)) {
                      initLoginConfig(currNode, httpContext);
                  } else {
                      throw new JellyException("Invalid element in <securityHandler> tag. Are you using the <constraints> tag?: " + currNode);
                  }
          }
  
      }
  
      /* ------------------------------------------------------------
       * This is the code from Jetty's WebApplicationContext
       * with the HttpContextTag parameter added
       *
       * Process a parsed xml node to setup the security constraints
       * for an http server
       *
       * @param node the parsed xml starting node of the constraints
       * @param httpContext the tag to add the security constraint to
      */
      protected void initSecurityConstraint(XmlParser.Node node,
                                            HttpContextTag httpContext)
      {
          SecurityConstraint scBase = new SecurityConstraint();
  
          XmlParser.Node auths=node.get("auth-constraint");
          if (auths!=null)
          {
              scBase.setAuthenticate(true);
              // auth-constraint
              Iterator iter= auths.iterator("role-name");
              while(iter.hasNext())
              {
                  String role=((XmlParser.Node)iter.next()).toString(false,true);
                  scBase.addRole(role);
              }
          }
  
          XmlParser.Node data=node.get("user-data-constraint");
          if (data!=null)
          {
              data=data.get("transport-guarantee");
              String guarantee = data.toString(false,true).toUpperCase();
              if (guarantee==null || guarantee.length()==0 ||
                  "NONE".equals(guarantee))
                  scBase.setDataConstraint(scBase.DC_NONE);
              else if ("INTEGRAL".equals(guarantee))
                  scBase.setDataConstraint(scBase.DC_INTEGRAL);
              else if ("CONFIDENTIAL".equals(guarantee))
                  scBase.setDataConstraint(scBase.DC_CONFIDENTIAL);
              else
              {
                  Code.warning("Unknown user-data-constraint:"+guarantee);
                  scBase.setDataConstraint(scBase.DC_CONFIDENTIAL);
              }
          }
  
          Iterator iter= node.iterator("web-resource-collection");
          while(iter.hasNext())
          {
              XmlParser.Node collection=(XmlParser.Node)iter.next();
              String name=collection.getString("web-resource-name",false,true);
              SecurityConstraint sc = (SecurityConstraint)scBase.clone();
              sc.setName(name);
  
              Iterator iter2= collection.iterator("http-method");
              while(iter2.hasNext())
                  sc.addMethod(((XmlParser.Node)iter2.next())
                               .toString(false,true));
  
              iter2= collection.iterator("url-pattern");
              while(iter2.hasNext())
              {
                  String url=
                      ((XmlParser.Node)iter2.next()).toString(false,true);
                  httpContext.addSecurityConstraint(url,sc);
              }
          }
      }
  
      /* ------------------------------------------------------------
       * This is the code from Jetty's WebApplicationContext
       * with the HttpContextTag parameter added
       *
       *
       * Process a parsed xml node to setup the authenticator and realm
       * for an http server
       *
       * @param node the parsed xml starting node of the login configuration
       * @param httpContext the tag to add the authenticator and realm to
      */
      protected void initLoginConfig(XmlParser.Node node,
                                     HttpContextTag httpContext)
      {
          XmlParser.Node method=node.get("auth-method");
          if (method!=null)
          {
              Authenticator authenticator=null;
              String m=method.toString(false,true);
  
              if (SecurityConstraint.__FORM_AUTH.equals(m))
                  authenticator=_formAuthenticator=new FormAuthenticator();
              else if (SecurityConstraint.__BASIC_AUTH.equals(m))
                  authenticator=new BasicAuthenticator();
              else if (SecurityConstraint.__DIGEST_AUTH.equals(m))
                  authenticator=new DigestAuthenticator();
              else if (SecurityConstraint.__CERT_AUTH.equals(m))
                  authenticator=new ClientCertAuthenticator();
              else
                  Code.warning("UNKNOWN AUTH METHOD: "+m);
  
              httpContext.setAuthenticator(authenticator);
          }
  
          XmlParser.Node name=node.get("realm-name");
          if (name!=null)
              httpContext.setRealmName(name.toString(false,true));
  
          XmlParser.Node formConfig = node.get("form-login-config");
          if(formConfig != null)
          {
              if (_formAuthenticator==null)
                  Code.warning("FORM Authentication miss-configured");
              else
              {
                  XmlParser.Node loginPage = formConfig.get("form-login-page");
                  if (loginPage != null)
                      _formAuthenticator.setLoginPage(loginPage.toString(false,true));
                  XmlParser.Node errorPage = formConfig.get("form-error-page");
                  if (errorPage != null)
                      _formAuthenticator.setErrorPage(errorPage.toString(false,true));
              }
          }
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
  
      /**
       * Getter for property authenticationMethod.
       *
       * @return value of property authenticationMethod.
       */
      public String getauthenticationMethod() {
          return _authenticationMethod;
      }
  
      /**
       * Setter for property authenticationMethod.
       *
       * @param authenticationMethod Type of authentication (BASIC, FORM, DIGEST, CLIENT-CERT)
       * Note that only BASIC and CLIENT-CERT are supported by Jetty as of v4.1.1
       */
      public void setauthenticationMethod(String authenticationMethod) {
          _authenticationMethod = authenticationMethod;
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/HttpContextTag.java
  
  Index: HttpContextTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/HttpContextTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpContext;
  import org.mortbay.http.HttpHandler;
  import org.mortbay.http.SecurityConstraint;
  import org.mortbay.http.SecurityConstraint.Authenticator;
  import org.mortbay.util.Resource;
  
  import java.net.URL;
  
  /**
   * Declare a context for a Jetty http server
   *
   * @author  rtl
   * @version $Id: HttpContextTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class HttpContextTag extends TagSupport {
  
      /** parameter path with default*/
      private String _contextPath = JettyHttpServerTag.DEFAULT_CONTEXT_PATH;
  
      /** parameter resourceBase, with default */
      private String _resourceBase = JettyHttpServerTag.DEFAULT_RESOURCE_BASE;
  
      /** parameter realmName*/
      private String _realmName;
  
      /** the actual context this tag refers to */
      private HttpContext _context;
  
      /** Creates a new instance of HttpContextTag */
      public HttpContextTag() {
          // create an actual context for this tag
          _context = new HttpContext();
      }
  
      /**
       * Perform the tag functionality. In this case, setup the context path
       * and resource base before adding the context to the parent server
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
  
          JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass(
              JettyHttpServerTag.class);
          if ( httpserver == null ) {
              throw new JellyException( "<httpContext> tag must be enclosed inside a <server> tag" );
          }
  
          // allow nested tags first, e.g body
          invokeBody(xmlOutput);
  
          _context.setContextPath(getContextPath());
  
          // convert the resource string to a URL
          // (this makes URL's relative to the location of the script
          URL baseResourceURL = getContext().getResource(getResourceBase());
          _context.setBaseResource(Resource.newResource(baseResourceURL));
          if (null != getRealmName()) {
              _context.setRealmName(getRealmName());
          }
          httpserver.addContext(_context);
  
      }
  
      /**
       * Add an http handler to the context instance
       *
       * @param handler the handler to add
       */
      public void addHandler(HttpHandler httHandler) {
          _context.addHandler(httHandler);
      }
  
      /**
       * Add a security constraint for the specified path specification
       * to the context instance
       *
       * @param pathSpec the path specification for the security constraint
       * @param sc the security constraint to add
       */
      public void addSecurityConstraint(String pathSpec, SecurityConstraint sc) {
          _context.addSecurityConstraint(pathSpec, sc);
      }
  
      /**
       * Add an authenticator to the context instance
       *
       * @param authenticator the authenticator to add
       */
      public void setAuthenticator(Authenticator authenticator)
      {
          _context.setAuthenticator(authenticator);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
      /**
       * Getter for property context path.
       *
       * @return value of property context path.
       */
      public String getContextPath() {
          return _contextPath;
      }
  
      /**
       * Setter for property context path.
       *
       * @param path New resourceBase of property context path.
       */
      public void setContextPath(String contextPath) {
          _contextPath = contextPath;
      }
  
      /**
       * Getter for property resourceBase.
       *
       * @return value of property resourceBase.
       */
      public String getResourceBase() {
          return _resourceBase;
      }
  
      /**
       * Setter for property resourceBase.
       *
       * @param resourceBase New value of property resourceBase.
       */
      public void setResourceBase(String resourceBase) {
          _resourceBase = resourceBase;
      }
  
      /**
       * Getter for property realm name.
       *
       * @return value of property realm name.
       */
      public String getRealmName() {
          return _realmName;
      }
  
      /**
       * Setter for property context path.
       *
       * @param path New resourceBase of property context path.
       */
      public void setRealmName(String realmName) {
          _realmName = realmName;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/AbstractMethodHandlerTag.java
  
  Index: AbstractMethodHandlerTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpResponse;
  
  /**
   * An abstract base tag to declare a handler for a particular request method
   * in an http context in an http server
   *
   * @author  rtl
   * @version $Id: AbstractMethodHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  abstract public class AbstractMethodHandlerTag extends TagSupport {
  
      /** Override this to return the name of the http method handled by this tag */
      abstract public String getMethodHandled();
  
      /**
       * Perform the tag functionality. In this case, add a http method handler
       * to the parent that invokes the script in the body of this tag when
       * processing an http request
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          JellyResourceHandlerTag parentTag =
              (JellyResourceHandlerTag) findAncestorWithClass(
                  JellyResourceHandlerTag.class);
  
          if ( parentTag == null ) {
              throw new JellyException( "<" + getMethodHandled().toLowerCase() +
                                        "Request> tag must be enclosed inside a <jellyResourceHandler> tag" );
          }
  
          // register this tag with the http handler for the appropriate method
          parentTag.getJellyResourceHttpHandler().registerTag(this, getMethodHandled());
  
          // NOTE - don't invokeBody here as we only want to do it during a request
      }
  
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JettyTagLibrary.java
  
  Index: JettyTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JettyTagLibrary.java,v 1.1 2002/07/14 13:05:14 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/14 13:05:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import java.util.Map;
  
  import org.apache.commons.jelly.TagLibrary;
  
  /**
   * A set of jelly tags for instantiating a Jetty HTTP server
   *
   * @author rtl
   * @version $Id: JettyTagLibrary.java,v 1.1 2002/07/14 13:05:14 dion Exp $
   */
  public class JettyTagLibrary extends TagLibrary {
  
      /**
       * Creates a new instance of LatkaTagLibrary
       */
      public JettyTagLibrary() {
  
          registerTag("jettyHttpServer", JettyHttpServerTag.class);
          registerTag("socketListener", SocketListenerTag.class);
          registerTag("realm", RealmTag.class);
          registerTag("httpContext", HttpContextTag.class);
          registerTag("resourceHandler", ResourceHandlerTag.class);
          registerTag("notFoundHandler", NotFoundHandlerTag.class);
          registerTag("securityHandler", SecurityHandlerTag.class);
  
          registerTag("jellyResourceHandler", JellyResourceHandlerTag.class);
          registerTag("getRequest", GetRequestTag.class);
          registerTag("postRequest", PostRequestTag.class);
          registerTag("putRequest", PutRequestTag.class);
          registerTag("deleteRequest", DeleteRequestTag.class);
          registerTag("responseHeader", ResponseHeaderTag.class);
          registerTag("responseBody", ResponseBodyTag.class);
      }
  
      /**
       * @see TagLibarary#getTagClasses()
       *
       * @return a Map of tag name to tag class
       */
      public Map getTagClasses() {
          return super.getTagClasses();
      }
  
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/GetRequestTag.java
  
  Index: GetRequestTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/GetRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  /**
   * Respond to a GET request to a Jetty http server
   *
   * @author  rtl
   * @version $Id: PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class GetRequestTag extends AbstractMethodHandlerTag {
  
      /** return the name of the http method handled by this tag */
      public String getMethodHandled() {
          return "GET";
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/DeleteRequestTag.java
  
  Index: DeleteRequestTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/DeleteRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.commons.jelly.tags.jetty;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.mortbay.http.HttpResponse;
  
  /**
   * Respond to a DELETE request to a Jetty http server
   *
   * @author  rtl
   * @version $Id: DeleteRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class DeleteRequestTag extends AbstractMethodHandlerTag {
  
      /** return the name of the http method handled by this tag */
      public String getMethodHandled() {
          return "DELETE";
      }
  }
  
  
  
  
  1.84      +6 -0      jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- project.xml	23 Oct 2002 11:00:31 -0000	1.83
  +++ project.xml	30 Oct 2002 11:54:11 -0000	1.84
  @@ -345,6 +345,12 @@
         <version>SNAPSHOT</version>
       </dependency>
       
  +    <!-- http server taglib -->
  +    <dependency>
  +      <id>jetty</id>
  +      <version>4.1-rc6</version>
  +    </dependency>
  +    
   	<!-- jms taglib -->
       <dependency>
         <id>commons-messenger</id>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/httpContext.jelly
  
  Index: httpContext.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value="/contextTest"/>
      <j:set var="testPort" value="8100"/>
      <j:set var="testUri" value="http://localhost:${testPort}${contextPathVar}/contextTest.txt"/>
  
      <jettyHttpServer var="httpServer">
        <socketListener port="${testPort}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/contextTest"/>
      </jettyHttpServer>
  
      <http:get var="mtc" uri="${testUri}"/>
  
      <j:if test='${mtc.statusCode == 200}'>
          ${mtc.responseBodyAsString}
      </j:if>
      <j:if test='${mtc.statusCode != 200}'>
          Results for mtc url are:
          http return code = ${mtc.statusCode}
          http status text = '${mtc.statusText}'
          size of result = ${mtc.responseBodyAsString.length()}
          response time = ${mtc.responseTime}
  
              <j:forEach items="${mtc.responseHeaders}" var="header" indexVar="i">
                  header[${i}] = ${header}
              </j:forEach>
      </j:if>
      ${httpServer.stop(false)}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/securityHandlerUnauthorized.jelly
  
  Index: securityHandlerUnauthorized.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value="/resourceHandlerTest"/>
      <j:set var="testPort" value="8100"/>
      <j:set var="testUri" value="http://localhost:${testPort}${contextPathVar}/resourceHandlerTest.txt"/>
  
      <jettyHttpServer var="httpServerUnauthorized">
        <socketListener port="${testPort}"/>
        <realm name="Demo Realm" config="setup/demoRealm.properties"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest" realmName="Demo Realm">
            <securityHandler>
              <constraints>
  
                <security-constraint>
                  <web-resource-collection>
                   <web-resource-name>Default</web-resource-name>
                    <url-pattern>/</url-pattern>
                  </web-resource-collection>
                  <auth-constraint>
                    <role-name>*</role-name>
                  </auth-constraint>
                </security-constraint>
  
                <login-config>
                  <auth-method>BASIC</auth-method>
                  <realm-name>Demo Realm</realm-name>
                </login-config>
  
              </constraints>
            </securityHandler>
  
            <resourceHandler/>
        </httpContext>
      </jettyHttpServer>
  
      <!-- get with no authentication should fail with Unauthorized -->
      <http:get var="mtc1" uri="${testUri}"/>
  
      <j:choose>
        <j:when test="${mtc1.statusCode == 401}">
            <!-- get with authentication in controlled area should work-->
            <http:get var="mtc2" uri="${testUri}">
               <http:header name="Authorization" value="Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="/>
            </http:get>
            <j:choose>
                <j:when test="${mtc2.statusCode == 200}">
                    It works!
                </j:when>
                <j:otherwise>
                  Results for mtc2 url are:
                  http return code = ${mtc2.statusCode}
                  http status text = '${mtc2.statusText}'
                </j:otherwise>
            </j:choose>
        </j:when>
  
        <j:otherwise>
          Results for mtc1 url are:
          http return code = ${mtc1.statusCode}
          http status text = '${mtc1.statusText}'
        </j:otherwise>
      </j:choose>
      ${httpServerUnauthorized.stop(false)}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/securityHandlerForbidden.jelly
  
  Index: securityHandlerForbidden.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value="/"/>
      <j:set var="testPort" value="8100"/>
      <j:set var="forbiddenUri" value="http://localhost:${testPort}/noaccess"/>
  
      <jettyHttpServer var="httpServerForbidden">
        <socketListener port="${testPort}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot">
            <securityHandler>
              <constraints>
  
                <security-constraint>
                  <web-resource-collection>
                    <web-resource-name>Forbidden</web-resource-name>
                    <url-pattern>/*</url-pattern>
                  </web-resource-collection>
                  <auth-constraint>
                  </auth-constraint>
                </security-constraint>
  
              </constraints>
            </securityHandler>
  
            <resourceHandler/>
        </httpContext>
      </jettyHttpServer>
  
      <!-- get should always be forbidden -->
      <http:get var="mtc" uri="${forbiddenUri}"/>
  
      <j:choose>
        <j:when test="${mtc.statusCode == 403}">
            It works!
        </j:when>
  
        <j:otherwise>
          Results for mtc url are:
          http return code = ${mtc.statusCode}
          http status text = '${mtc.statusText}'
        </j:otherwise>
      </j:choose>
      ${httpServerForbidden.stop(false)}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/jellyResourceHandler.jelly
  
  Index: jellyResourceHandler.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value="/resourceHandlerTest"/>
      <j:set var="testPort1" value="8100"/>
      <j:set var="testPort2" value="8200"/>
      <j:set var="testUri1" value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTest.txt"/>
      <j:set var="testUri2" value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTest.txt"/>
  
      <jettyHttpServer var="httpServerNoOp">
        <socketListener port="${testPort1}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest">
            <jellyResourceHandler/>
        </httpContext>
      </jettyHttpServer>
  
      <jettyHttpServer var="httpServerOp">
        <socketListener port="${testPort2}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest">
            <jellyResourceHandler>
  
              <getRequest>
                  <j:set var="new.content.type" value="text/plain"/>
                  <j:set var="new.location" value="new location"/>
  
                  <responseHeader name="Content-Type" value="${new.content.type}"/>
                  <responseHeader name="Location" value="${new.location}"/>
                  <responseBody>
                      It works!
                  </responseBody>
  
              </getRequest>
  
            </jellyResourceHandler>
        </httpContext>
      </jettyHttpServer>
  
      <http:get var="mtc1" uri="${testUri1}"/>
      <j:choose>
        <j:when test="${mtc1.statusCode == 404}">
            <http:get var="mtc2" uri="${testUri2}"/>
            <j:choose>
                <j:when test="${mtc2.statusCode == 200}">
                  It works!
                </j:when>
                <j:otherwise>
                  Results for mtc2 url are:
                  http return code = ${mtc2.statusCode}
                  http status text = '${mtc2.statusText}'
                  Content-Type = ${mtc2.getResponseHeader("Content-Type")}
                  Location = ${mtc2.getResponseHeader("Location")}
                </j:otherwise>
              </j:choose>
        </j:when>
  
        <j:otherwise>
          Results for mtc1 url are:
          http return code = ${mtc1.statusCode}
          http status text = '${mtc1.statusText}'
        </j:otherwise>
      </j:choose>
  
      ${httpServerNoOp.stop(false)}
      ${httpServerOp.stop(false)}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/resourceHandler.jelly
  
  Index: resourceHandler.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value="/resourceHandlerTest"/>
      <j:set var="testPort1" value="8100"/>
      <j:set var="testPort2" value="8200"/>
      <j:set var="testUri" value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTest.txt"/>
      <j:set var="bogusUri" value="http://localhost:${testPort1}${contextPathVar}/zzz"/>
      <j:set var="testUriHeadOnly" value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTest.txt"/>
  
      <jettyHttpServer var="httpServerDefault">
        <socketListener port="${testPort1}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest">
            <resourceHandler/>
        </httpContext>
      </jettyHttpServer>
  
      <jettyHttpServer var="httpServerHeadOnly">
        <socketListener port="${testPort2}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest">
            <resourceHandler allowedMethods="OPTIONS,DELETE, HEAD"/>
        </httpContext>
      </jettyHttpServer>
  
      <http:get var="mtc1" uri="${testUri}"/>
  
      <!-- if get to default works and bogus uri returns 404
           and a head request to the head only resource handler works
           when a get fails then all is ok -->
      <j:if test='${mtc1.statusCode == 200}'>
          <http:get var="mtc2" uri="${bogusUri}"/>
          <j:if test='${mtc2.statusCode == 404}'>
              <http:head var="mtc3" uri="${testUriHeadOnly}"/>
              <j:if test='${mtc3.statusCode == 200}'>
                  <http:get var="mtc4" uri="${testUriHeadOnly}"/>
                  <j:if test='${mtc4.statusCode == 405}'>
                      It works!
                  </j:if>
              </j:if>
          </j:if>
          <j:if test='${mtc2.statusCode != 404}'>
              Results for mtc2 url are:
              http return code = ${mtc2.statusCode}
              http status text = '${mtc2.statusText}'
              size of result = ${mtc2.responseBodyAsString.length()}
              response time = ${mtc2.responseTime}
  
                  <j:forEach items="${mtc2.responseHeaders}" var="header" indexVar="i">
                      header[${i}] = ${header}
                  </j:forEach>
          </j:if>
      </j:if>
      <j:if test='${mtc1.statusCode != 200}'>
          Results for mtc1 url are:
          http return code = ${mtc1.statusCode}
          http status text = '${mtc1.statusText}'
          size of result = ${mtc1.responseBodyAsString.length()}
          response time = ${mtc1.responseTime}
  
              <j:forEach items="${mtc1.responseHeaders}" var="header" indexVar="i">
                  header[${i}] = ${header}
              </j:forEach>
      </j:if>
      ${httpServerHeadOnly.stop(false)}
      ${httpServerDefault.stop(false)}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/securityHandler.jelly
  
  Index: securityHandler.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value="/resourceHandlerTest"/>
      <j:set var="testPort1" value="8100"/>
      <j:set var="testPort2" value="8200"/>
      <j:set var="testUri1" value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTest.txt"/>
      <j:set var="testUri2" value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTest.txt"/>
  
      <jettyHttpServer var="httpServerNoAccess">
        <socketListener port="${testPort1}"/>
        <realm name="Demo Realm" config="setup/demoRealm.properties"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest" realmName="Demo Realm">
            <securityHandler>
              <constraints>
  
                <security-constraint>
                  <web-resource-collection>
                   <web-resource-name>Default</web-resource-name>
                    <url-pattern>/</url-pattern>
                  </web-resource-collection>
                  <auth-constraint>
                    <role-name>*</role-name>
                  </auth-constraint>
                </security-constraint>
  
                <login-config>
                  <auth-method>BASIC</auth-method>
                  <realm-name>Demo Realm</realm-name>
                </login-config>
  
              </constraints>
            </securityHandler>
  
            <resourceHandler/>
        </httpContext>
      </jettyHttpServer>
  
      <jettyHttpServer var="httpServerAllowAccess">
        <socketListener port="${testPort2}"/>
        <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest">
            <securityHandler>
              <constraints>
  
                <security-constraint>
                  <web-resource-collection>
                   <web-resource-name>Resource Handler Test</web-resource-name>
                    <url-pattern>/resourceHandlerTest/*</url-pattern>
                    <http-method>GET</http-method>
                    <http-method>HEAD</http-method>
                  </web-resource-collection>
                </security-constraint>
  
                <security-constraint>
                  <web-resource-collection>
                   <web-resource-name>Default</web-resource-name>
                    <url-pattern>/</url-pattern>
                  </web-resource-collection>
                  <auth-constraint/>
                </security-constraint>
  
              </constraints>
            </securityHandler>
  
            <resourceHandler/>
        </httpContext>
      </jettyHttpServer>
  
      <!-- get with no authentication should fail-->
      <http:get var="mtc1" uri="${testUri1}"/>
  
      <j:choose>
        <j:when test="${mtc1.statusCode == 403}">
            <!-- get with no authentication in allowed area should work-->
            <http:get var="mtc2" uri="${testUri2}"/>
            <j:choose>
                <j:when test="${mtc2.statusCode == 200}">
                    <!-- get with authentication in controlled area should work-->
                    <http:get var="mtc3" uri="${testUri1}">
                       <http:header name="Authorization" value="Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="/>
                    </http:get>
                    <j:choose>
                        <j:when test="${mtc3.statusCode == 200}">
                            It works!
                        </j:when>
                        <j:otherwise>
                          Results for mtc3 url are:
                          http return code = ${mtc3.statusCode}
                          http status text = '${mtc3.statusText}'
                        </j:otherwise>
                    </j:choose>
                </j:when>
  
                <j:otherwise>
                  Results for mtc2 url are:
                  http return code = ${mtc2.statusCode}
                  http status text = '${mtc2.statusText}'
                </j:otherwise>
            </j:choose>
  
        </j:when>
  
        <j:otherwise>
          Results for mtc1 url are:
          http return code = ${mtc1.statusCode}
          http status text = '${mtc1.statusText}'
        </j:otherwise>
      </j:choose>
      ${httpServerAllowAccess.stop(false)}
      ${httpServerNoAccess.stop(false)}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/socketListener.jelly
  
  Index: socketListener.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns:http="jelly:http"
      xmlns="jelly:jetty"
      trim="false">
  
      <j:set var="contextPathVar" value=""/>
      <j:set var="testPort1" value="8100"/>
      <j:set var="testPort2" value="8200"/>
      <j:set var="testUri1" value="http://localhost:${testPort1}${contextPathVar}/test1.txt"/>
      <j:set var="testUri2" value="http://localhost:${testPort2}${contextPathVar}/test1.txt"/>
  
      <jettyHttpServer var="httpServer1">
        <socketListener/>
      </jettyHttpServer>
  
      <jettyHttpServer var="httpServer2">
        <socketListener port="${testPort2}"/>
      </jettyHttpServer>
  
      <http:get var="mtc1" uri="${testUri1}"/>
      <http:get var="mtc2" uri="${testUri2}"/>
  
      <j:if test='${mtc1.statusCode == 200}'>
          <j:if test='${mtc2.statusCode == 200}'>
              <j:if test='${mtc2.responseBodyAsString == mtc1.responseBodyAsString}'>
                  ${mtc2.responseBodyAsString}
              </j:if>
          </j:if>
      </j:if>
      <j:if test='${mtc1.statusCode != 200}'>
          Results for mtc1 url are:
          http return code = ${mtc1.statusCode}
          http status text = '${mtc1.statusText}'
          size of result = ${mtc1.responseBodyAsString.length()}
          response time = ${mtc1.responseTime}
  
              <j:forEach items="${mtc1.responseHeaders}" var="header" indexVar="i">
                  header[${i}] = ${header}
              </j:forEach>
      </j:if>
      <j:if test='${mtc2.statusCode != 200}'>
          Results for mtc2 url are:
          http return code = ${mtc2.statusCode}
          http status text = '${mtc2.statusText}'
          size of result = ${mtc2.responseBodyAsString.length()}
          response time = ${mtc2.responseTime}
  
              <j:forEach items="${mtc2.responseHeaders}" var="header" indexVar="i">
                  header[${i}] = ${header}
              </j:forEach>
      </j:if>
      ${httpServer2.stop()}
      ${httpServer1.stop()}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/defaultServer.jelly
  
  Index: defaultServer.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly
      xmlns:j="jelly:core"
      xmlns="jelly:jetty"
      xmlns:http="jelly:http"
      trim="false">
  
      <j:set var="contextPathVar" value=""/>
      <j:set var="testPort" value="8100"/>
      <j:set var="testUri" value="http://localhost:${testPort}${contextPathVar}/test1.txt"/>
  
      <jettyHttpServer var="httpServer"/>
  
      <http:get var="mtc" uri="${testUri}"/>
      <j:if test='${mtc.statusCode == 200}'>
          ${mtc.responseBodyAsString}
      </j:if>
      <j:if test='${mtc.statusCode != 200}'>
          Results for mtc url are:
          http return code = ${mtc.statusCode}
          http status text = '${mtc.statusText}'
          size of result = ${mtc.responseBodyAsString.length()}
          response time = ${mtc.responseTime}
  
              <j:forEach items="${mtc.responseHeaders}" var="header" indexVar="i">
                  header[${i}] = ${header}
              </j:forEach>
      </j:if>
      ${httpServer.stop()}
  
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/TestJettyHttpServerTags.java
  
  Index: TestJettyHttpServerTags.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestJettyHttpServerTags.java,v 1.6 2002/05/15 07:47:50 jstrachan Exp $
   * $Revision: 1.6 $
   * $Date: 2002/05/15 07:47:50 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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/>.
   *
   * $Id: TestJettyHttpServerTags.java,v 1.6 2002/05/15 07:47:50 jstrachan Exp $
   */
  package org.apache.commons.jelly.jetty;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.StringWriter;
  import java.util.Iterator;
  import java.util.List;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.parser.XMLParser;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.dom4j.Document;
  import org.dom4j.DocumentHelper;
  import org.dom4j.Node;
  
  /** Tests the parser, the engine and the XML tags
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.6 $
    */
  public class TestJettyHttpServerTags extends TestCase {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(TestJettyHttpServerTags.class);
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      public static Test suite() {
          return new TestSuite(TestJettyHttpServerTags.class);
      }
  
      public TestJettyHttpServerTags(String testName) {
          super(testName);
      }
  
      public void testDefaultServer() throws Exception {
          String text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/defaultServer.jelly"
          );
          assertEquals("Produces the correct output", "It works!", text);
      }
  
      public void testSocketListener() throws Exception {
          String text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/socketListener.jelly"
          );
          assertEquals("Produces the correct output", "It works!", text);
      }
  
      public void testHttpContext() throws Exception {
          String text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/httpContext.jelly"
          );
          assertEquals("Produces the correct output", "It works!", text);
      }
  
      public void testResourceHandler() throws Exception {
          String text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/resourceHandler.jelly"
          );
          assertEquals("Produces the correct output", "It works!", text);
      }
  
      public void testSecurityHandler() throws Exception {
          String text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/securityHandlerForbidden.jelly"
          );
          assertEquals("Forbidden test produces the correct output", "It works!", text);
  
          text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/securityHandlerUnauthorized.jelly"
          );
          assertEquals("Unauthorized produces the correct output", "It works!", text);
      }
  
      public void testJellyResourceHandler() throws Exception {
          String text = evaluteScriptAsText(
              "src/test/org/apache/commons/jelly//jetty/jellyResourceHandler.jelly"
          );
          assertEquals("Produces the correct output", "It works!", text);
      }
  
      /**
       * Evaluates the script by the given file name and
       * returns the whitespace trimmed output as text
       */
      protected String evaluteScriptAsText(String fileName) throws Exception {
          JellyContext context = new JellyContext();
  
          // allow scripts to refer to any resource inside this project
          // using an absolute URI like /src/test/org/apache/foo.xml
          context.setRootURL(new File(".").toURL());
  
          // cature the output
          StringWriter buffer = new StringWriter();
          XMLOutput output = XMLOutput.createXMLOutput(buffer);
  
          context.runScript( new File(fileName), output );
          String text = buffer.toString().trim();
          if (log.isDebugEnabled()) {
              log.debug("Evaluated script as...");
              log.debug(text);
          }
          return text;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/setup/demoRealm.properties
  
  Index: demoRealm.properties
  ===================================================================
  #
  # This file defines users passwords and roles for a HashUserRealm
  #
  # The format is
  #  <username>: <password>[,<rolename> ...]
  #
  # Passwords may be clear text, obfuscated or checksummed.  The class
  # com.mortbay.Util.Password should be used to generate obfuscated
  # passwords or password checksums
  #
  # If DIGEST Authentication is used, the password must be in a recoverable
  # format, either plain text or OBF:.
  #
  
  test: test
  Aladdin: open sesame
  
  
  1.27      +2 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
  
  Index: jelly.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- jelly.properties	16 Oct 2002 12:45:51 -0000	1.26
  +++ jelly.properties	30 Oct 2002 11:54:11 -0000	1.27
  @@ -30,3 +30,5 @@
   interaction = org.apache.commons.jelly.tags.interaction.InteractionTagLibrary
   antlr       = org.apache.commons.jelly.tags.antlr.AntlrTagLibrary
   quartz      = org.apache.commons.jelly.tags.quartz.QuartzTagLibrary
  +http        = org.apache.commons.jelly.tags.http.HttpTagLibrary
  +jetty       = org.apache.commons.jelly.tags.jetty.JettyTagLibrary
  
  
  
  1.2       +1 -1      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/http/http.jelly
  
  Index: http.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/http/http.jelly,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- http.jelly	27 Sep 2002 02:18:34 -0000	1.1
  +++ http.jelly	30 Oct 2002 11:54:11 -0000	1.2
  @@ -1,7 +1,7 @@
   <?xml version="1.0"?>
   <j:jelly
       xmlns:j="jelly:core"
  -    xmlns="jelly:org.apache.commons.jelly.tags.http.HttpTagLibrary"
  +    xmlns="jelly:http"
       trim="false">
       <!-- a session holds shared http state info 
       <session> -->
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot/contextTest/contextTest.txt
  
  Index: contextTest.txt
  ===================================================================
  It works!
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHandlerTest/resourceHandlerTest.txt
  
  Index: resourceHandlerTest.txt
  ===================================================================
  It works!
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot/test1.txt
  
  Index: test1.txt
  ===================================================================
  It works!
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot test1.txt

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Michael A. Smith" <ma...@apache.org>
> [being anal again... ]
>
> >    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
> >    * reserved.
>
> 2002?

:-). Well spotted again Michael. Now corrected. Many thanks.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot test1.txt

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 30 Oct 2002, Michael A. Smith <ma...@apache.org> wrote:

> [being anal again... ]

If you are running a Unix like system, you may be interested in this
<http://cvs.apache.org/viewcvs/jakarta-ant/src/etc/yearcheck.sh>.

I use this to update my Ant CVS copy and it will immediately report
all files without Copyright as well as those that have no copyright
for 2002.

No rocket science, but very useful to me.

BTW, I think it is wrong to say 1999-2002 for a file that has been
created in 2002.  It would even be wrong if the file hasn't been
modified in 2000, in which case 1999,2001-2002 would be correct AFAIK.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot test1.txt

Posted by "Michael A. Smith" <ma...@apache.org>.
[being anal again... ]

jstrachan@apache.org wrote:
> jstrachan    2002/10/30 03:54:12
> 
>   Modified:    jelly    project.xml
>                jelly/src/java/org/apache/commons/jelly jelly.properties
>                jelly/src/test/org/apache/commons/jelly/http http.jelly
>   Added:       jelly/src/java/org/apache/commons/jelly/tags/jetty
>                         package.html SocketListenerTag.java
>                         ResponseBodyTag.java JellyResourceHandlerTag.java
>                         ResponseHeaderTag.java JettyHttpServerTag.java
>                         ResourceHandlerTag.java RealmTag.java
>                         PutRequestTag.java NotFoundHandlerTag.java
>                         PostRequestTag.java JellyResourceHttpHandler.java
>                         SecurityHandlerTag.java HttpContextTag.java
>                         AbstractMethodHandlerTag.java JettyTagLibrary.java
>                         GetRequestTag.java DeleteRequestTag.java
>                jelly/src/test/org/apache/commons/jelly/jetty
>                         httpContext.jelly securityHandlerUnauthorized.jelly
>                         securityHandlerForbidden.jelly
>                         jellyResourceHandler.jelly resourceHandler.jelly
>                         securityHandler.jelly socketListener.jelly
>                         defaultServer.jelly TestJettyHttpServerTags.java
>                jelly/src/test/org/apache/commons/jelly/jetty/setup
>                         demoRealm.properties
>                jelly/src/test/org/apache/commons/jelly/jetty/docRoot/contextTest
>                         contextTest.txt
>                jelly/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHandlerTest
>                         resourceHandlerTest.txt
>                jelly/src/test/org/apache/commons/jelly/jetty/docRoot
>                         test1.txt
>   Log:
>   Committed patch supplied by Robert Leftwich which creates a Jetty tag library for creating HTTP servers for testing web requests using an embedded Jetty instance.
>   
>   It could be that there is some crossover with 
>   
>   Latka
>   http://jakarta.apache.org/commons/latka/index.html
>   
>   Anteater
>   http://aft.sourceforge.net/
>   
>   or Cactus
>   http://jakarta.apache.org/cactus/
>   
>   I'm not personally expert enough to know what should be done in this area. So I'm committing this and then the discussion between the various groups can start. 
>   It might be that one of the above projects could be a better home for the above code - lets see what the community at large thinks.

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/SocketListenerTag.java
>   
>   Index: SocketListenerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SocketListenerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResponseBodyTag.java
>   
>   Index: ResponseBodyTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ResponseBodyTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JellyResourceHandlerTag.java
>   
>   Index: JellyResourceHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResponseHeaderTag.java
>   
>   Index: ResponseHeaderTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ResponseHeaderTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?


[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JettyHttpServerTag.java
>   
>   Index: JettyHttpServerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JettyHttpServerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResourceHandlerTag.java
>   
>   Index: ResourceHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?


[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/RealmTag.java
>   
>   Index: RealmTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/RealmTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?


[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/PutRequestTag.java
>   
>   Index: PutRequestTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/NotFoundHandlerTag.java
>   
>   Index: NotFoundHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/NotFoundHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/PostRequestTag.java
>   
>   Index: PostRequestTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/PostRequestTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JellyResourceHttpHandler.java
>   
>   Index: JellyResourceHttpHandler.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHttpHandler.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

>   1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/SecurityHandlerTag.java
>   
>   Index: SecurityHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SecurityHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
>    * reserved.

2002?

[snip]

ok, I'm bored with this.  check the copyright dates in all those other 
files as well.  :)

michael
-- 
Michael A. Smith
mas@apache.org



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[jelly][cactus] embedding servlet engines and integration testing... (was Re: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot test1.txt)

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Vincent Massol" <vm...@octo.com>
>
> Looks very cool. Would it be possible for someone to show an example of
> how it works?

Here's a simple example in this directory...

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/src/test/org/apa
che/commons/jelly/jetty/

such as

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/src/test/org/apa
che/commons/jelly/jetty/jellyResourceHandler.jelly?rev=HEAD


> In cactus we have a JettyInitializer class that we use to start an
> embedded Jetty server in the junit test suite.
>
> Is that the same thing?

Very close yes. Right now the Jetty-Jelly tags create an embedded Jetty
server which can be used with inside unit test. Right now the tags have
focussed on generating mock responses or invoking a Jelly script to process
the response. (So mocking the server). However it should be pretty easy to
add real registrations of servlets or deployments of wars etc.


> The philosophy of Cactus is that there is an engine (the cactus
> framework) and several front ends. ATM Cactus has the following front
> ends:
> - Maven plugin
> - Jetty integration in IDE using the JettyInitializer class I mentioned
> - Eclipse plugin (in development)
> - Ant integration
>
> I am completely in favor of adding a Jelly Cactus Tag library. In other
> words, we could factor out the Cactus Maven plugin (already using jelly)
> and create a Cactus tag suite that the Cactus Maven plugin would then
> use.

Sounds cool

> ATM, in all the Cactus plugins we have had to create ways to start/stop
> servers as there is no general library available for this. However, I am
> quite keen to start using someone else's as this is not the business of
> Cactus to develop ways to start/stop/deploy applications in containers.
>
> What do you think?

Funnily enough only yesterday as part of my day job I was creating some
integration tests using Jelly and JellyUnit. I was sending a bunch of JMS
messages around a system, waiting for a while, then testing that the
database contained the right information inside it. The tests are fine
though the big missing pieces are

* start/stop/redeploy

Having some simple way to deploy WARs, EARs, MDBs and so forth, on remote
testing machines as part of a test sounds like a great idea, then being able
to undeploy them after the test has finished. Are there Ant tasks we can
reuse for this?

* orchestration and coordination.

Right now I use the <interaction:ask> tag to pause the integration tests
until the right point before the database-tester kicks off. Ideally that
should be automated. So I'd like some way to orchestrate the integration
tests so I can totally automate things. So this could be where we get to use
Werkflow & Jelly to perform cross-process coordination to allow the (say)
database tests to run once the input messages have been fully processed.
Then we can use JMS, JMX, HTTP or SOAP requests to signal when to start/stop
testing activities.

Getting back to your original point; yes I could do with a simple way to
start/stop/deploy artifacts. Would the existing Ant tasks out there do the
trick?

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot test1.txt

Posted by Vincent Massol <vm...@octo.com>.
Hi,

Looks very cool. Would it be possible for someone to show an example of
how it works?

In cactus we have a JettyInitializer class that we use to start an
embedded Jetty server in the junit test suite.

Is that the same thing?

The philosophy of Cactus is that there is an engine (the cactus
framework) and several front ends. ATM Cactus has the following front
ends:
- Maven plugin
- Jetty integration in IDE using the JettyInitializer class I mentioned
- Eclipse plugin (in development)
- Ant integration

I am completely in favor of adding a Jelly Cactus Tag library. In other
words, we could factor out the Cactus Maven plugin (already using jelly)
and create a Cactus tag suite that the Cactus Maven plugin would then
use.

ATM, in all the Cactus plugins we have had to create ways to start/stop
servers as there is no general library available for this. However, I am
quite keen to start using someone else's as this is not the business of
Cactus to develop ways to start/stop/deploy applications in containers.

What do you think?

Thanks
-Vincent

> -----Original Message-----
> From: jstrachan@apache.org [mailto:jstrachan@apache.org]
> Sent: 30 October 2002 11:54
> To: jakarta-commons-sandbox-cvs@apache.org
> Subject: cvs commit: jakarta-commons-
> sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot
test1.txt
> 
> jstrachan    2002/10/30 03:54:12
> 
>   Modified:    jelly    project.xml
>                jelly/src/java/org/apache/commons/jelly
jelly.properties
>                jelly/src/test/org/apache/commons/jelly/http http.jelly
>   Added:       jelly/src/java/org/apache/commons/jelly/tags/jetty
>                         package.html SocketListenerTag.java
>                         ResponseBodyTag.java
JellyResourceHandlerTag.java
>                         ResponseHeaderTag.java JettyHttpServerTag.java
>                         ResourceHandlerTag.java RealmTag.java
>                         PutRequestTag.java NotFoundHandlerTag.java
>                         PostRequestTag.java
JellyResourceHttpHandler.java
>                         SecurityHandlerTag.java HttpContextTag.java
>                         AbstractMethodHandlerTag.java
JettyTagLibrary.java
>                         GetRequestTag.java DeleteRequestTag.java
>                jelly/src/test/org/apache/commons/jelly/jetty
>                         httpContext.jelly
> securityHandlerUnauthorized.jelly
>                         securityHandlerForbidden.jelly
>                         jellyResourceHandler.jelly
resourceHandler.jelly
>                         securityHandler.jelly socketListener.jelly
>                         defaultServer.jelly
TestJettyHttpServerTags.java
>                jelly/src/test/org/apache/commons/jelly/jetty/setup
>                         demoRealm.properties
> 
> jelly/src/test/org/apache/commons/jelly/jetty/docRoot/contextTest
>                         contextTest.txt
> 
>
jelly/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHandlerTes
t
>                         resourceHandlerTest.txt
>                jelly/src/test/org/apache/commons/jelly/jetty/docRoot
>                         test1.txt
>   Log:
>   Committed patch supplied by Robert Leftwich which creates a Jetty
tag
> library for creating HTTP servers for testing web requests using an
> embedded Jetty instance.
> 
> 
> 
>   It could be that there is some crossover with
> 
> 
> 
>   Latka
> 
>   http://jakarta.apache.org/commons/latka/index.html
> 
> 
> 
>   Anteater
> 
>   http://aft.sourceforge.net/
> 
> 
> 
>   or Cactus
> 
>   http://jakarta.apache.org/cactus/
> 
> 
> 
>   I'm not personally expert enough to know what should be done in this
> area. So I'm committing this and then the discussion between the
various
> groups can start.
> 
>   It might be that one of the above projects could be a better home
for
> the above code - lets see what the community at large thinks.
> 
>   Revision  Changes    Path
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/package.html
> 
>   Index: package.html
>   ===================================================================
>   <html>
>   <head>
>   </head>
>   <body>
> 
>     <p>Tags for starting Jetty HTTP servers and procesing HTTP
requests
> using Jelly scripts
>     </p>
> 
>   </body>
>   </html>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/SocketListene
rT
> ag.java
> 
>   Index: SocketListenerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/SocketListenerTag.
ja
> va,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.SocketListener;
>   import org.mortbay.util.InetAddrPort;
> 
>   /**
>    * Declare a socket listener for a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: SocketListenerTag.java,v 1.3 2002/07/14 12:38:22
dion
> Exp $
>    */
>   public class SocketListenerTag extends TagSupport {
> 
>       /** parameter port with default*/
>       private int _port = JettyHttpServerTag.DEFAULT_PORT;
> 
>       /** parameter host, with default */
>       private String _host = JettyHttpServerTag.DEFAULT_HOST;
> 
>       /** Creates a new instance of SocketListenerTag */
>       public SocketListenerTag() {
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, add a socket
> listener
>        * for the specified host and port to the parent server,
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           JettyHttpServerTag httpserver = (JettyHttpServerTag)
> findAncestorWithClass(
>               JettyHttpServerTag.class);
>           if ( httpserver == null ) {
>               throw new JellyException( "<socketListener> tag must be
> enclosed inside a <server> tag" );
>           }
>           httpserver.addListener(
>               new SocketListener(new InetAddrPort(getHost(),
getPort())));
>           invokeBody(xmlOutput);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
>       /**
>        * Getter for property port.
>        *
>        * @return value of property port.
>        */
>       public int getPort() {
>           return _port;
>       }
> 
>       /**
>        * Setter for property port.
>        *
>        * @param port New value of property port.
>        */
>       public void setPort(int port) {
>           _port = port;
>       }
> 
>       /**
>        * Getter for property host.
>        *
>        * @return value of property host.
>        */
>       public String getHost() {
>           return _host;
>       }
> 
>       /**
>        * Setter for property host.
>        *
>        * @param host New value of property host.
>        */
>       public void setHost(String host) {
>           _host = host;
>       }
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResponseBodyT
ag
> .java
> 
>   Index: ResponseBodyTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/ResponseBodyTag.ja
va
> ,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpResponse;
>   import org.mortbay.util.ByteArrayISO8859Writer;
> 
>   /**
>    * Set the response body in a response handler for a Jetty http
server
>    *
>    * @author  rtl
>    */
>   public class ResponseBodyTag extends TagSupport {
> 
>       /**
>        * Perform the tag functionality. In this case, set the body of
a
>        * http response found in the jelly context
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
> 
>           // get the response from the context
>           HttpResponse httpResponse = (HttpResponse)
> getContext().getVariable("response");
>           if (null == httpResponse) {
>               throw new JellyException("HttpResponse variable not
> available in Jelly context");
>           }
> 
>           ByteArrayISO8859Writer writer = new
> ByteArrayISO8859Writer(1500);
>           writer.write(getBodyText());
>           writer.flush();
>           httpResponse.setContentLength(writer.length());
>           writer.writeTo(httpResponse.getOutputStream());
> 
>       }
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JellyResource
Ha
> ndlerTag.java
> 
>   Index: JellyResourceHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHandl
er
> Tag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   /**
>    * A resource handler that uses Jelly scripts to provide resources
>    * to a context in a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: JellyResourceHandlerTag.java,v 1.3 2002/07/14
12:38:22
> dion Exp $
>    */
>   public class JellyResourceHandlerTag extends TagSupport {
> 
>       /** The http handler that calls the body of the tag. */
>       private JellyResourceHttpHandler _jellyResourceHttpHandler;
> 
>       /** Creates a new instance of JellyResourceHandlerTag */
>       public JellyResourceHandlerTag() {
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, add an http
handler
>        * to the parent context that runs the script in the body of
this
> tag
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           HttpContextTag httpContext = (HttpContextTag)
> findAncestorWithClass(
>               HttpContextTag.class);
>           if ( httpContext == null ) {
>               throw new JellyException( "<jellyResourceHandler> tag
must
> be enclosed inside a <httpContext> tag" );
>           }
> 
>           _jellyResourceHttpHandler =
>               new JellyResourceHttpHandler(xmlOutput);
> 
>           httpContext.addHandler(_jellyResourceHttpHandler);
> 
>           // process any child method handlers
>           invokeBody(xmlOutput);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>       protected JellyResourceHttpHandler getJellyResourceHttpHandler()
{
>           return _jellyResourceHttpHandler;
>       }
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResponseHeade
rT
> ag.java
> 
>   Index: ResponseHeaderTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/ResponseHeaderTag.
ja
> va,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpResponse;
> 
>   /**
>    * Set a response header in the request handler of a Jetty http
server
>    *
>    * @author  rtl
>    */
>   public class ResponseHeaderTag extends TagSupport {
> 
>       /** parameter name */
>       private String _name;
> 
>       /** parameter value */
>       private String _value;
> 
>       /**
>        * Perform the tag functionality. In this case, set a header in
the
>        * http response found in the jelly context
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
> 
>           if (null == getName()) {
>               throw new JellyException("<responseHeader> tag must have
a
> name");
>           }
> 
>           // get the response from the context
>           HttpResponse httpResponse = (HttpResponse)
> getContext().getVariable("response");
>           if (null == httpResponse) {
>               throw new JellyException("HttpResponse variable not
> available in Jelly context");
>           }
> 
>           // if value is valid then set it
>           // otherwise remove the field
>           if (null != getValue()) {
>               httpResponse.setField(getName(), getValue());
>           } else {
>               httpResponse.removeField(getName());
>           }
> 
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>       /**
>        * Getter for property context path.
>        *
>        * @return value of property context path.
>        */
>       public String getName() {
>           return _name;
>       }
> 
>       /**
>        * Setter for property context path.
>        *
>        * @param path New value of property context path.
>        */
>       public void setName(String name) {
>           _name = name;
>       }
> 
>       /**
>        * Getter for property value.
>        *
>        * @return value of property value.
>        */
>       public String getValue() {
>           return _value;
>       }
> 
>       /**
>        * Setter for property value.
>        *
>        * @param value New value of property value.
>        */
>       public void setValue(String value) {
>           _value = value;
>       }
> 
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JettyHttpServ
er
> Tag.java
> 
>   Index: JettyHttpServerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/JettyHttpServerTag
.j
> ava,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpContext;
>   import org.mortbay.http.HttpListener;
>   import org.mortbay.http.HttpServer;
>   import org.mortbay.http.SocketListener;
>   import org.mortbay.http.UserRealm;
>   import org.mortbay.http.handler.NotFoundHandler;
>   import org.mortbay.http.handler.ResourceHandler;
>   import org.mortbay.util.Resource;
> 
>   import java.net.URL;
> 
>   /**
>    * Declare an instance of a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: JettyHttpServerTag.java,v 1.3 2002/07/14 12:38:22
dion
> Exp $
>    */
>   public class JettyHttpServerTag extends TagSupport {
> 
>       /** default port to create listeners for */
>       public static final int DEFAULT_PORT = 8100;
> 
>       /** default host to create listeners/context for */
>       public static final String DEFAULT_HOST = "localhost";
> 
>       /** default context to create context for */
>       public static final String DEFAULT_CONTEXT_PATH = "/";
> 
>       /** default resource base to use for context */
>       public static final String DEFAULT_RESOURCE_BASE = "./docRoot";
> 
>       /** unique identifier of the tag/ variable to store result in */
>       private String _var;
> 
>       /** the http server for this tag */
>       private HttpServer _server;
> 
>       /** Creates a new instance of JettyHttpServerTag */
>       public JettyHttpServerTag() {
>           // Create the server
>           _server=new HttpServer();
> 
>           // turn off alias checking in Jetty's FileResource,
>           // so that we don't need exact case in resource names
>
System.setProperty("org.mortbay.util.FileResource.checkAliases",
> "false");
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, create an http
> server after
>        * making sure that it has at least one context and associated
http
> handler,
>        * creating defaults if it doesn't
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
> 
>           // allow nested tags first, e.g body
>           invokeBody(xmlOutput);
> 
>           // if no listeners create a default port listener
>           if (_server.getListeners().length == 0) {
>               SocketListener listener=new SocketListener();
>               listener.setPort(DEFAULT_PORT);
>               listener.setHost(DEFAULT_HOST);
>               _server.addListener(listener);
>           }
> 
>           // if no context/s create a default context
>           if (_server.getContexts().length == 0) {
>               // Create a context
>               HttpContext context = _server.getContext(DEFAULT_HOST,
> 
> DEFAULT_CONTEXT_PATH);
> 
>               // Serve static content from the context
>               URL baseResourceURL =
> getContext().getResource(DEFAULT_RESOURCE_BASE);
>               Resource resource =
Resource.newResource(baseResourceURL);
>               context.setBaseResource(resource);
>               _server.addContext(context);
>           }
> 
>           // check that all the contexts have at least one handler
>           // if not then add a default resource handler and a not
found
> handler
>           HttpContext[] allContexts = _server.getContexts();
>           for (int i = 0; i < allContexts.length; i++) {
>               HttpContext currContext = allContexts[i];
>               if (currContext.getHandlers().length == 0) {
>                   currContext.addHandler(new ResourceHandler());
>                   currContext.addHandler(new NotFoundHandler());
>               }
>           }
> 
>           // Start the http server
>           _server.start();
> 
>           // set variable to value if required
>           if (getVar() != null) {
>               getContext().setVariable(getVar(), _server);
>           }
>       }
> 
>       /**
>        * Add an http listener to the server instance
>        *
>        * @param listener the listener to add
>        */
>       public void addListener(HttpListener listener) {
>           _server.addListener(listener);
>       }
> 
>       /**
>        * Add an http context to the server instance
>        *
>        * @param context the context to add
>        */
>       public void addContext(HttpContext context) {
>           _server.addContext(context);
>       }
> 
>       /* ------------------------------------------------------------
*/
>       /**
>        * Add a user authentication realm to the server instance
>        *
>        * @param realm the realm to add
>        * @return the realm added
>        */
>       public UserRealm addRealm(UserRealm realm)
>       {
>           return _server.addRealm(realm);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>       /**
>        * Getter for property var.
>        *
>        * @return Value of property var.
>        */
>       public String getVar() {
>           return _var;
>       }
> 
>       /**
>        * Setter for property var.
>        *
>        * @param var New value of property var.
>        */
>       public void setVar(String var) {
>           _var = var;
>       }
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/ResourceHandl
er
> Tag.java
> 
>   Index: ResourceHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/ResourceHandlerTag
.j
> ava,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.handler.ResourceHandler;
> 
>   import java.util.StringTokenizer;
> 
>   /**
>    * Declare a static file resource handler for a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: ResourceHandlerTag.java,v 1.3 2002/07/14 12:38:22
dion
> Exp $
>    */
>   public class ResourceHandlerTag extends TagSupport {
> 
>       /** parameter allowed methods */
>       private String _allowedMethods;
> 
>       /** Creates a new instance of ResourceHandlerTag */
>       public ResourceHandlerTag() {
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, add a resource
> handler
>        * to the parent context, setting the allowed methods if
required
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           HttpContextTag httpContext = (HttpContextTag)
> findAncestorWithClass(
>               HttpContextTag.class);
>           if ( httpContext == null ) {
>               throw new JellyException( "<resourceHandler> tag must be
> enclosed inside a <httpContext> tag" );
>           }
>           ResourceHandler resourceHandler = new ResourceHandler();
>           if (getAllowedMethods() != null) {
>               // split comma-separated list up into tokens and convert
to
> an array
>               StringTokenizer tokenizer =
>                   new StringTokenizer( getAllowedMethods(), " ," );
>               String[] allowedMethods = new
> String[tokenizer.countTokens()];
>               for (int i = 0; i < allowedMethods.length; i++) {
>                   allowedMethods[i] = tokenizer.nextToken();
>               }
>               resourceHandler.setAllowedMethods(allowedMethods);
>           }
>           httpContext.addHandler(resourceHandler);
>           invokeBody(xmlOutput);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>       /**
>        * Getter for property allowedMethods.
>        *
>        * @return value of property allowedMethods.
>        */
>       public String getAllowedMethods() {
>           return _allowedMethods;
>       }
> 
>       /**
>        * Setter for property allowedMethods.
>        *
>        * @param allowedMethods Comma separated list of allowed
methods.
>        */
>       public void setAllowedMethods(String allowedMethods) {
>           _allowedMethods = allowedMethods;
>       }
> 
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/RealmTag.java
> 
>   Index: RealmTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
> commons/latka/src/java/org/apache/commons/latka/jelly/RealmTag.java,v
1.3
> 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HashUserRealm;
> 
>   import java.net.URL;
> 
>   /**
>    * Declare a user realm for a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: RealmTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    */
>   public class RealmTag extends TagSupport {
> 
>       /** parameter name with default*/
>       private String _name;
> 
>       /** parameter config, with default */
>       private String _config;
> 
>       /** Creates a new instance of RealmTag */
>       public RealmTag() {
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, add a realm with
the
>        * specified name using the specified config (preperties) file
to
> the
>        * parent server,
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           JettyHttpServerTag httpserver = (JettyHttpServerTag)
> findAncestorWithClass(
>               JettyHttpServerTag.class);
>           if ( httpserver == null ) {
>               throw new JellyException( "<realm> tag must be enclosed
> inside a <server> tag" );
>           }
>           if (null == getName() || null == getConfig()) {
>               throw new JellyException( "<realm> tag must have a name
and
> a config" );
>           }
> 
>           // convert the config string to a URL
>           // (this makes URL's relative to the location of the script
>           URL configURL = getContext().getResource(getConfig());
>           httpserver.addRealm( new HashUserRealm(getName(),
> configURL.toString() ) );
>           invokeBody(xmlOutput);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>       /**
>        * Getter for property name.
>        *
>        * @return value of property name.
>        */
>       public String getName() {
>           return _name;
>       }
> 
>       /**
>        * Setter for property name.
>        *
>        * @param name New value of property name.
>        */
>       public void setName(String name) {
>           _name = name;
>       }
> 
>       /**
>        * Getter for property config.
>        *
>        * @return value of property config.
>        */
>       public String getConfig() {
>           return _config;
>       }
> 
>       /**
>        * Setter for property config.
>        *
>        * @param config New value of property config.
>        */
>       public void setConfig(String config) {
>           _config = config;
>       }
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/PutRequestTag
.j
> ava
> 
>   Index: PutRequestTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/PutRequestTag.java
,v
> 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   /**
>    * Respond to a PUT request to a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion
Exp $
>    */
>   /** A tag for the http PUT method */
>   public class PutRequestTag extends AbstractMethodHandlerTag {
> 
>       /** return the name of the http method handled by this tag */
>       public String getMethodHandled() {
>           return "PUT";
>       }
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/NotFoundHandl
er
> Tag.java
> 
>   Index: NotFoundHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/NotFoundHandlerTag
.j
> ava,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.handler.NotFoundHandler;
> 
>   import java.util.StringTokenizer;
> 
>   /**
>    * Declare a not found resource handler for a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: NotFoundHandlerTag.java,v 1.3 2002/07/14 12:38:22
dion
> Exp $
>    */
>   public class NotFoundHandlerTag extends TagSupport {
> 
>       /** Creates a new instance of NotFoundHandlerTag */
>       public NotFoundHandlerTag() {
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, add a resource
> handler
>        * to the parent context, setting the allowed methods if
required
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           HttpContextTag httpContext = (HttpContextTag)
> findAncestorWithClass(
>               HttpContextTag.class);
>           if ( httpContext == null ) {
>               throw new JellyException( "<notFoundHandler> tag must be
> enclosed inside a <httpContext> tag" );
>           }
>           NotFoundHandler notFoundHandler = new NotFoundHandler();
>           httpContext.addHandler(notFoundHandler);
>           invokeBody(xmlOutput);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/PostRequestTa
g.
> java
> 
>   Index: PostRequestTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/PostRequestTag.jav
a,
> v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   /**
>    * Respond to a POST request to a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion
Exp $
>    */
>   public class PostRequestTag extends AbstractMethodHandlerTag {
> 
>       /** return the name of the http method handled by this tag */
>       public String getMethodHandled() {
>           return "POST";
>       }
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JellyResource
Ht
> tpHandler.java
> 
>   Index: JellyResourceHttpHandler.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHttpH
an
> dler.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyContext;
>   import org.apache.commons.jelly.Tag;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpException;
>   import org.mortbay.http.HttpRequest;
>   import org.mortbay.http.HttpResponse;
>   import org.mortbay.http.handler.AbstractHttpHandler;
> 
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
> 
>   import java.io.IOException;
>   import java.util.HashMap;
>   import java.util.Map;
> 
>   /**
>    * The actual http handler implementation for an http context in an
http
> server
>    *
>    * @author  rtl
>    * @version $Id: JellyResourceHttpHandler.java,v 1.3 2002/07/14
12:38:22
> dion Exp $
>    */
>   class JellyResourceHttpHandler extends AbstractHttpHandler {
> 
>       /** The Log to which logging calls will be made. */
>       private static final Log log =
> LogFactory.getLog(JellyResourceHttpHandler.class);
> 
>       /** The name of the var to check if setHandled should not be set
to
> true . */
>       private static final String OVERRIDE_SET_HANDLED_VAR =
> "overrideSetHandled";
> 
>       /** The list of  tags registered to handle a request method  */
>       private Map _tagMap;
> 
>       /** The place where to output the results of the tag body */
>       private XMLOutput _xmlOutput;
> 
>       /** Creates a new instance of JellyResourceHttpHandler */
>       public JellyResourceHttpHandler( XMLOutput xmlOutput ) {
>           _tagMap = new HashMap();
>           _xmlOutput = xmlOutput;
>       }
> 
>       /*
>        * register this tag as the handler for the specified method
>        *
>        * @param tag the tag to be registered
>        * @param method the name of the http method which this tag
> processes
>        */
>       public void registerTag(Tag tag, String method){
>           _tagMap.put(method.toLowerCase(), tag);
>       }
> 
>       /*
>        * handle an http request
>        *
>        * @param pathInContext the path of the http request
>        * @param pathParams the parameters (if any) of the http request
>        * @param request the actual http request
>        * @param response the place for any response
>        *
>        * @throws HttpException when an error occurs
>        * @throws IOException when an error occurs
>        */
>       public void handle(String pathInContext,
>                          String pathParams,
>                          HttpRequest request,
>                          HttpResponse response)
>           throws HttpException, IOException
>       {
>           Tag handlerTag = (Tag)
> _tagMap.get(request.getMethod().toLowerCase());
>           if (null != handlerTag) {
>               // setup the parameters in the jelly context
>               JellyContext jellyContext = handlerTag.getContext();
>               jellyContext.setVariable( "pathInContext",
pathInContext);
>               jellyContext.setVariable( "pathParams", pathParams);
>               jellyContext.setVariable( "request", request);
>               jellyContext.setVariable( "response", response);
> 
>               try {
>                   handlerTag.invokeBody(_xmlOutput);
>                   // only call set handled if tag has not requested an
> override
>                   // if it has requested an override then reset the
> request
>                   if (null ==
> jellyContext.getVariable(OVERRIDE_SET_HANDLED_VAR)) {
>                       request.setHandled(true);
>                   } else {
> 
> jellyContext.removeVariable(OVERRIDE_SET_HANDLED_VAR);
>                   }
>               } catch (Exception ex ) {
>                   throw new
> HttpException(HttpResponse.__500_Internal_Server_Error,
>                                           "Error invoking method
handler
> tag: " + ex.getLocalizedMessage());
>               }
>           } else {
>               log.info("No handler for request:" +
>                         request.getMethod() + " path:" +
>                         response.getHttpContext().getContextPath() +
>                         pathInContext);
>           }
> 
>           return;
>       }
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/SecurityHandl
er
> Tag.java
> 
>   Index: SecurityHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/SecurityHandlerTag
.j
> ava,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.BasicAuthenticator;
>   import org.mortbay.http.ClientCertAuthenticator;
>   import org.mortbay.http.DigestAuthenticator;
>   import org.mortbay.http.SecurityConstraint.Authenticator;
>   import org.mortbay.http.SecurityConstraint;
>   import org.mortbay.http.handler.SecurityHandler;
>   import org.mortbay.jetty.servlet.FormAuthenticator;
>   import org.mortbay.util.Code;
>   import org.mortbay.xml.XmlParser;
> 
>   import org.xml.sax.InputSource;
> 
>   import java.io.StringReader;
>   import java.util.Iterator;
> 
>   /**
>    * Declare a security handler for a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: SecurityHandlerTag.java,v 1.3 2002/07/14 12:38:22
dion
> Exp $
>    */
>   public class SecurityHandlerTag extends TagSupport {
> 
>       /** a form authenticator used by this tag */
>       private transient FormAuthenticator _formAuthenticator;
> 
>       /** parameter authentication method, defaults to BASIC in Jetty
*/
>       private String _authenticationMethod;
> 
>       /** Creates a new instance of SecurityHandlerTag */
>       public SecurityHandlerTag() {
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, add a security
> handler
>        * to the parent context, setting the authentication method if
> required
>        * The security constraints should be specified as the body of
this
> tag
>        * using the same format as a web.xml file wrapped in a single
>        * <constraints> tag to allow parsing of a well-formed snippet,
e.g.
>        *
>        * <constraints>
>        *   <security-constraint>
>        *    <web-resource-collection>
>        *     <web-resource-name>Default</web-resource-name>
>        *      <url-pattern>/</url-pattern>
>        *    </web-resource-collection>
>        *    <auth-constraint/>
>        *   </security-constraint>
>        *
>        *   <security-constraint>
>        *     <web-resource-collection>
>        *
<url-pattern>/docRoot/resourceHandlerTest/*</url-pattern>
>        *       <http-method>GET</http-method>
>        *       <http-method>HEAD</http-method>
>        *     </web-resource-collection>
>        *     <auth-constraint>
>        *       <role-name>*</role-name>
>        *     </auth-constraint>
>        *   </security-constraint>
>        *
>        *   <login-config>
>        *     <auth-method>BASIC</auth-method>
>        *     <realm-name>Jetty Demo Realm</realm-name>
>        *   </login-config>
>        *
>        * </constraints>
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           HttpContextTag httpContext = (HttpContextTag)
> findAncestorWithClass(
>               HttpContextTag.class);
>           if ( httpContext == null ) {
>               throw new JellyException( "<securityHandler> tag must be
> enclosed inside a <httpContext> tag" );
>           }
>           SecurityHandler securityHandler = new SecurityHandler();
>           if (getauthenticationMethod() != null) {
>
securityHandler.setAuthMethod(getauthenticationMethod());
>           }
>           httpContext.addHandler(securityHandler);
> 
>           // get the security constraints from the body of this tag
>           // by parsing the body of the parent (so it will be well
formed)
>           String bodyText = getBodyText();
>           StringReader reader = new StringReader(bodyText);
>           InputSource inputSource = new InputSource(reader);
> 
>           // crate a non-validating parser
>           XmlParser xmlParser = new XmlParser(false);
> 
>           XmlParser.Node node = xmlParser.parse(inputSource);
> 
>           Iterator iter=node.iterator();
>           XmlParser.Node currNode = null;
>           while (iter.hasNext())
>           {
>                   Object o = iter.next();
>                   if (!(o instanceof XmlParser.Node))
>                       continue;
> 
>                   currNode=(XmlParser.Node)o;
>                   String name=currNode.getTag();
> 
>                   if ("security-constraint".equals(name)) {
>                       initSecurityConstraint(currNode, httpContext);
>                   } else if ("login-config".equals(name)) {
>                       initLoginConfig(currNode, httpContext);
>                   } else {
>                       throw new JellyException("Invalid element in
> <securityHandler> tag. Are you using the <constraints> tag?: " +
> currNode);
>                   }
>           }
> 
>       }
> 
>       /* ------------------------------------------------------------
>        * This is the code from Jetty's WebApplicationContext
>        * with the HttpContextTag parameter added
>        *
>        * Process a parsed xml node to setup the security constraints
>        * for an http server
>        *
>        * @param node the parsed xml starting node of the constraints
>        * @param httpContext the tag to add the security constraint to
>       */
>       protected void initSecurityConstraint(XmlParser.Node node,
>                                             HttpContextTag
httpContext)
>       {
>           SecurityConstraint scBase = new SecurityConstraint();
> 
>           XmlParser.Node auths=node.get("auth-constraint");
>           if (auths!=null)
>           {
>               scBase.setAuthenticate(true);
>               // auth-constraint
>               Iterator iter= auths.iterator("role-name");
>               while(iter.hasNext())
>               {
>                   String
> role=((XmlParser.Node)iter.next()).toString(false,true);
>                   scBase.addRole(role);
>               }
>           }
> 
>           XmlParser.Node data=node.get("user-data-constraint");
>           if (data!=null)
>           {
>               data=data.get("transport-guarantee");
>               String guarantee =
data.toString(false,true).toUpperCase();
>               if (guarantee==null || guarantee.length()==0 ||
>                   "NONE".equals(guarantee))
>                   scBase.setDataConstraint(scBase.DC_NONE);
>               else if ("INTEGRAL".equals(guarantee))
>                   scBase.setDataConstraint(scBase.DC_INTEGRAL);
>               else if ("CONFIDENTIAL".equals(guarantee))
>                   scBase.setDataConstraint(scBase.DC_CONFIDENTIAL);
>               else
>               {
>                   Code.warning("Unknown
user-data-constraint:"+guarantee);
>                   scBase.setDataConstraint(scBase.DC_CONFIDENTIAL);
>               }
>           }
> 
>           Iterator iter= node.iterator("web-resource-collection");
>           while(iter.hasNext())
>           {
>               XmlParser.Node collection=(XmlParser.Node)iter.next();
>               String name=collection.getString("web-resource-
> name",false,true);
>               SecurityConstraint sc =
(SecurityConstraint)scBase.clone();
>               sc.setName(name);
> 
>               Iterator iter2= collection.iterator("http-method");
>               while(iter2.hasNext())
>                   sc.addMethod(((XmlParser.Node)iter2.next())
>                                .toString(false,true));
> 
>               iter2= collection.iterator("url-pattern");
>               while(iter2.hasNext())
>               {
>                   String url=
>
((XmlParser.Node)iter2.next()).toString(false,true);
>                   httpContext.addSecurityConstraint(url,sc);
>               }
>           }
>       }
> 
>       /* ------------------------------------------------------------
>        * This is the code from Jetty's WebApplicationContext
>        * with the HttpContextTag parameter added
>        *
>        *
>        * Process a parsed xml node to setup the authenticator and
realm
>        * for an http server
>        *
>        * @param node the parsed xml starting node of the login
> configuration
>        * @param httpContext the tag to add the authenticator and realm
to
>       */
>       protected void initLoginConfig(XmlParser.Node node,
>                                      HttpContextTag httpContext)
>       {
>           XmlParser.Node method=node.get("auth-method");
>           if (method!=null)
>           {
>               Authenticator authenticator=null;
>               String m=method.toString(false,true);
> 
>               if (SecurityConstraint.__FORM_AUTH.equals(m))
>                   authenticator=_formAuthenticator=new
> FormAuthenticator();
>               else if (SecurityConstraint.__BASIC_AUTH.equals(m))
>                   authenticator=new BasicAuthenticator();
>               else if (SecurityConstraint.__DIGEST_AUTH.equals(m))
>                   authenticator=new DigestAuthenticator();
>               else if (SecurityConstraint.__CERT_AUTH.equals(m))
>                   authenticator=new ClientCertAuthenticator();
>               else
>                   Code.warning("UNKNOWN AUTH METHOD: "+m);
> 
>               httpContext.setAuthenticator(authenticator);
>           }
> 
>           XmlParser.Node name=node.get("realm-name");
>           if (name!=null)
>               httpContext.setRealmName(name.toString(false,true));
> 
>           XmlParser.Node formConfig = node.get("form-login-config");
>           if(formConfig != null)
>           {
>               if (_formAuthenticator==null)
>                   Code.warning("FORM Authentication miss-configured");
>               else
>               {
>                   XmlParser.Node loginPage =
formConfig.get("form-login-
> page");
>                   if (loginPage != null)
> 
> _formAuthenticator.setLoginPage(loginPage.toString(false,true));
>                   XmlParser.Node errorPage =
formConfig.get("form-error-
> page");
>                   if (errorPage != null)
> 
> _formAuthenticator.setErrorPage(errorPage.toString(false,true));
>               }
>           }
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
> 
>       /**
>        * Getter for property authenticationMethod.
>        *
>        * @return value of property authenticationMethod.
>        */
>       public String getauthenticationMethod() {
>           return _authenticationMethod;
>       }
> 
>       /**
>        * Setter for property authenticationMethod.
>        *
>        * @param authenticationMethod Type of authentication (BASIC,
FORM,
> DIGEST, CLIENT-CERT)
>        * Note that only BASIC and CLIENT-CERT are supported by Jetty
as of
> v4.1.1
>        */
>       public void setauthenticationMethod(String authenticationMethod)
{
>           _authenticationMethod = authenticationMethod;
>       }
> 
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/HttpContextTa
g.
> java
> 
>   Index: HttpContextTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/HttpContextTag.jav
a,
> v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpContext;
>   import org.mortbay.http.HttpHandler;
>   import org.mortbay.http.SecurityConstraint;
>   import org.mortbay.http.SecurityConstraint.Authenticator;
>   import org.mortbay.util.Resource;
> 
>   import java.net.URL;
> 
>   /**
>    * Declare a context for a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: HttpContextTag.java,v 1.3 2002/07/14 12:38:22 dion
Exp
> $
>    */
>   public class HttpContextTag extends TagSupport {
> 
>       /** parameter path with default*/
>       private String _contextPath =
> JettyHttpServerTag.DEFAULT_CONTEXT_PATH;
> 
>       /** parameter resourceBase, with default */
>       private String _resourceBase =
> JettyHttpServerTag.DEFAULT_RESOURCE_BASE;
> 
>       /** parameter realmName*/
>       private String _realmName;
> 
>       /** the actual context this tag refers to */
>       private HttpContext _context;
> 
>       /** Creates a new instance of HttpContextTag */
>       public HttpContextTag() {
>           // create an actual context for this tag
>           _context = new HttpContext();
>       }
> 
>       /**
>        * Perform the tag functionality. In this case, setup the
context
> path
>        * and resource base before adding the context to the parent
server
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
> 
>           JettyHttpServerTag httpserver = (JettyHttpServerTag)
> findAncestorWithClass(
>               JettyHttpServerTag.class);
>           if ( httpserver == null ) {
>               throw new JellyException( "<httpContext> tag must be
> enclosed inside a <server> tag" );
>           }
> 
>           // allow nested tags first, e.g body
>           invokeBody(xmlOutput);
> 
>           _context.setContextPath(getContextPath());
> 
>           // convert the resource string to a URL
>           // (this makes URL's relative to the location of the script
>           URL baseResourceURL =
> getContext().getResource(getResourceBase());
>
_context.setBaseResource(Resource.newResource(baseResourceURL));
>           if (null != getRealmName()) {
>               _context.setRealmName(getRealmName());
>           }
>           httpserver.addContext(_context);
> 
>       }
> 
>       /**
>        * Add an http handler to the context instance
>        *
>        * @param handler the handler to add
>        */
>       public void addHandler(HttpHandler httHandler) {
>           _context.addHandler(httHandler);
>       }
> 
>       /**
>        * Add a security constraint for the specified path
specification
>        * to the context instance
>        *
>        * @param pathSpec the path specification for the security
> constraint
>        * @param sc the security constraint to add
>        */
>       public void addSecurityConstraint(String pathSpec,
> SecurityConstraint sc) {
>           _context.addSecurityConstraint(pathSpec, sc);
>       }
> 
>       /**
>        * Add an authenticator to the context instance
>        *
>        * @param authenticator the authenticator to add
>        */
>       public void setAuthenticator(Authenticator authenticator)
>       {
>           _context.setAuthenticator(authenticator);
>       }
> 
>
//------------------------------------------------------------------
> --------
>       // Property accessors/mutators
>
//------------------------------------------------------------------
> --------
>       /**
>        * Getter for property context path.
>        *
>        * @return value of property context path.
>        */
>       public String getContextPath() {
>           return _contextPath;
>       }
> 
>       /**
>        * Setter for property context path.
>        *
>        * @param path New resourceBase of property context path.
>        */
>       public void setContextPath(String contextPath) {
>           _contextPath = contextPath;
>       }
> 
>       /**
>        * Getter for property resourceBase.
>        *
>        * @return value of property resourceBase.
>        */
>       public String getResourceBase() {
>           return _resourceBase;
>       }
> 
>       /**
>        * Setter for property resourceBase.
>        *
>        * @param resourceBase New value of property resourceBase.
>        */
>       public void setResourceBase(String resourceBase) {
>           _resourceBase = resourceBase;
>       }
> 
>       /**
>        * Getter for property realm name.
>        *
>        * @return value of property realm name.
>        */
>       public String getRealmName() {
>           return _realmName;
>       }
> 
>       /**
>        * Setter for property context path.
>        *
>        * @param path New resourceBase of property context path.
>        */
>       public void setRealmName(String realmName) {
>           _realmName = realmName;
>       }
> 
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/AbstractMetho
dH
> andlerTag.java
> 
>   Index: AbstractMethodHandlerTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/JellyResourceHandl
er
> Tag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpResponse;
> 
>   /**
>    * An abstract base tag to declare a handler for a particular
request
> method
>    * in an http context in an http server
>    *
>    * @author  rtl
>    * @version $Id: AbstractMethodHandlerTag.java,v 1.3 2002/07/14
12:38:22
> dion Exp $
>    */
>   abstract public class AbstractMethodHandlerTag extends TagSupport {
> 
>       /** Override this to return the name of the http method handled
by
> this tag */
>       abstract public String getMethodHandled();
> 
>       /**
>        * Perform the tag functionality. In this case, add a http
method
> handler
>        * to the parent that invokes the script in the body of this tag
> when
>        * processing an http request
>        *
>        * @param xmlOutput where to send output
>        * @throws Exception when an error occurs
>        */
>       public void doTag(XMLOutput xmlOutput) throws Exception {
>           JellyResourceHandlerTag parentTag =
>               (JellyResourceHandlerTag) findAncestorWithClass(
>                   JellyResourceHandlerTag.class);
> 
>           if ( parentTag == null ) {
>               throw new JellyException( "<" +
> getMethodHandled().toLowerCase() +
>                                         "Request> tag must be enclosed
> inside a <jellyResourceHandler> tag" );
>           }
> 
>           // register this tag with the http handler for the
appropriate
> method
>           parentTag.getJellyResourceHttpHandler().registerTag(this,
> getMethodHandled());
> 
>           // NOTE - don't invokeBody here as we only want to do it
during
> a request
>       }
> 
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/JettyTagLibra
ry
> .java
> 
>   Index: JettyTagLibrary.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/JettyTagLibrary.ja
va
> ,v 1.1 2002/07/14 13:05:14 dion Exp $
>    * $Revision: 1.1 $
>    * $Date: 2002/07/14 13:05:14 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import java.util.Map;
> 
>   import org.apache.commons.jelly.TagLibrary;
> 
>   /**
>    * A set of jelly tags for instantiating a Jetty HTTP server
>    *
>    * @author rtl
>    * @version $Id: JettyTagLibrary.java,v 1.1 2002/07/14 13:05:14 dion
Exp
> $
>    */
>   public class JettyTagLibrary extends TagLibrary {
> 
>       /**
>        * Creates a new instance of LatkaTagLibrary
>        */
>       public JettyTagLibrary() {
> 
>           registerTag("jettyHttpServer", JettyHttpServerTag.class);
>           registerTag("socketListener", SocketListenerTag.class);
>           registerTag("realm", RealmTag.class);
>           registerTag("httpContext", HttpContextTag.class);
>           registerTag("resourceHandler", ResourceHandlerTag.class);
>           registerTag("notFoundHandler", NotFoundHandlerTag.class);
>           registerTag("securityHandler", SecurityHandlerTag.class);
> 
>           registerTag("jellyResourceHandler",
> JellyResourceHandlerTag.class);
>           registerTag("getRequest", GetRequestTag.class);
>           registerTag("postRequest", PostRequestTag.class);
>           registerTag("putRequest", PutRequestTag.class);
>           registerTag("deleteRequest", DeleteRequestTag.class);
>           registerTag("responseHeader", ResponseHeaderTag.class);
>           registerTag("responseBody", ResponseBodyTag.class);
>       }
> 
>       /**
>        * @see TagLibarary#getTagClasses()
>        *
>        * @return a Map of tag name to tag class
>        */
>       public Map getTagClasses() {
>           return super.getTagClasses();
>       }
> 
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/GetRequestTag
.j
> ava
> 
>   Index: GetRequestTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/GetRequestTag.java
,v
> 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   /**
>    * Respond to a GET request to a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: PutRequestTag.java,v 1.3 2002/07/14 12:38:22 dion
Exp $
>    */
>   public class GetRequestTag extends AbstractMethodHandlerTag {
> 
>       /** return the name of the http method handled by this tag */
>       public String getMethodHandled() {
>           return "GET";
>       }
>   }
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/java/org/apache/commons/jelly/tags/jetty/DeleteRequest
Ta
> g.java
> 
>   Index: DeleteRequestTag.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-
>
commons/latka/src/java/org/apache/commons/latka/jelly/DeleteRequestTag.j
av
> a,v 1.3 2002/07/14 12:38:22 dion Exp $
>    * $Revision: 1.3 $
>    * $Date: 2002/07/14 12:38:22 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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.commons.jelly.tags.jetty;
> 
>   import org.apache.commons.jelly.JellyException;
>   import org.apache.commons.jelly.TagSupport;
>   import org.apache.commons.jelly.XMLOutput;
> 
>   import org.mortbay.http.HttpResponse;
> 
>   /**
>    * Respond to a DELETE request to a Jetty http server
>    *
>    * @author  rtl
>    * @version $Id: DeleteRequestTag.java,v 1.3 2002/07/14 12:38:22
dion
> Exp $
>    */
>   public class DeleteRequestTag extends AbstractMethodHandlerTag {
> 
>       /** return the name of the http method handled by this tag */
>       public String getMethodHandled() {
>           return "DELETE";
>       }
>   }
> 
> 
> 
> 
>   1.84      +6 -0      jakarta-commons-sandbox/jelly/project.xml
> 
>   Index: project.xml
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
>   retrieving revision 1.83
>   retrieving revision 1.84
>   diff -u -r1.83 -r1.84
>   --- project.xml	23 Oct 2002 11:00:31 -0000	1.83
>   +++ project.xml	30 Oct 2002 11:54:11 -0000	1.84
>   @@ -345,6 +345,12 @@
>          <version>SNAPSHOT</version>
>        </dependency>
> 
>   +    <!-- http server taglib -->
>   +    <dependency>
>   +      <id>jetty</id>
>   +      <version>4.1-rc6</version>
>   +    </dependency>
>   +
>    	<!-- jms taglib -->
>        <dependency>
>          <id>commons-messenger</id>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/httpContext.jelly
> 
>   Index: httpContext.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value="/contextTest"/>
>       <j:set var="testPort" value="8100"/>
>       <j:set var="testUri"
>
value="http://localhost:${testPort}${contextPathVar}/contextTest.txt"/>
> 
>       <jettyHttpServer var="httpServer">
>         <socketListener port="${testPort}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/contextTest"/>
>       </jettyHttpServer>
> 
>       <http:get var="mtc" uri="${testUri}"/>
> 
>       <j:if test='${mtc.statusCode == 200}'>
>           ${mtc.responseBodyAsString}
>       </j:if>
>       <j:if test='${mtc.statusCode != 200}'>
>           Results for mtc url are:
>           http return code = ${mtc.statusCode}
>           http status text = '${mtc.statusText}'
>           size of result = ${mtc.responseBodyAsString.length()}
>           response time = ${mtc.responseTime}
> 
>               <j:forEach items="${mtc.responseHeaders}" var="header"
> indexVar="i">
>                   header[${i}] = ${header}
>               </j:forEach>
>       </j:if>
>       ${httpServer.stop(false)}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/securityHandlerUna
ut
> horized.jelly
> 
>   Index: securityHandlerUnauthorized.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value="/resourceHandlerTest"/>
>       <j:set var="testPort" value="8100"/>
>       <j:set var="testUri"
>
value="http://localhost:${testPort}${contextPathVar}/resourceHandlerTest
.t
> xt"/>
> 
>       <jettyHttpServer var="httpServerUnauthorized">
>         <socketListener port="${testPort}"/>
>         <realm name="Demo Realm" config="setup/demoRealm.properties"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest" realmName="Demo Realm">
>             <securityHandler>
>               <constraints>
> 
>                 <security-constraint>
>                   <web-resource-collection>
>                    <web-resource-name>Default</web-resource-name>
>                     <url-pattern>/</url-pattern>
>                   </web-resource-collection>
>                   <auth-constraint>
>                     <role-name>*</role-name>
>                   </auth-constraint>
>                 </security-constraint>
> 
>                 <login-config>
>                   <auth-method>BASIC</auth-method>
>                   <realm-name>Demo Realm</realm-name>
>                 </login-config>
> 
>               </constraints>
>             </securityHandler>
> 
>             <resourceHandler/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <!-- get with no authentication should fail with Unauthorized
-->
>       <http:get var="mtc1" uri="${testUri}"/>
> 
>       <j:choose>
>         <j:when test="${mtc1.statusCode == 401}">
>             <!-- get with authentication in controlled area should
work-->
>             <http:get var="mtc2" uri="${testUri}">
>                <http:header name="Authorization" value="Basic
> QWxhZGRpbjpvcGVuIHNlc2FtZQ=="/>
>             </http:get>
>             <j:choose>
>                 <j:when test="${mtc2.statusCode == 200}">
>                     It works!
>                 </j:when>
>                 <j:otherwise>
>                   Results for mtc2 url are:
>                   http return code = ${mtc2.statusCode}
>                   http status text = '${mtc2.statusText}'
>                 </j:otherwise>
>             </j:choose>
>         </j:when>
> 
>         <j:otherwise>
>           Results for mtc1 url are:
>           http return code = ${mtc1.statusCode}
>           http status text = '${mtc1.statusText}'
>         </j:otherwise>
>       </j:choose>
>       ${httpServerUnauthorized.stop(false)}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/securityHandlerFor
bi
> dden.jelly
> 
>   Index: securityHandlerForbidden.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value="/"/>
>       <j:set var="testPort" value="8100"/>
>       <j:set var="forbiddenUri"
> value="http://localhost:${testPort}/noaccess"/>
> 
>       <jettyHttpServer var="httpServerForbidden">
>         <socketListener port="${testPort}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot">
>             <securityHandler>
>               <constraints>
> 
>                 <security-constraint>
>                   <web-resource-collection>
>                     <web-resource-name>Forbidden</web-resource-name>
>                     <url-pattern>/*</url-pattern>
>                   </web-resource-collection>
>                   <auth-constraint>
>                   </auth-constraint>
>                 </security-constraint>
> 
>               </constraints>
>             </securityHandler>
> 
>             <resourceHandler/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <!-- get should always be forbidden -->
>       <http:get var="mtc" uri="${forbiddenUri}"/>
> 
>       <j:choose>
>         <j:when test="${mtc.statusCode == 403}">
>             It works!
>         </j:when>
> 
>         <j:otherwise>
>           Results for mtc url are:
>           http return code = ${mtc.statusCode}
>           http status text = '${mtc.statusText}'
>         </j:otherwise>
>       </j:choose>
>       ${httpServerForbidden.stop(false)}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/jellyResourceHandl
er
> .jelly
> 
>   Index: jellyResourceHandler.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value="/resourceHandlerTest"/>
>       <j:set var="testPort1" value="8100"/>
>       <j:set var="testPort2" value="8200"/>
>       <j:set var="testUri1"
>
value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTes
t.
> txt"/>
>       <j:set var="testUri2"
>
value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTes
t.
> txt"/>
> 
>       <jettyHttpServer var="httpServerNoOp">
>         <socketListener port="${testPort1}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest">
>             <jellyResourceHandler/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <jettyHttpServer var="httpServerOp">
>         <socketListener port="${testPort2}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest">
>             <jellyResourceHandler>
> 
>               <getRequest>
>                   <j:set var="new.content.type" value="text/plain"/>
>                   <j:set var="new.location" value="new location"/>
> 
>                   <responseHeader name="Content-Type"
> value="${new.content.type}"/>
>                   <responseHeader name="Location"
> value="${new.location}"/>
>                   <responseBody>
>                       It works!
>                   </responseBody>
> 
>               </getRequest>
> 
>             </jellyResourceHandler>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <http:get var="mtc1" uri="${testUri1}"/>
>       <j:choose>
>         <j:when test="${mtc1.statusCode == 404}">
>             <http:get var="mtc2" uri="${testUri2}"/>
>             <j:choose>
>                 <j:when test="${mtc2.statusCode == 200}">
>                   It works!
>                 </j:when>
>                 <j:otherwise>
>                   Results for mtc2 url are:
>                   http return code = ${mtc2.statusCode}
>                   http status text = '${mtc2.statusText}'
>                   Content-Type =
${mtc2.getResponseHeader("Content-Type")}
>                   Location = ${mtc2.getResponseHeader("Location")}
>                 </j:otherwise>
>               </j:choose>
>         </j:when>
> 
>         <j:otherwise>
>           Results for mtc1 url are:
>           http return code = ${mtc1.statusCode}
>           http status text = '${mtc1.statusText}'
>         </j:otherwise>
>       </j:choose>
> 
>       ${httpServerNoOp.stop(false)}
>       ${httpServerOp.stop(false)}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/resourceHandler.je
ll
> y
> 
>   Index: resourceHandler.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value="/resourceHandlerTest"/>
>       <j:set var="testPort1" value="8100"/>
>       <j:set var="testPort2" value="8200"/>
>       <j:set var="testUri"
>
value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTes
t.
> txt"/>
>       <j:set var="bogusUri"
> value="http://localhost:${testPort1}${contextPathVar}/zzz"/>
>       <j:set var="testUriHeadOnly"
>
value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTes
t.
> txt"/>
> 
>       <jettyHttpServer var="httpServerDefault">
>         <socketListener port="${testPort1}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest">
>             <resourceHandler/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <jettyHttpServer var="httpServerHeadOnly">
>         <socketListener port="${testPort2}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest">
>             <resourceHandler allowedMethods="OPTIONS,DELETE, HEAD"/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <http:get var="mtc1" uri="${testUri}"/>
> 
>       <!-- if get to default works and bogus uri returns 404
>            and a head request to the head only resource handler works
>            when a get fails then all is ok -->
>       <j:if test='${mtc1.statusCode == 200}'>
>           <http:get var="mtc2" uri="${bogusUri}"/>
>           <j:if test='${mtc2.statusCode == 404}'>
>               <http:head var="mtc3" uri="${testUriHeadOnly}"/>
>               <j:if test='${mtc3.statusCode == 200}'>
>                   <http:get var="mtc4" uri="${testUriHeadOnly}"/>
>                   <j:if test='${mtc4.statusCode == 405}'>
>                       It works!
>                   </j:if>
>               </j:if>
>           </j:if>
>           <j:if test='${mtc2.statusCode != 404}'>
>               Results for mtc2 url are:
>               http return code = ${mtc2.statusCode}
>               http status text = '${mtc2.statusText}'
>               size of result = ${mtc2.responseBodyAsString.length()}
>               response time = ${mtc2.responseTime}
> 
>                   <j:forEach items="${mtc2.responseHeaders}"
var="header"
> indexVar="i">
>                       header[${i}] = ${header}
>                   </j:forEach>
>           </j:if>
>       </j:if>
>       <j:if test='${mtc1.statusCode != 200}'>
>           Results for mtc1 url are:
>           http return code = ${mtc1.statusCode}
>           http status text = '${mtc1.statusText}'
>           size of result = ${mtc1.responseBodyAsString.length()}
>           response time = ${mtc1.responseTime}
> 
>               <j:forEach items="${mtc1.responseHeaders}" var="header"
> indexVar="i">
>                   header[${i}] = ${header}
>               </j:forEach>
>       </j:if>
>       ${httpServerHeadOnly.stop(false)}
>       ${httpServerDefault.stop(false)}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/securityHandler.je
ll
> y
> 
>   Index: securityHandler.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value="/resourceHandlerTest"/>
>       <j:set var="testPort1" value="8100"/>
>       <j:set var="testPort2" value="8200"/>
>       <j:set var="testUri1"
>
value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTes
t.
> txt"/>
>       <j:set var="testUri2"
>
value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTes
t.
> txt"/>
> 
>       <jettyHttpServer var="httpServerNoAccess">
>         <socketListener port="${testPort1}"/>
>         <realm name="Demo Realm" config="setup/demoRealm.properties"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest" realmName="Demo Realm">
>             <securityHandler>
>               <constraints>
> 
>                 <security-constraint>
>                   <web-resource-collection>
>                    <web-resource-name>Default</web-resource-name>
>                     <url-pattern>/</url-pattern>
>                   </web-resource-collection>
>                   <auth-constraint>
>                     <role-name>*</role-name>
>                   </auth-constraint>
>                 </security-constraint>
> 
>                 <login-config>
>                   <auth-method>BASIC</auth-method>
>                   <realm-name>Demo Realm</realm-name>
>                 </login-config>
> 
>               </constraints>
>             </securityHandler>
> 
>             <resourceHandler/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <jettyHttpServer var="httpServerAllowAccess">
>         <socketListener port="${testPort2}"/>
>         <httpContext contextPath="${contextPathVar}"
> resourceBase="./docRoot/resourceHandlerTest">
>             <securityHandler>
>               <constraints>
> 
>                 <security-constraint>
>                   <web-resource-collection>
>                    <web-resource-name>Resource Handler
Test</web-resource-
> name>
>                     <url-pattern>/resourceHandlerTest/*</url-pattern>
>                     <http-method>GET</http-method>
>                     <http-method>HEAD</http-method>
>                   </web-resource-collection>
>                 </security-constraint>
> 
>                 <security-constraint>
>                   <web-resource-collection>
>                    <web-resource-name>Default</web-resource-name>
>                     <url-pattern>/</url-pattern>
>                   </web-resource-collection>
>                   <auth-constraint/>
>                 </security-constraint>
> 
>               </constraints>
>             </securityHandler>
> 
>             <resourceHandler/>
>         </httpContext>
>       </jettyHttpServer>
> 
>       <!-- get with no authentication should fail-->
>       <http:get var="mtc1" uri="${testUri1}"/>
> 
>       <j:choose>
>         <j:when test="${mtc1.statusCode == 403}">
>             <!-- get with no authentication in allowed area should
work-->
>             <http:get var="mtc2" uri="${testUri2}"/>
>             <j:choose>
>                 <j:when test="${mtc2.statusCode == 200}">
>                     <!-- get with authentication in controlled area
should
> work-->
>                     <http:get var="mtc3" uri="${testUri1}">
>                        <http:header name="Authorization" value="Basic
> QWxhZGRpbjpvcGVuIHNlc2FtZQ=="/>
>                     </http:get>
>                     <j:choose>
>                         <j:when test="${mtc3.statusCode == 200}">
>                             It works!
>                         </j:when>
>                         <j:otherwise>
>                           Results for mtc3 url are:
>                           http return code = ${mtc3.statusCode}
>                           http status text = '${mtc3.statusText}'
>                         </j:otherwise>
>                     </j:choose>
>                 </j:when>
> 
>                 <j:otherwise>
>                   Results for mtc2 url are:
>                   http return code = ${mtc2.statusCode}
>                   http status text = '${mtc2.statusText}'
>                 </j:otherwise>
>             </j:choose>
> 
>         </j:when>
> 
>         <j:otherwise>
>           Results for mtc1 url are:
>           http return code = ${mtc1.statusCode}
>           http status text = '${mtc1.statusText}'
>         </j:otherwise>
>       </j:choose>
>       ${httpServerAllowAccess.stop(false)}
>       ${httpServerNoAccess.stop(false)}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/socketListener.jel
ly
> 
>   Index: socketListener.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns:http="jelly:http"
>       xmlns="jelly:jetty"
>       trim="false">
> 
>       <j:set var="contextPathVar" value=""/>
>       <j:set var="testPort1" value="8100"/>
>       <j:set var="testPort2" value="8200"/>
>       <j:set var="testUri1"
> value="http://localhost:${testPort1}${contextPathVar}/test1.txt"/>
>       <j:set var="testUri2"
> value="http://localhost:${testPort2}${contextPathVar}/test1.txt"/>
> 
>       <jettyHttpServer var="httpServer1">
>         <socketListener/>
>       </jettyHttpServer>
> 
>       <jettyHttpServer var="httpServer2">
>         <socketListener port="${testPort2}"/>
>       </jettyHttpServer>
> 
>       <http:get var="mtc1" uri="${testUri1}"/>
>       <http:get var="mtc2" uri="${testUri2}"/>
> 
>       <j:if test='${mtc1.statusCode == 200}'>
>           <j:if test='${mtc2.statusCode == 200}'>
>               <j:if test='${mtc2.responseBodyAsString ==
> mtc1.responseBodyAsString}'>
>                   ${mtc2.responseBodyAsString}
>               </j:if>
>           </j:if>
>       </j:if>
>       <j:if test='${mtc1.statusCode != 200}'>
>           Results for mtc1 url are:
>           http return code = ${mtc1.statusCode}
>           http status text = '${mtc1.statusText}'
>           size of result = ${mtc1.responseBodyAsString.length()}
>           response time = ${mtc1.responseTime}
> 
>               <j:forEach items="${mtc1.responseHeaders}" var="header"
> indexVar="i">
>                   header[${i}] = ${header}
>               </j:forEach>
>       </j:if>
>       <j:if test='${mtc2.statusCode != 200}'>
>           Results for mtc2 url are:
>           http return code = ${mtc2.statusCode}
>           http status text = '${mtc2.statusText}'
>           size of result = ${mtc2.responseBodyAsString.length()}
>           response time = ${mtc2.responseTime}
> 
>               <j:forEach items="${mtc2.responseHeaders}" var="header"
> indexVar="i">
>                   header[${i}] = ${header}
>               </j:forEach>
>       </j:if>
>       ${httpServer2.stop()}
>       ${httpServer1.stop()}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/defaultServer.jell
y
> 
>   Index: defaultServer.jelly
>   ===================================================================
>   <?xml version="1.0"?>
>   <j:jelly
>       xmlns:j="jelly:core"
>       xmlns="jelly:jetty"
>       xmlns:http="jelly:http"
>       trim="false">
> 
>       <j:set var="contextPathVar" value=""/>
>       <j:set var="testPort" value="8100"/>
>       <j:set var="testUri"
> value="http://localhost:${testPort}${contextPathVar}/test1.txt"/>
> 
>       <jettyHttpServer var="httpServer"/>
> 
>       <http:get var="mtc" uri="${testUri}"/>
>       <j:if test='${mtc.statusCode == 200}'>
>           ${mtc.responseBodyAsString}
>       </j:if>
>       <j:if test='${mtc.statusCode != 200}'>
>           Results for mtc url are:
>           http return code = ${mtc.statusCode}
>           http status text = '${mtc.statusText}'
>           size of result = ${mtc.responseBodyAsString.length()}
>           response time = ${mtc.responseTime}
> 
>               <j:forEach items="${mtc.responseHeaders}" var="header"
> indexVar="i">
>                   header[${i}] = ${header}
>               </j:forEach>
>       </j:if>
>       ${httpServer.stop()}
> 
>   </j:jelly>
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/TestJettyHttpServe
rT
> ags.java
> 
>   Index: TestJettyHttpServerTags.java
>   ===================================================================
>   /*
>    * $Header: /home/cvs/jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/TestJettyHttpServerTags.
ja
> va,v 1.6 2002/05/15 07:47:50 jstrachan Exp $
>    * $Revision: 1.6 $
>    * $Date: 2002/05/15 07:47:50 $
>    *
>    *
====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2002 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 acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
> itself,
>    *    if and wherever such third-party acknowlegements normally
appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
>    *    permission of the Apache Group.
>    *
>    * 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/>.
>    *
>    * $Id: TestJettyHttpServerTags.java,v 1.6 2002/05/15 07:47:50
jstrachan
> Exp $
>    */
>   package org.apache.commons.jelly.jetty;
> 
>   import java.io.File;
>   import java.io.FileInputStream;
>   import java.io.InputStream;
>   import java.io.IOException;
>   import java.io.StringWriter;
>   import java.util.Iterator;
>   import java.util.List;
> 
>   import junit.framework.Test;
>   import junit.framework.TestCase;
>   import junit.framework.TestSuite;
>   import junit.textui.TestRunner;
> 
>   import org.apache.commons.jelly.JellyContext;
>   import org.apache.commons.jelly.Script;
>   import org.apache.commons.jelly.XMLOutput;
>   import org.apache.commons.jelly.parser.XMLParser;
> 
>   import org.apache.commons.logging.Log;
>   import org.apache.commons.logging.LogFactory;
> 
>   import org.dom4j.Document;
>   import org.dom4j.DocumentHelper;
>   import org.dom4j.Node;
> 
>   /** Tests the parser, the engine and the XML tags
>     *
>     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
>     * @version $Revision: 1.6 $
>     */
>   public class TestJettyHttpServerTags extends TestCase {
> 
>       /** The Log to which logging calls will be made. */
>       private static final Log log =
> LogFactory.getLog(TestJettyHttpServerTags.class);
> 
>       public static void main(String[] args) {
>           TestRunner.run(suite());
>       }
> 
>       public static Test suite() {
>           return new TestSuite(TestJettyHttpServerTags.class);
>       }
> 
>       public TestJettyHttpServerTags(String testName) {
>           super(testName);
>       }
> 
>       public void testDefaultServer() throws Exception {
>           String text = evaluteScriptAsText(
> 
> "src/test/org/apache/commons/jelly//jetty/defaultServer.jelly"
>           );
>           assertEquals("Produces the correct output", "It works!",
text);
>       }
> 
>       public void testSocketListener() throws Exception {
>           String text = evaluteScriptAsText(
> 
> "src/test/org/apache/commons/jelly//jetty/socketListener.jelly"
>           );
>           assertEquals("Produces the correct output", "It works!",
text);
>       }
> 
>       public void testHttpContext() throws Exception {
>           String text = evaluteScriptAsText(
>
"src/test/org/apache/commons/jelly//jetty/httpContext.jelly"
>           );
>           assertEquals("Produces the correct output", "It works!",
text);
>       }
> 
>       public void testResourceHandler() throws Exception {
>           String text = evaluteScriptAsText(
> 
> "src/test/org/apache/commons/jelly//jetty/resourceHandler.jelly"
>           );
>           assertEquals("Produces the correct output", "It works!",
text);
>       }
> 
>       public void testSecurityHandler() throws Exception {
>           String text = evaluteScriptAsText(
> 
>
"src/test/org/apache/commons/jelly//jetty/securityHandlerForbidden.jelly
"
>           );
>           assertEquals("Forbidden test produces the correct output",
"It
> works!", text);
> 
>           text = evaluteScriptAsText(
> 
>
"src/test/org/apache/commons/jelly//jetty/securityHandlerUnauthorized.je
ll
> y"
>           );
>           assertEquals("Unauthorized produces the correct output", "It
> works!", text);
>       }
> 
>       public void testJellyResourceHandler() throws Exception {
>           String text = evaluteScriptAsText(
> 
> "src/test/org/apache/commons/jelly//jetty/jellyResourceHandler.jelly"
>           );
>           assertEquals("Produces the correct output", "It works!",
text);
>       }
> 
>       /**
>        * Evaluates the script by the given file name and
>        * returns the whitespace trimmed output as text
>        */
>       protected String evaluteScriptAsText(String fileName) throws
> Exception {
>           JellyContext context = new JellyContext();
> 
>           // allow scripts to refer to any resource inside this
project
>           // using an absolute URI like /src/test/org/apache/foo.xml
>           context.setRootURL(new File(".").toURL());
> 
>           // cature the output
>           StringWriter buffer = new StringWriter();
>           XMLOutput output = XMLOutput.createXMLOutput(buffer);
> 
>           context.runScript( new File(fileName), output );
>           String text = buffer.toString().trim();
>           if (log.isDebugEnabled()) {
>               log.debug("Evaluated script as...");
>               log.debug(text);
>           }
>           return text;
>       }
>   }
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/setup/demoRealm.pr
op
> erties
> 
>   Index: demoRealm.properties
>   ===================================================================
>   #
>   # This file defines users passwords and roles for a HashUserRealm
>   #
>   # The format is
>   #  <username>: <password>[,<rolename> ...]
>   #
>   # Passwords may be clear text, obfuscated or checksummed.  The class
>   # com.mortbay.Util.Password should be used to generate obfuscated
>   # passwords or password checksums
>   #
>   # If DIGEST Authentication is used, the password must be in a
> recoverable
>   # format, either plain text or OBF:.
>   #
> 
>   test: test
>   Aladdin: open sesame
> 
> 
>   1.27      +2 -0      jakarta-commons-
> sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
> 
>   Index: jelly.properties
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons-
> sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
>   retrieving revision 1.26
>   retrieving revision 1.27
>   diff -u -r1.26 -r1.27
>   --- jelly.properties	16 Oct 2002 12:45:51 -0000	1.26
>   +++ jelly.properties	30 Oct 2002 11:54:11 -0000	1.27
>   @@ -30,3 +30,5 @@
>    interaction =
> org.apache.commons.jelly.tags.interaction.InteractionTagLibrary
>    antlr       = org.apache.commons.jelly.tags.antlr.AntlrTagLibrary
>    quartz      = org.apache.commons.jelly.tags.quartz.QuartzTagLibrary
>   +http        = org.apache.commons.jelly.tags.http.HttpTagLibrary
>   +jetty       = org.apache.commons.jelly.tags.jetty.JettyTagLibrary
> 
> 
> 
>   1.2       +1 -1      jakarta-commons-
> sandbox/jelly/src/test/org/apache/commons/jelly/http/http.jelly
> 
>   Index: http.jelly
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons-
> sandbox/jelly/src/test/org/apache/commons/jelly/http/http.jelly,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- http.jelly	27 Sep 2002 02:18:34 -0000	1.1
>   +++ http.jelly	30 Oct 2002 11:54:11 -0000	1.2
>   @@ -1,7 +1,7 @@
>    <?xml version="1.0"?>
> 
>    <j:jelly
> 
>        xmlns:j="jelly:core"
> 
>   -    xmlns="jelly:org.apache.commons.jelly.tags.http.HttpTagLibrary"
> 
>   +    xmlns="jelly:http"
> 
>        trim="false">
> 
>        <!-- a session holds shared http state info
> 
>        <session> -->
> 
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot/contextTes
t/
> contextTest.txt
> 
>   Index: contextTest.txt
>   ===================================================================
>   It works!
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHa
nd
> lerTest/resourceHandlerTest.txt
> 
>   Index: resourceHandlerTest.txt
>   ===================================================================
>   It works!
> 
> 
> 
>   1.1                  jakarta-commons-
>
sandbox/jelly/src/test/org/apache/commons/jelly/jetty/docRoot/test1.txt
> 
>   Index: test1.txt
>   ===================================================================
>   It works!
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-
> help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>