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 2003/08/09 21:04:29 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session StandardSession.java

remm        2003/08/09 12:04:29

  Modified:    catalina/src/share/org/apache/catalina Context.java
               catalina/src/share/org/apache/catalina/core
                        ApplicationContext.java StandardContext.java
                        StandardContextValve.java
               catalina/src/share/org/apache/catalina/session
                        StandardSession.java
  Log:
  - Split the applicationListeners array in two, for performance reasons.
  
  Revision  Changes    Path
  1.9       +29 -8     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Context.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Context.java	22 Jul 2003 21:01:26 -0000	1.8
  +++ Context.java	9 Aug 2003 19:04:29 -0000	1.9
  @@ -120,24 +120,45 @@
   
   
       /**
  -     * Return the set of initialized application listener objects,
  +     * Return the set of initialized application event listener objects,
        * in the order they were specified in the web application deployment
        * descriptor, for this application.
        *
        * @exception IllegalStateException if this method is called before
        *  this application has started, or after it has been stopped
        */
  -    public Object[] getApplicationListeners();
  +    public Object[] getApplicationEventListeners();
   
   
       /**
  -     * Store the set of initialized application listener objects,
  +     * Store the set of initialized application event listener objects,
        * in the order they were specified in the web application deployment
        * descriptor, for this application.
        *
        * @param listeners The set of instantiated listener objects.
        */
  -    public void setApplicationListeners(Object listeners[]);
  +    public void setApplicationEventListeners(Object listeners[]);
  +
  +
  +    /**
  +     * Return the set of initialized application lifecycle listener objects,
  +     * in the order they were specified in the web application deployment
  +     * descriptor, for this application.
  +     *
  +     * @exception IllegalStateException if this method is called before
  +     *  this application has started, or after it has been stopped
  +     */
  +    public Object[] getApplicationLifecycleListeners();
  +
  +
  +    /**
  +     * Store the set of initialized application lifecycle listener objects,
  +     * in the order they were specified in the web application deployment
  +     * descriptor, for this application.
  +     *
  +     * @param listeners The set of instantiated listener objects.
  +     */
  +    public void setApplicationLifecycleListeners(Object listeners[]);
   
   
       /**
  
  
  
  1.15      +6 -6      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
  
  Index: ApplicationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationContext.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ApplicationContext.java	5 Aug 2003 13:22:03 -0000	1.14
  +++ ApplicationContext.java	9 Aug 2003 19:04:29 -0000	1.15
  @@ -751,7 +751,7 @@
           }
   
           // Notify interested application event listeners
  -        Object listeners[] = context.getApplicationListeners();
  +        Object listeners[] = context.getApplicationEventListeners();
           if ((listeners == null) || (listeners.length == 0))
               return;
           ServletContextAttributeEvent event =
  @@ -814,7 +814,7 @@
           }
   
           // Notify interested application event listeners
  -        Object listeners[] = context.getApplicationListeners();
  +        Object listeners[] = context.getApplicationEventListeners();
           if ((listeners == null) || (listeners.length == 0))
               return;
           ServletContextAttributeEvent event = null;
  
  
  
  1.80      +74 -21    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- StandardContext.java	2 Aug 2003 17:42:59 -0000	1.79
  +++ StandardContext.java	9 Aug 2003 19:04:29 -0000	1.80
  @@ -77,12 +77,7 @@
   import java.util.Hashtable;
   import java.util.Stack;
   import java.net.URLDecoder;
  -import javax.servlet.FilterConfig;
  -import javax.servlet.ServletContext;
  -import javax.servlet.ServletContextEvent;
  -import javax.servlet.ServletContextListener;
  -import javax.servlet.ServletException;
  -import javax.servlet.ServletRequestListener;
  +
   import javax.naming.NamingException;
   import javax.naming.directory.DirContext;
   import javax.management.InstanceNotFoundException;
  @@ -92,6 +87,18 @@
   import javax.management.Notification;
   import javax.management.NotificationBroadcasterSupport;
   import javax.management.ObjectName;
  +
  +import javax.servlet.FilterConfig;
  +import javax.servlet.ServletContext;
  +import javax.servlet.ServletContextAttributeListener;
  +import javax.servlet.ServletContextEvent;
  +import javax.servlet.ServletContextListener;
  +import javax.servlet.ServletException;
  +import javax.servlet.ServletRequestAttributeListener;
  +import javax.servlet.ServletRequestListener;
  +import javax.servlet.http.HttpSessionAttributeListener;
  +import javax.servlet.http.HttpSessionListener;
  +
   import org.apache.naming.ContextBindings;
   import org.apache.naming.resources.BaseDirContext;
   import org.apache.naming.resources.FileDirContext;
  @@ -185,10 +192,17 @@
   
   
       /**
  -     * The set of instantiated application listener objects, in a one-to-one
  -     * correspondence to the class names in <code>applicationListeners</code>.
  +     * The set of instantiated application event listener objects</code>.
  +     */
  +    private transient Object applicationEventListenersObjects[] = 
  +        new Object[0];
  +
  +
  +    /**
  +     * The set of instantiated application lifecycle listener objects</code>.
        */
  -    private transient Object applicationListenersObjects[] = new Object[0];
  +    private transient Object applicationLifecycleListenersObjects[] = 
  +        new Object[0];
   
   
       /**
  @@ -599,31 +613,52 @@
   
   
       /**
  -     * Return the set of initialized application listener objects,
  +     * Return the set of initialized application event listener objects,
        * in the order they were specified in the web application deployment
        * descriptor, for this application.
        *
        * @exception IllegalStateException if this method is called before
        *  this application has started, or after it has been stopped
        */
  -    public Object[] getApplicationListeners() {
  +    public Object[] getApplicationEventListeners() {
  +        return (applicationEventListenersObjects);
  +    }
   
  -        return (applicationListenersObjects);
   
  +    /**
  +     * Store the set of initialized application event listener objects,
  +     * in the order they were specified in the web application deployment
  +     * descriptor, for this application.
  +     *
  +     * @param listeners The set of instantiated listener objects.
  +     */
  +    public void setApplicationEventListeners(Object listeners[]) {
  +        applicationEventListenersObjects = listeners;
       }
   
   
       /**
  -     * Store the set of initialized application listener objects,
  +     * Return the set of initialized application lifecycle listener objects,
        * in the order they were specified in the web application deployment
        * descriptor, for this application.
        *
  -     * @param listeners The set of instantiated listener objects.
  +     * @exception IllegalStateException if this method is called before
  +     *  this application has started, or after it has been stopped
        */
  -    public void setApplicationListeners(Object listeners[]) {
  +    public Object[] getApplicationLifecycleListeners() {
  +        return (applicationEventListenersObjects);
  +    }
   
  -        applicationListenersObjects = listeners;
   
  +    /**
  +     * Store the set of initialized application lifecycle listener objects,
  +     * in the order they were specified in the web application deployment
  +     * descriptor, for this application.
  +     *
  +     * @param listeners The set of instantiated listener objects.
  +     */
  +    public void setApplicationLifecycleListeners(Object listeners[]) {
  +        applicationEventListenersObjects = listeners;
       }
   
   
  @@ -3482,13 +3517,30 @@
               return (false);
           }
   
  +        // Sort listeners in two arrays
  +        ArrayList eventListeners = new ArrayList();
  +        ArrayList lifecycleListeners = new ArrayList();
  +        for (int i = 0; i < results.length; i++) {
  +            if ((results[i] instanceof ServletContextAttributeListener)
  +                || (results[i] instanceof ServletRequestAttributeListener)
  +                || (results[i] instanceof ServletRequestListener)) {
  +                eventListeners.add(results[i]);
  +            }
  +            if ((results[i] instanceof ServletContextListener)
  +                || (results[i] instanceof HttpSessionListener)) {
  +                lifecycleListeners.add(results[i]);
  +            }
  +        }
  +
  +        setApplicationEventListeners(eventListeners.toArray());
  +        setApplicationLifecycleListeners(lifecycleListeners.toArray());
  +
           // Send application start events
   
           if (log.isDebugEnabled())
               log.debug("Sending application start events");
   
  -        setApplicationListeners(results);
  -        Object instances[] = getApplicationListeners();
  +        Object instances[] = getApplicationLifecycleListeners();
           if (instances == null)
               return (ok);
           ServletContextEvent event =
  @@ -3528,7 +3580,7 @@
               log.debug("Sending application stop events");
   
           boolean ok = true;
  -        Object listeners[] = getApplicationListeners();
  +        Object listeners[] = getApplicationLifecycleListeners();
           if (listeners == null)
               return (ok);
           ServletContextEvent event =
  @@ -3553,7 +3605,8 @@
                   ok = false;
               }
           }
  -        setApplicationListeners(null);
  +        setApplicationEventListeners(null);
  +        setApplicationLifecycleListeners(null);
           return (ok);
   
       }
  
  
  
  1.12      +5 -5      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java
  
  Index: StandardContextValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StandardContextValve.java	23 Jul 2003 01:13:49 -0000	1.11
  +++ StandardContextValve.java	9 Aug 2003 19:04:29 -0000	1.12
  @@ -224,7 +224,7 @@
           throws IOException, ServletException {
   
           Object instances[] = 
  -            ((StandardContext) container).getApplicationListeners();
  +            ((Context) container).getApplicationEventListeners();
   
           ServletRequestEvent event = null;
   
  
  
  
  1.19      +8 -8      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardSession.java
  
  Index: StandardSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StandardSession.java	8 Jul 2003 06:28:02 -0000	1.18
  +++ StandardSession.java	9 Aug 2003 19:04:29 -0000	1.19
  @@ -390,7 +390,7 @@
   
           // Notify interested application event listeners
           Context context = (Context) manager.getContainer();
  -        Object listeners[] = context.getApplicationListeners();
  +        Object listeners[] = context.getApplicationLifecycleListeners();
           if (listeners != null) {
               HttpSessionEvent event =
                   new HttpSessionEvent(getSession());
  @@ -655,7 +655,7 @@
               // Notify interested application event listeners
               // FIXME - Assumes we call listeners in reverse order
               Context context = (Context) manager.getContainer();
  -            Object listeners[] = context.getApplicationListeners();
  +            Object listeners[] = context.getApplicationLifecycleListeners();
               if (notify && (listeners != null)) {
                   HttpSessionEvent event =
                       new HttpSessionEvent(getSession());
  @@ -1174,7 +1174,7 @@
   
           // Notify interested application event listeners
           Context context = (Context) manager.getContainer();
  -        Object listeners[] = context.getApplicationListeners();
  +        Object listeners[] = context.getApplicationEventListeners();
           if (listeners == null)
               return;
           for (int i = 0; i < listeners.length; i++) {
  @@ -1296,7 +1296,7 @@
   
           // Notify interested application event listeners
           Context context = (Context) manager.getContainer();
  -        Object listeners[] = context.getApplicationListeners();
  +        Object listeners[] = context.getApplicationEventListeners();
           if (listeners == null)
               return;
           for (int i = 0; i < listeners.length; i++) {
  
  
  

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