remm        01/09/08 14:46:14

  Modified:    src/wrappers/catalina SlideServerListener.java server.xml
  Added:       src/wrappers/catalina ManagerHost.java slidemanager.xml
  Log:
  - Add placeholder for Slide manager webapp.
  - The namespace is passed to the webapp as the "org.apache.slide.Namespace"
    servlet context attribute.
  
  Revision  Changes    Path
  1.2       +8 -7      jakarta-slide/src/wrappers/catalina/SlideServerListener.java
  
  Index: SlideServerListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/wrappers/catalina/SlideServerListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SlideServerListener.java  2001/09/08 20:03:12     1.1
  +++ SlideServerListener.java  2001/09/08 21:46:14     1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/wrappers/catalina/SlideServerListener.java,v 1.1 
2001/09/08 20:03:12 remm Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/09/08 20:03:12 $
  + * $Header: 
/home/cvs/jakarta-slide/src/wrappers/catalina/SlideServerListener.java,v 1.2 
2001/09/08 21:46:14 remm Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/09/08 21:46:14 $
    *
    * ====================================================================
    *
  @@ -103,7 +103,7 @@
    * Server listener responsible for setting up the Slide domain.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.1 $ $Date: 2001/09/08 20:03:12 $
  + * @version $Revision: 1.2 $ $Date: 2001/09/08 21:46:14 $
    */
   public class SlideServerListener
       implements LifecycleListener {
  @@ -336,9 +336,10 @@
                   } else if (host instanceof WebdavHost) {
                       System.out.println("Set domain for Webdav host");
                       ((WebdavHost) host).setDomain(domain);
  -                }/* else if (host instanceof SlideManagerHost) {
  -                    ((SlideManagerHost) host).setDomain(domain);
  -                    }*/
  +                } else if (host instanceof ManagerHost) {
  +                    System.out.println("Set domain for Slide manager host");
  +                    ((ManagerHost) host).setDomain(domain);
  +                }
   
               }
   
  
  
  
  1.3       +2 -1      jakarta-slide/src/wrappers/catalina/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/wrappers/catalina/server.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- server.xml        2001/09/08 20:03:12     1.2
  +++ server.xml        2001/09/08 21:46:14     1.3
  @@ -135,7 +135,8 @@
                 timestamp="true"/>
   
         <!-- Define the default virtual host -->
  -      <Host name="localhost" debug="0" appBase="manager" unpackWARs="false">
  +      <Host name="localhost" debug="0" appBase="blank" unpackWARs="false"
  +       className="wrappers.catalina.ManagerHost">
   
           <Valve className="org.apache.catalina.valves.AccessLogValve"
                    directory="logs"  prefix="manager_access_log." suffix=".txt"
  
  
  
  1.1                  jakarta-slide/src/wrappers/catalina/ManagerHost.java
  
  Index: ManagerHost.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/wrappers/catalina/ManagerHost.java,v 1.1 
