geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: incubator-geronimo/modules/web/src/java/org/apache/geronimo/web WebAccessLog.java AbstractWebApplication.java AbstractWebContainer.java WebApplication.java WebContainer.java
Date Sat, 23 Aug 2003 09:38:05 GMT
janb        2003/08/23 02:38:04

  Modified:    modules/web/src/java/org/apache/geronimo/web
                        AbstractWebApplication.java
                        AbstractWebContainer.java WebApplication.java
                        WebContainer.java
  Added:       modules/web/src/java/org/apache/geronimo/web
                        WebAccessLog.java
  Log:
  Fleshing out more methods.
  
  Revision  Changes    Path
  1.3       +163 -17   incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebApplication.java
  
  Index: AbstractWebApplication.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebApplication.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractWebApplication.java	21 Aug 2003 14:36:22 -0000	1.2
  +++ AbstractWebApplication.java	23 Aug 2003 09:38:04 -0000	1.3
  @@ -58,6 +58,15 @@
   
   import java.net.URI;
   
  +import javax.naming.Context;
  +import javax.naming.InitialContext;
  +import javax.naming.LinkRef;
  +import javax.naming.NamingException;
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.xml.parsers.FactoryConfigurationError;
  +import javax.xml.parsers.ParserConfigurationException;
  +
   import org.apache.geronimo.common.AbstractComponent;
   import org.w3c.dom.Document;
   
  @@ -66,8 +75,7 @@
    * AbstractWebApplication
    *  
    * Instances are created by a deployer. The deployer finds the 
  - * WebContainer and associates it with the WebApplication, then calls
  - *  deploy() on the container passing in the identity of the WebApplication.
  + * WebContainer and associates it with the WebApplication.
    * 
    * 
    * @version $Revision$ $Date$
  @@ -76,8 +84,46 @@
       extends AbstractComponent
       implements WebApplication
   {
  +    /**
  +     * Class loading delegation model 
  +     */
  +    private boolean java2ClassloadingCompliance = false;
   
  -    
  +    private URI warURI = null;
  +    private URI webXmlURI = null;
  +    private Document webXmlDoc = null;
  +    private DocumentBuilder parser = null;
  +
  +    private URI geronimoXmlURI = null;
  +    private Document geronimoXmlDoc = null;
  +    private Context initialContext = null;
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**
  +     * Constructor
  +     *
  +     */
  +    public AbstractWebApplication()
  +    {
  +        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  +        try
  +        {
  +            parser = factory.newDocumentBuilder();
  +            initialContext = new InitialContext();
  +        }
  +        catch (FactoryConfigurationError e)
  +        {
  +            throw new AssertionError("No XML parser available");
  +        }
  +        catch (ParserConfigurationException e)
  +        {
  +            throw new AssertionError("No XML parser available");
  +        }
  +        catch (NamingException e)
  +        {
  +            throw new AssertionError("No initial JNDI context");
  +        }
  +    }
   
       /* --------------------------------------------------------------------------------------
*/
       /* Start the webapp. Called by the container or management interface
  @@ -85,13 +131,13 @@
        * @throws IllegalStateException
        * @see org.apache.geronimo.common.Component#start()
        */
  -    public void doStart() 
  -        throws Exception
  +    public void doStart() throws Exception
       {
           if (getContainer() == null)
               throw new IllegalStateException("WebApplication must have a container set before
START can be called");
   
  -        //start the webapp
  +        // set up the JNDI context for this webapp
  +        setupENC();
       }
   
       /* --------------------------------------------------------------------------------------
*/
  @@ -133,41 +179,141 @@
        */
       public String getDeploymentDescriptor()
       {
  -        // TODO
  +        try
  +        {
  +            parseWebXml();
  +
  +        }
  +        catch (Exception e)
  +        {
  +            throw new IllegalStateException(e.toString());
  +        }
  +
           return null;
       }
   
       /* --------------------------------------------------------------------------------------
*/
  -    /* 
  +    /* Get the URI of the web.xml deployment descriptor
        * @return
        * @see org.apache.geronimo.web.WebApplication#getDeploymentDescriptorURI()
        */
       public URI getDeploymentDescriptorURI()
       {
  -        // TODO
  -        return null;
  +        return webXmlURI;
       }
   
       /* --------------------------------------------------------------------------------------
*/
  -    /* 
  +    /* Get the Document representing the web.xml descriptor
        * @return
        * @see org.apache.geronimo.web.WebApplication#getDeploymentDescriptorDocument()
        */
       public Document getDeploymentDescriptorDocument()
       {
  -        // TODO
  -        return null;
  +        try
  +        {
  +            parseWebXml();
  +            return webXmlDoc;
  +        }
  +        catch (Exception e)
  +        {
  +            throw new IllegalStateException(e.toString());
  +        }
  +
  +    }
  +
  +    public URI getGeronimoDeploymentDescriptorURI()
  +    {
  +        return geronimoXmlURI;
  +    }
  +
  +    public Document getGeronimoDeploymentDescriptorDocument()
  +    {
  +        return geronimoXmlDoc;
       }
   
  +    public String getGeronimoDeploymentDescriptor()
  +    {
  +        //TODO
  +        return null;
  +    }
       /* --------------------------------------------------------------------------------------
*/
  -    /* 
  +    /* Get the URI of the webapp itself
        * @return
        * @see org.apache.geronimo.web.WebApplication#getURI()
        */
       public URI getURI()
       {
  -        // TODO
  -        return null;
  +        return warURI;
  +    }
  +    /* --------------------------------------------------------------------------------------
*/
  +    /** Setter for classloading compliance. If true, then classloading will
  +     * delegate first to parent classloader a la Java2 spec. If false, then
  +     * webapps wanting to load class will try their own context class loader first.
  +     * @param state
  +     */
  +    public void setJava2ClassloadingCompliance(boolean state)
  +    {
  +        java2ClassloadingCompliance = state;
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Getter for classloading compliance.
  +     * @see setJava2ClassloadingCompliance
  +     * @return
  +     */
  +    public boolean getJava2ClassloadingCompliance()
  +    {
  +        return java2ClassloadingCompliance;
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /** Parse the deployment descriptor, if it hasn't been already
  +     *
  +     * @exception Exception if an error occurs
  +     */
  +    protected synchronized void parseWebXml() throws Exception
  +    {
  +        if (webXmlURI == null)
  +            return;
  +
  +        if (webXmlDoc != null)
  +            return;
  +
  +        webXmlDoc = parser.parse(webXmlURI.toString());
  +    }
  +
  +    protected synchronized void parseGeronimoXml() throws Exception
  +    {
  +        if (geronimoXmlURI == null)
  +            return;
  +        if (geronimoXmlDoc != null)
  +            return;
  +
  +        geronimoXmlDoc = parser.parse(geronimoXmlURI.toString());
  +    }
  +
  +    protected void setupENC() throws Exception
  +    {
  +        //parse the standard descriptor
  +        parseWebXml();
  +
  +        //parse the geronimo web descriptor?
  +        parseGeronimoXml();
  +
  +        //create the java:comp/env context
  +        Context enc = null;
  +        
  +        //populate the resources
  +
  +        //populate the ejbs
  +
  +        //populate the UserTransaction
  +        enc.bind ("UserTransaction",  new LinkRef ("javax.transaction.UserTransaction"));
  +        
  +        //populate the security
  +
  +        //secure the context as read-only (if necessary)
  +
       }
   
   }
  
  
  
  1.3       +138 -24   incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebContainer.java
  
  Index: AbstractWebContainer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractWebContainer.java	21 Aug 2003 15:02:45 -0000	1.2
  +++ AbstractWebContainer.java	23 Aug 2003 09:38:04 -0000	1.3
  @@ -55,48 +55,141 @@
   */
   package org.apache.geronimo.web;
   
  +import java.net.URI;
  +
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
  +
   import org.apache.geronimo.common.AbstractContainer;
   import org.apache.geronimo.common.Component;
  +import org.w3c.dom.Document;
   
  +/* --------------------------------------------------------------------------------------
*/
   /**
  + * AbstractWebContainer
  + * 
    * Base class for web containers.
    *
    * @version $Revision$ $Date$
    */
  -public class AbstractWebContainer extends AbstractContainer implements WebContainer {
  +public class AbstractWebContainer
  +    extends AbstractContainer
  +    implements WebContainer
  +{
       /**
  -     * Location of the defualt web.xml file
  +     * Location of the default web.xml file
        */
  -    private String defaultWebXmlURL;
  +    private URI defaultWebXmlURI = null;
   
       /**
  -     * Creates a WebApplication from the url and associates it with this container.
  -     * @param url the location of the web application to deploy
  -     * @throws Exception
  -     * @see org.apache.geronimo.web.WebContainer#deploy(java.lang.String)
  +     * Parsed default web.xml 
  +     */
  +    private Document defaultWebXmlDoc = null;
  +
  +
  +    /**
  +     * Controls unpacking of wars to tmp runtime location
        */
  -    public void deploy(String url) throws Exception {
  +    private boolean unpackWars = true;
  +
  +
  +    private final DocumentBuilder parser;
  +
  +
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**
  +     *  Constructor
  +     */
  +    public AbstractWebContainer()
  +    {
  +        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  +        try
  +        {
  +            parser = factory.newDocumentBuilder();
  +        }
  +        catch (Exception e)
  +        {
  +            throw new AssertionError("No XML parser available");
  +        }
       }
   
  +    /* --------------------------------------------------------------------------------------
*/
       /**
  -     * Get the URL of the web defaults.
  +    * Creates a WebApplication from the url and associates it with this container.
  +    * @param url the location of the web application to deploy
  +    * @throws Exception
  +    * @see org.apache.geronimo.web.WebContainer#deploy(java.lang.String)
  +    */
  +    public void deploy(String url) throws Exception
  +    {
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**
  +     * Get the URI of the web defaults.
        * @return the location of the default web.xml file for this container
        * @see org.apache.geronimo.web.WebContainer#getDefaultWebXmlURL()
        */
  -    public String getDefaultWebXmlURL() {
  -        return defaultWebXmlURL;
  +    public URI getDefaultWebXmlURI()
  +    {
  +        return defaultWebXmlURI;
       }
   
  -    /**
  -     * Set a url of a web.xml containing defaults for this continer.
  -     * @param url the location of the default web.xml file
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Set a uri of a web.xml containing defaults for this container.
  +     * @param uri the location of the default web.xml file
        * @see org.apache.geronimo.web.WebContainer#setDefaultWebXmlURL(java.lang.String)
        */
  -    public void setDefaultWebXmlURL(String url) {
  -        defaultWebXmlURL = url;
  +    public void setDefaultWebXmlURI(URI uri)
  +    {
  +        defaultWebXmlURI = uri;
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Get the parsed web defaults
  +     * @return
  +     */
  +    public Document getDefaultWebXmlDoc()
  +    {
  +        return defaultWebXmlDoc;
       }
  -    
  -    /* (non-Javadoc)
  +
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Parse the web defaults descriptor
  +     * @throws Exception
  +     */
  +    protected void parseWebDefaults() throws Exception
  +    {
  +        if (defaultWebXmlURI == null)
  +            return;
  +
  +        defaultWebXmlDoc = parser.parse(defaultWebXmlURI.toString());
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /* 
  +     * @return
  +     * @see org.apache.geronimo.web.WebContainer#getUnpackWars()
  +     */
  +    public boolean getUnpackWars()
  +    {
  +        return unpackWars;
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /* 
  +     * @param state
  +     * @see org.apache.geronimo.web.WebContainer#setUnpackWars(boolean)
  +     */
  +    public void setUnpackWars(boolean state)
  +    {
  +        unpackWars = state;
  +    }
  +
  +    /* --------------------------------------------------------------------------------------
*/
  +    /* Add a component to this container's containment hierarchy
        * @see org.apache.geronimo.common.Container#addComponent(org.apache.geronimo.common.Component)
        */
       public void addComponent(Component component)
  @@ -107,9 +200,12 @@
               webConnectorAdded((WebConnector)component);
           else if (component instanceof WebApplication)
               webApplicationAdded((WebApplication)component);
  +        else if (component instanceof WebAccessLog)
  +            webAccessLogAdded ((WebAccessLog)component);
       }
  -
  -    /* (non-Javadoc)
  +    
  +    /* --------------------------------------------------------------------------------------
*/
  +    /* Remove a component from this container's hierarchy
        * @see org.apache.geronimo.common.Container#removeComponent(org.apache.geronimo.common.Component)
        */
       public void removeComponent(Component component) throws Exception
  @@ -122,6 +218,8 @@
           super.removeComponent(component);
       }
       
  +    
  +    /* --------------------------------------------------------------------------------------
*/
       /**
        * Method called by addComponent after a WebConnector has been added.
        * @param connector
  @@ -130,7 +228,8 @@
       {
       }
   
  -    
  +
  +    /* --------------------------------------------------------------------------------------
*/
       /**
        * Method called by addComponment after a WebApplication has been added.
        * @param connector
  @@ -140,15 +239,24 @@
       }
       
       
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**
  +     * @param log
  +     */
  +    protected void webAccessLogAdded (WebAccessLog log)
  +    {
  +    }
  +    
  +    /* --------------------------------------------------------------------------------------
*/
       /**
  -     * Method called by addComponent before a WebConnector has been removed.
  +     * Method called by removeComponent before a WebConnector has been removed.
        * @param connector
        */
       protected void webConnectorRemoval(WebConnector connector)
       {
       }
   
  -    
  +    /* --------------------------------------------------------------------------------------
*/   
       /**
        * Method called by removeComponment before a WebApplication has been removed.
        * @param connector
  @@ -157,5 +265,11 @@
       {
       }
       
  -
  +    /* --------------------------------------------------------------------------------------
*/
  +    /** Remove an access log service from the container
  +     * @param log
  +     */
  +    protected void webAccessLogRemoval (WebAccessLog log)
  +    {
  +    }
   }
  
  
  
  1.3       +22 -1     incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/WebApplication.java
  
  Index: WebApplication.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/WebApplication.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebApplication.java	21 Aug 2003 14:36:22 -0000	1.2
  +++ WebApplication.java	23 Aug 2003 09:38:04 -0000	1.3
  @@ -94,4 +94,25 @@
       public URI getDeploymentDescriptorURI();
       
       public Document getDeploymentDescriptorDocument();
  +    
  +    public String getGeronimoDeploymentDescriptor();
  +    
  +    public URI getGeronimoDeploymentDescriptorURI();
  +    
  +    public Document getGeronimoDeploymentDescriptorDocument();
  +    
  +    /* --------------------------------------------------------------------------------------
*/
  +     /**Getter for the class loader delegation model for this webapp
  +      * @return
  +      */
  +     public boolean getJava2ClassloadingCompliance ();
  +     
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Set the class loading delegation model for this web application
  +     * @param state
  +     */
  +    public void setJava2ClassloadingCompliance (boolean state );
  +    
  +    
  + 
   }
  
  
  
  1.2       +32 -6     incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/WebContainer.java
  
  Index: WebContainer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/WebContainer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebContainer.java	18 Aug 2003 13:30:41 -0000	1.1
  +++ WebContainer.java	23 Aug 2003 09:38:04 -0000	1.2
  @@ -56,7 +56,10 @@
   
   package org.apache.geronimo.web;
   
  +import java.net.URI;
  +
   import org.apache.geronimo.common.Container;
  +import org.w3c.dom.Document;
   
   /*
    * WebContainer
  @@ -70,22 +73,45 @@
       /*--------------------------------------------------------------------------------
*/
       /** Deploy a web application. Convenience method to 
        * have the container create the WebApplication and add it to itself.
  -    * @param url 
  +    * @param uri
       * @throws Exception
       */
  -    public void deploy(String url) throws Exception;
  +    public void deploy(String uri) throws Exception;
   
       /*--------------------------------------------------------------------------------
*/
       /** Set up a web.xml descriptor for the Container to use as
        * defaults.
       * @param url 
       */
  -    public void setDefaultWebXmlURL(String url);
  +    public void setDefaultWebXmlURI(URI uri);
   
       /*--------------------------------------------------------------------------------
*/
  -    /** Get the url of the default web.xml descriptor used 
  +    /** Get the uri of the default web.xml descriptor used 
        * by this container.
       * @return
       */
  -    public String getDefaultWebXmlURL();
  +    public URI getDefaultWebXmlURI();
  +    
  +    
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Get the parsed web defaults
  +     * @return
  +     */
  +    public Document getDefaultWebXmlDoc ();
  +        
  +
  +    
  +    /* --------------------------------------------------------------------------------------
*/
  +    /** Control if wars will be unpacked to temporary location or not
  +     * @param state
  +     */
  +    public void setUnpackWars (boolean state);
  +    
  +    /* --------------------------------------------------------------------------------------
*/
  +    /**Getter for whether wars will be unpacked to temporary location or not
  +     * @return
  +     */
  +    public boolean getUnpackWars ();
  +    
  +
   }
  
  
  
  1.1                  incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/WebAccessLog.java
  
  Index: WebAccessLog.java
  ===================================================================
  /* ====================================================================
  * The Apache Software License, Version 1.1
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" and
  *    "Apache Geronimo" 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",
  *    "Apache Geronimo", nor may "Apache" appear in their name, without
  *    prior written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation.  For more
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  *
  * ====================================================================
  */
  
  
  package org.apache.geronimo.web;
  
  import java.net.URI;
  
  import org.apache.geronimo.common.Component;
  
  /* --------------------------------------------------------------------------------------
*/
  /**
   * WebAccessLog
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2003/08/23 09:38:04 $
   */
  public interface WebAccessLog extends Component
  {
      public void setLogLocation (URI uri);
      
      public URI getLogLocation ();
      
      // extendedNCSAFormat
      
      // rollover retention days
      
      // date format
      
      // append
      
      // buffering
      
  }
  
  
  

Mime
View raw message