tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming ResourceRef.java
Date Sat, 10 Nov 2001 00:01:55 GMT
craigmcc    01/11/09 16:01:55

  Modified:    catalina/src/share/org/apache/catalina/core
                        NamingContextListener.java StandardContext.java
                        StandardHostDeployer.java StandardServer.java
               catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java
               catalina/src/share/org/apache/naming ResourceRef.java
  Log:
  Reuse NamingContextListener inside StandardHostDeployer as well, so that
  resources defined in a separate context deployment descriptor file are
  recognized.
  
  Propogate some debugging state downward to help isolate any future
  problems like this.
  
  Revision  Changes    Path
  1.2       +49 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java
  
  Index: NamingContextListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NamingContextListener.java	2001/11/08 21:08:22	1.1
  +++ NamingContextListener.java	2001/11/10 00:01:54	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
1.1 2001/11/08 21:08:22 remm Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/11/08 21:08:22 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v
1.2 2001/11/10 00:01:54 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/11/10 00:01:54 $
    *
    * ====================================================================
    *
  @@ -116,7 +116,7 @@
    * with each context and server.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.1 $ $Date: 2001/11/08 21:08:22 $
  + * @version $Revision: 1.2 $ $Date: 2001/11/10 00:01:54 $
    */
   
   public class NamingContextListener
  @@ -149,6 +149,12 @@
   
   
       /**
  +     * Debugging level.
  +     */
  +    protected int debug = 0;
  +
  +
  +    /**
        * Initialized flag.
        */
       protected boolean initialized = false;
  @@ -189,6 +195,28 @@
   
   
       /**
  +     * Return the "debug" property.
  +     */
  +    public int getDebug() {
  +
  +        return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the "debug" property.
  +     *
  +     * @param debug The new debug level
  +     */
  +    public void setDebug(int debug) {
  +
  +        this.debug = debug;
  +
  +    }
  +
  +
  +    /**
        * Return the "name" property.
        */
       public String getName() {
  @@ -377,6 +405,9 @@
   
           int i;
   
  +        if (debug >= 1)
  +            log("Creating JNDI naming context");
  +
           // Environment entries
           ContextEnvironment[] contextEnvironments = 
               namingResources.findEnvironments();
  @@ -487,9 +518,12 @@
           } catch (NumberFormatException e) {
               log(sm.getString("naming.invalidEnvEntryValue", env.getName()));
           }
  +
           // Binding the object to the appropriate name
           if (value != null) {
               try {
  +                if (debug >= 2)
  +                    log("  Adding environment entry " + env.getName());
                   createSubcontexts(envCtx, env.getName());
                   envCtx.bind(env.getName(), value);
               } catch (NamingException e) {
  @@ -522,6 +556,10 @@
           // Adding the additional parameters, if any
           addAdditionalParameters(ref, resource.getName());
           try {
  +            if (debug >= 2) {
  +                log("  Adding resource ref " + resource.getName());
  +                log("  " + ref);
  +            }
               createSubcontexts(envCtx, resource.getName());
               envCtx.bind(resource.getName(), ref);
           } catch (NamingException e) {
  @@ -541,6 +579,8 @@
           // Adding the additional parameters, if any
           addAdditionalParameters(ref, name);
           try {
  +            if (debug >= 2)
  +                log("  Adding resource env ref " + name);
               createSubcontexts(envCtx, name);
               envCtx.bind(name, ref);
           } catch (NamingException e) {
  @@ -561,6 +601,8 @@
           // Adding the additional parameters, if any
           addAdditionalParameters(ref, resourceLink.getName());
           try {
  +            if (debug >= 2)
  +                log("  Adding resource link " + resourceLink.getName());
               createSubcontexts(envCtx, resourceLink.getName());
               envCtx.bind(resourceLink.getName(), ref);
           } catch (NamingException e) {
  @@ -649,6 +691,9 @@
       private void addAdditionalParameters(Reference ref, String name) {
           ResourceParams resourceParameters =
               namingResources.findResourceParams(name);
  +        if (debug >= 2)
  +            log("  Resource parameters for " + name + " = " +
  +                resourceParameters);
           if (resourceParameters == null)
               return;
           Hashtable params = resourceParameters.getParameters();
  
  
  
  1.87      +5 -4      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- StandardContext.java	2001/11/08 21:12:00	1.86
  +++ StandardContext.java	2001/11/10 00:01:54	1.87
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.86 2001/11/08 21:12:00 remm Exp $
  - * $Revision: 1.86 $
  - * $Date: 2001/11/08 21:12:00 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.87 2001/11/10 00:01:54 craigmcc Exp $
  + * $Revision: 1.87 $
  + * $Date: 2001/11/10 00:01:54 $
    *
    * ====================================================================
    *
  @@ -145,7 +145,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.86 $ $Date: 2001/11/08 21:12:00 $
  + * @version $Revision: 1.87 $ $Date: 2001/11/10 00:01:54 $
    */
   
   public class StandardContext
  @@ -3349,6 +3349,7 @@
           if (ok && isUseNaming()) {
               if (namingContextListener == null) {
                   namingContextListener = new NamingContextListener();
  +                namingContextListener.setDebug(getDebug());
                   namingContextListener.setName(getNamingContextName());
                   addLifecycleListener(namingContextListener);
                   addContainerListener(namingContextListener);
  
  
  
  1.2       +18 -7     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java
  
  Index: StandardHostDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardHostDeployer.java	2001/10/25 00:23:02	1.1
  +++ StandardHostDeployer.java	2001/11/10 00:01:54	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java,v
1.1 2001/10/25 00:23:02 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/10/25 00:23:02 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java,v
1.2 2001/11/10 00:01:54 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/11/10 00:01:54 $
    *
    * ====================================================================
    *
  @@ -82,6 +82,7 @@
   import org.apache.catalina.LifecycleException;
   import org.apache.catalina.LifecycleListener;
   import org.apache.catalina.startup.ContextRuleSet;
  +import org.apache.catalina.startup.NamingRuleSet;
   import org.apache.catalina.util.StringManager;
   import org.apache.commons.digester.Digester;
   import org.xml.sax.SAXParseException;
  @@ -92,7 +93,7 @@
    * <code>StandardHost</code> implementation class.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2001/10/25 00:23:02 $
  + * @version $Revision: 1.2 $ $Date: 2001/11/10 00:01:54 $
    */
   
   public class StandardHostDeployer implements Deployer {
  @@ -138,7 +139,7 @@
        * The <code>ContextRuleSet</code> associated with our
        * <code>digester</code> instance.
        */
  -    private ContextRuleSet digesterRuleSet = null;
  +    private ContextRuleSet contextRuleSet = null;
   
   
       /**
  @@ -148,6 +149,13 @@
   
   
       /**
  +     * The <code>NamingRuleSet</code> associated with our
  +     * <code>digester</code> instance.
  +     */
  +    private NamingRuleSet namingRuleSet = null;
  +
  +
  +    /**
        * The document base which should replace the value specified in the
        * <code>Context</code> being added in the <code>addChild()</code>
method,
        * or <code>null</code> if the original value should remain untouched.
  @@ -364,6 +372,7 @@
           try {
               stream = config.openStream();
               Digester digester = createDigester();
  +            digester.setDebug(host.getDebug());
               digester.clear();
               digester.push(this);
               digester.parse(stream);
  @@ -586,8 +595,10 @@
               if (host.getDebug() > 0)
                   digester.setDebug(3);
               digester.setValidating(false);
  -            digesterRuleSet = new ContextRuleSet("");
  -            digester.addRuleSet(digesterRuleSet);
  +            contextRuleSet = new ContextRuleSet("");
  +            digester.addRuleSet(contextRuleSet);
  +            namingRuleSet = new NamingRuleSet("Context/");
  +            digester.addRuleSet(namingRuleSet);
           }
           return (digester);
   
  
  
  
  1.15      +33 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StandardServer.java	2001/11/09 19:39:11	1.14
  +++ StandardServer.java	2001/11/10 00:01:54	1.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
1.14 2001/11/09 19:39:11 remm Exp $
  - * $Revision: 1.14 $
  - * $Date: 2001/11/09 19:39:11 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
1.15 2001/11/10 00:01:54 craigmcc Exp $
  + * $Revision: 1.15 $
  + * $Date: 2001/11/10 00:01:54 $
    *
    * ====================================================================
    *
  @@ -90,7 +90,7 @@
    * (but not required) when deploying and starting Catalina.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.14 $ $Date: 2001/11/09 19:39:11 $
  + * @version $Revision: 1.15 $ $Date: 2001/11/10 00:01:54 $
    */
   
   public final class StandardServer
  @@ -115,6 +115,12 @@
   
   
       /**
  +     * Debugging detail level.
  +     */
  +    private int debug = 0;
  +
  +
  +    /**
        * Global naming resources.
        */
       private NamingResources globalNamingResources = null;
  @@ -187,6 +193,28 @@
   
   
       /**
  +     * Return the debugging detail level.
  +     */
  +    public int getDebug() {
  +
  +        return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the debugging detail level.
  +     *
  +     * @param debug The new debugging detail level
  +     */
  +    public void setDebug(int debug) {
  +
  +        this.debug = debug;
  +
  +    }
  +
  +
  +    /**
        * Return the global naming resources.
        */
       public NamingResources getGlobalNamingResources() {
  @@ -561,6 +589,7 @@
               if ((globalNamingResources != null) 
                   && (namingContextListener == null)) {
                   namingContextListener = new NamingContextListener();
  +                namingContextListener.setDebug(getDebug());
                   addLifecycleListener(namingContextListener);
               }
           }
  
  
  
  1.56      +6 -4      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- ContextConfig.java	2001/11/08 21:14:25	1.55
  +++ ContextConfig.java	2001/11/10 00:01:55	1.56
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.55 2001/11/08 21:14:25 remm Exp $
  - * $Revision: 1.55 $
  - * $Date: 2001/11/08 21:14:25 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.56 2001/11/10 00:01:55 craigmcc Exp $
  + * $Revision: 1.56 $
  + * $Date: 2001/11/10 00:01:55 $
    *
    * ====================================================================
    *
  @@ -127,7 +127,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.55 $ $Date: 2001/11/08 21:14:25 $
  + * @version $Revision: 1.56 $ $Date: 2001/11/10 00:01:55 $
    */
   
   public final class ContextConfig
  @@ -263,6 +263,7 @@
           // Process the application web.xml file
           try {
               Digester digester = createWebDigester();
  +            digester.setDebug(getDebug());
               synchronized (digester) {
                   if (context instanceof StandardContext)
                       ((StandardContext) context).setReplaceWelcomeFiles(true);
  @@ -500,6 +501,7 @@
           // Process the default web.xml file
           try {
               Digester digester = createWebDigester();
  +            digester.setDebug(getDebug());
               synchronized (digester) {
                   if (context instanceof StandardContext)
                       ((StandardContext) context).setReplaceWelcomeFiles(true);
  
  
  
  1.2       +36 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ResourceRef.java
  
  Index: ResourceRef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ResourceRef.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceRef.java	2000/11/04 06:46:08	1.1
  +++ ResourceRef.java	2001/11/10 00:01:55	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ResourceRef.java,v
1.1 2000/11/04 06:46:08 remm Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/11/04 06:46:08 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/ResourceRef.java,v
1.2 2001/11/10 00:01:55 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/11/10 00:01:55 $
    *
    * ====================================================================
    *
  @@ -64,7 +64,9 @@
   
   package org.apache.naming;
   
  +import java.util.Enumeration;
   import java.util.Hashtable;
  +import javax.naming.RefAddr;
   import javax.naming.Reference;
   import javax.naming.Context;
   import javax.naming.StringRefAddr;
  @@ -73,7 +75,7 @@
    * Represents a reference address to a resource.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.1 $ $Date: 2000/11/04 06:46:08 $
  + * @version $Revision: 1.2 $ $Date: 2001/11/10 00:01:55 $
    */
   
   public class ResourceRef
  @@ -173,6 +175,36 @@
                   return DEFAULT_FACTORY;
               }
           }
  +    }
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
  +    /**
  +     * Return a String rendering of this object.
  +     */
  +    public String toString() {
  +
  +        StringBuffer sb = new StringBuffer("ResourceRef[");
  +        sb.append("className=");
  +        sb.append(getClassName());
  +        sb.append(",factoryClassLocation=");
  +        sb.append(getFactoryClassLocation());
  +        sb.append(",factoryClassName=");
  +        sb.append(getFactoryClassName());
  +        Enumeration refAddrs = getAll();
  +        while (refAddrs.hasMoreElements()) {
  +            RefAddr refAddr = (RefAddr) refAddrs.nextElement();
  +            sb.append(",{type=");
  +            sb.append(refAddr.getType());
  +            sb.append(",content=");
  +            sb.append(refAddr.getContent());
  +            sb.append("}");
  +        }
  +        sb.append("]");
  +        return (sb.toString());
  +
       }
   
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message