2001/09/08 21:46:14 remm Exp $
   * $Revision: 1.1 $
   * $Date: 2001/09/08 21:46:14 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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 [EMAIL PROTECTED]
   *
   * 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/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package wrappers.catalina;
  
  
  import java.io.BufferedOutputStream;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.net.JarURLConnection;
  import java.net.URL;
  import java.net.MalformedURLException;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.jar.JarEntry;
  import java.util.jar.JarFile;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.catalina.Container;
  import org.apache.catalina.Context;
  import org.apache.catalina.Deployer;
  import org.apache.catalina.Globals;
  import org.apache.catalina.HttpRequest;
  import org.apache.catalina.Host;
  import org.apache.catalina.Lifecycle;
  import org.apache.catalina.LifecycleException;
  import org.apache.catalina.LifecycleListener;
  import org.apache.catalina.Request;
  import org.apache.catalina.Response;
  import org.apache.catalina.core.DefaultContext;
  import org.apache.catalina.core.StandardHost;
  import org.apache.catalina.core.ApplicationContext;
  
  import org.apache.slide.common.EmbeddedDomain;
  import org.apache.slide.common.Namespace;
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.webdav.WebdavServlet;
  
  /**
   * Slide manager implementation of Host.
   *
   * @author Remy Maucherat
   * @version $Revision: 1.1 $ $Date: 2001/09/08 21:46:14 $
   */
  
  public class ManagerHost
      extends StandardHost
      implements Deployer, Host {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Create a new ManagerHost component with the default basic Valve.
       */
      public ManagerHost() {
  
        super();
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * Slide domain.
       */
      EmbeddedDomain domain;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Domain setter.
       */
      public void setDomain(EmbeddedDomain domain) {
          this.domain = domain;
      }
  
  
      /**
       * Domain getter.
       */
      public EmbeddedDomain getDomain() {
          return domain;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Prepare for active use of the public methods of this Component.
       *
       * @exception IllegalStateException if this component has already been
       *  started
       * @exception LifecycleException if this component detects a fatal error
       *  that prevents it from being started
       */
      public synchronized void start() throws LifecycleException {
          
          String defaultNamespace = domain.getDefaultNamespace();
          
          Enumeration namespaceNames = domain.enumerateNamespaces();
          while (namespaceNames.hasMoreElements()) {
              String name = (String) namespaceNames.nextElement();
              try {
                  File managerWar = new File("manager/manager.war");
                  install("/" + name, managerWar.toURL());
                  if (name.equals(defaultNamespace)) {
                      // Also install the deafult namespace as the root context
                      install("", managerWar.toURL());
                  }
              } catch (IOException e) {
                  // Can't happen
                  e.printStackTrace();
              }
          }
          
          super.start();
          
      }
  
  
      // ------------------------------------------------------- Deployer Methods
  
  
      /**
       * Install a new web application, whose web application archive is at the
       * specified URL, into this container with the specified context path.
       * A context path of "" (the empty string) should be used for the root
       * application for this container.  Otherwise, the context path must
       * start with a slash.
       * <p>
       * If this application is successfully installed, a ContainerEvent of type
       * <code>INSTALL_EVENT</code> will be sent to all registered listeners,
       * with the newly created <code>Context</code> as an argument.
       *
       * @param contextPath The context path to which this application should
       *  be installed (must be unique)
       * @param war A URL of type "jar:" that points to a WAR file, or type
       *  "file:" that points to an unpacked directory structure containing
       *  the web application to be installed
       *
       * @exception IllegalArgumentException if the specified context path
       *  is malformed (it must be "" or start with a slash)
       * @exception IllegalArgumentException if the specified context path
       *  is already attached to an existing web application
       * @exception IOException if an input/output error was encountered
       *  during install
       */
      public void install(String contextPath, URL war) throws IOException {
  
          // Validate the format and state of our arguments
          if (contextPath == null)
              throw new IllegalArgumentException
                  (sm.getString("standardHost.pathRequired"));
          if (!contextPath.equals("") && !contextPath.startsWith("/"))
              throw new IllegalArgumentException
                  (sm.getString("standardHost.pathFormat", contextPath));
          if (findDeployedApp(contextPath) != null)
              throw new IllegalArgumentException
                  (sm.getString("standardHost.pathUsed", contextPath));
          if (war == null)
              throw new IllegalArgumentException
                  (sm.getString("standardHost.warRequired"));
  
          // Prepare the local variables we will require
          String url = war.toString();
          String docBase = null;
          log(sm.getString("standardHost.installing", contextPath, url));
  
          if (url.startsWith("jar:")) {
              url = url.substring(4, url.length() - 2);
          }
          if (url.startsWith("file://"))
              docBase = url.substring(7);
          else if (url.startsWith("file:"))
              docBase = url.substring(5);
          else
              throw new IllegalArgumentException
                  (sm.getString("standardHost.warURL", url));
          
          // Install this new web application
          try {
  
              Class clazz = Class.forName(getContextClass());
              Context context = (Context) clazz.newInstance();
              context.setPath(contextPath);
              context.setDocBase(docBase);
  
              String namespaceName = contextPath;
              while (namespaceName.startsWith("/")) {
                  namespaceName = namespaceName.substring(1);
              }
              if (namespaceName.equals("")) {
                  namespaceName = domain.getDefaultNamespace();
              }
  
              NamespaceAccessToken accessToken = 
                  domain.getNamespaceToken(namespaceName);
  
              SlideRealm slideRealm = new SlideRealm();
              slideRealm.setAccessToken(accessToken);
              slideRealm.setNamespace(namespaceName);
              context.setRealm(slideRealm);
  
              context.getServletContext().setAttribute
                  (WebdavServlet.ATTRIBUTE_NAME, accessToken);
              ((ApplicationContext) context.getServletContext())
                  .setAttributeReadOnly(WebdavServlet.ATTRIBUTE_NAME);
  
              Namespace namespace = domain.getNamespace(namespaceName);
  
              context.getServletContext().setAttribute
                  ("org.apache.slide.Namespace", namespace);
              ((ApplicationContext) context.getServletContext())
                  .setAttributeReadOnly("org.apache.slide.Namespace");
  
              if (context instanceof Lifecycle) {
                  clazz = Class.forName(getConfigClass());
                  LifecycleListener listener =
                      (LifecycleListener) clazz.newInstance();
                  ((Lifecycle) context).addLifecycleListener(listener);
              }
              addChild(context);
  
            fireContainerEvent(INSTALL_EVENT, context);
  
          } catch (Exception e) {
              log(sm.getString("standardHost.installError", contextPath), e);
              throw new IOException(e.toString());
          }
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-slide/src/wrappers/catalina/slidemanager.xml
  
  Index: slidemanager.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd";>
  
  <web-app>
  </web-app>
  
  
  

Reply via email to