View Javadoc

    1   //========================================================================
    2   //$Id: TestListener.java,v 1.1 2005/10/26 10:12:55 gregwilkins Exp $
    3   //Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
    4   //------------------------------------------------------------------------
    5   //Licensed under the Apache License, Version 2.0 (the "License");
    6   //you may not use this file except in compliance with the License.
    7   //You may obtain a copy of the License at
    8   //http://www.apache.org/licenses/LICENSE-2.0
    9   //Unless required by applicable law or agreed to in writing, software
    10  //distributed under the License is distributed on an "AS IS" BASIS,
    11  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //See the License for the specific language governing permissions and
    13  //limitations under the License.
    14  //========================================================================
    15
    16  package com.acme;
    17
    18  import javax.servlet.ServletContextAttributeEvent;
    19  import javax.servlet.ServletContextAttributeListener;
    20  import javax.servlet.ServletContextEvent;
    21  import javax.servlet.ServletContextListener;
    22  import javax.servlet.ServletRequest;
    23  import javax.servlet.ServletRequestAttributeEvent;
    24  import javax.servlet.ServletRequestAttributeListener;
    25  import javax.servlet.ServletRequestEvent;
    26  import javax.servlet.ServletRequestListener;
    27  import javax.servlet.http.HttpServletRequest;
    28  import javax.servlet.http.HttpSessionActivationListener;
    29  import javax.servlet.http.HttpSessionAttributeListener;
    30  import javax.servlet.http.HttpSessionBindingEvent;
    31  import javax.servlet.http.HttpSessionEvent;
    32  import javax.servlet.http.HttpSessionListener;
    33
    34  public class TestListener implements HttpSessionListener,  HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
    35  {
    36      public void attributeAdded(HttpSessionBindingEvent se)
    37      {
    38          // System.err.println("attributedAdded "+se);
    39      }
    40
    41      public void attributeRemoved(HttpSessionBindingEvent se)
    42      {
    43          // System.err.println("attributeRemoved "+se);
    44      }
    45
    46      public void attributeReplaced(HttpSessionBindingEvent se)
    47      {
    48          // System.err.println("attributeReplaced "+se);
    49      }
    50
    51      public void sessionWillPassivate(HttpSessionEvent se)
    52      {
    53          // System.err.println("sessionWillPassivate "+se);
    54      }
    55
    56      public void sessionDidActivate(HttpSessionEvent se)
    57      {
    58          // System.err.println("sessionDidActivate "+se);
    59      }
    60
    61      public void contextInitialized(ServletContextEvent sce)
    62      {
    63          // System.err.println("contextInitialized "+sce);
    64      }
    65
    66      public void contextDestroyed(ServletContextEvent sce)
    67      {
    68          // System.err.println("contextDestroyed "+sce);
    69      }
    70
    71      public void attributeAdded(ServletContextAttributeEvent scab)
    72      {
    73          // System.err.println("attributeAdded "+scab);
    74      }
    75
    76      public void attributeRemoved(ServletContextAttributeEvent scab)
    77      {
    78          // System.err.println("attributeRemoved "+scab);
    79      }
    80
    81      public void attributeReplaced(ServletContextAttributeEvent scab)
    82      {
    83          // System.err.println("attributeReplaced "+scab);
    84      }
    85
    86      public void requestDestroyed(ServletRequestEvent sre)
    87      {
    88          ((HttpServletRequest)sre.getServletRequest()).getSession(false);
    89          sre.getServletRequest().setAttribute("requestInitialized",null);
    90          // System.err.println("requestDestroyed "+sre);
    91      }
    92
    93      public void requestInitialized(ServletRequestEvent sre)
    94      {
    95          sre.getServletRequest().setAttribute("requestInitialized","'"+sre.getServletContext().getContextPath()+"'");
    96          // System.err.println("requestInitialized "+sre);
    97      }
    98
    99      public void attributeAdded(ServletRequestAttributeEvent srae)
    100     {
    101         // System.err.println("attributeAdded "+srae);
    102     }
    103
    104     public void attributeRemoved(ServletRequestAttributeEvent srae)
    105     {
    106         // System.err.println("attributeRemoved "+srae);
    107     }
    108
    109     public void attributeReplaced(ServletRequestAttributeEvent srae)
    110     {
    111         // System.err.println("attributeReplaced "+srae);
    112     }
    113
    114     public void sessionCreated(HttpSessionEvent se)
    115     {
    116         // System.err.println("sessionCreated "+se);
    117     }
    118
    119     public void sessionDestroyed(HttpSessionEvent se)
    120     {
    121         // System.err.println("sessionDestroyed "+se);
    122     }
    123
    124 }