You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2002/01/22 17:12:26 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core NamingContextListener.java StandardServer.java

remm        02/01/22 08:12:26

  Modified:    catalina/src/share/org/apache/catalina/core
                        NamingContextListener.java StandardServer.java
  Log:
  - Changes to allow Catalina components to access an the global naming using
    standard JNDI lookups.
  - JNDI calls can only be made after the server has been started.
  - Change the order in which server listeners are registered, so that the naming listener
    goes first.
  - Note: The bidings are different at the moment from a standard ENC (the resources
    are not bound in a "comp" subcontext, for example).
  
  Revision  Changes    Path
  1.7       +20 -11    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- NamingContextListener.java	20 Jan 2002 03:00:56 -0000	1.6
  +++ NamingContextListener.java	22 Jan 2002 16:12:26 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v 1.6 2002/01/20 03:00:56 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/01/20 03:00:56 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/NamingContextListener.java,v 1.7 2002/01/22 16:12:26 remm Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/01/22 16:12:26 $
    *
    * ====================================================================
    *
  @@ -116,7 +116,7 @@
    * with each context and server.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.6 $ $Date: 2002/01/20 03:00:56 $
  + * @version $Revision: 1.7 $ $Date: 2002/01/22 16:12:26 $
    */
   
   public class NamingContextListener
  @@ -259,7 +259,7 @@
       public void lifecycleEvent(LifecycleEvent event) {
   
           container = event.getLifecycle();
  -        
  +
           if (container instanceof Context) {
               namingResources = ((Context) container).getNamingResources();
           } else if (container instanceof Server) {
  @@ -280,9 +280,7 @@
                   // Never happens
               }
               ContextAccessController.setSecurityToken(getName(), container);
  -            if (container instanceof Context)
  -                ContextBindings.bindContext(container, namingContext, 
  -                                            container);
  +            ContextBindings.bindContext(container, namingContext, container);
               //ContextBindings.bindThread(container, container);
   
               // Setting the context in read/write mode
  @@ -300,18 +298,26 @@
               //ContextBindings.unbindThread(container, container);
   
               // Binding the naming context to the class loader
  -            if (container instanceof Context)
  +            if (container instanceof Context) {
                   try {
                       ContextBindings.bindClassLoader
                           (container, container, 
                            ((Container) container).getLoader().getClassLoader());
  -            } catch (NamingException e) {
  -                log(sm.getString("naming.bindFailed", e));
  +                } catch (NamingException e) {
  +                    log(sm.getString("naming.bindFailed", e));
  +                }
               }
   
               if (container instanceof Server) {
                   org.apache.naming.factory.ResourceLinkFactory.setGlobalContext
                       (namingContext);
  +                try {
  +                    ContextBindings.bindClassLoader
  +                        (container, container, 
  +                         this.getClass().getClassLoader());
  +                } catch (NamingException e) {
  +                    log(sm.getString("naming.bindFailed", e));
  +                }
                   if (container instanceof StandardServer) {
                       ((StandardServer) container).setGlobalNamingContext
                           (namingContext);
  @@ -513,6 +519,9 @@
   
           if (debug >= 1)
               log("Creating JNDI naming context");
  +
  +        if (namingResources == null)
  +            namingResources = new NamingResources();
   
           // Environment entries
           ContextEnvironment[] contextEnvironments = 
  
  
  
  1.18      +12 -13    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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StandardServer.java	20 Jan 2002 03:00:56 -0000	1.17
  +++ StandardServer.java	22 Jan 2002 16:12:26 -0000	1.18
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v 1.17 2002/01/20 03:00:56 craigmcc Exp $
  - * $Revision: 1.17 $
  - * $Date: 2002/01/20 03:00:56 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v 1.18 2002/01/22 16:12:26 remm Exp $
  + * $Revision: 1.18 $
  + * $Date: 2002/01/22 16:12:26 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,7 @@
    * (but not required) when deploying and starting Catalina.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.17 $ $Date: 2002/01/20 03:00:56 $
  + * @version $Revision: 1.18 $ $Date: 2002/01/22 16:12:26 $
    */
   
   public final class StandardServer
  @@ -109,6 +109,14 @@
           super();
           ServerFactory.setServer(this);
   
  +        if (isUseNaming()) {
  +            if (namingContextListener == null) {
  +                namingContextListener = new NamingContextListener();
  +                namingContextListener.setDebug(getDebug());
  +                addLifecycleListener(namingContextListener);
  +            }
  +        }
  +
       }
   
   
  @@ -615,15 +623,6 @@
           if (started)
               throw new LifecycleException
                   (sm.getString("standardServer.start.started"));
  -
  -        if (isUseNaming()) {
  -            if ((globalNamingResources != null) 
  -                && (namingContextListener == null)) {
  -                namingContextListener = new NamingContextListener();
  -                namingContextListener.setDebug(getDebug());
  -                addLifecycleListener(namingContextListener);
  -            }
  -        }
   
           lifecycle.fireLifecycleEvent(START_EVENT, null);
           started = true;
  
  
  

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