View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package com.acme.test;
20  
21  import javax.annotation.Resource;
22  import javax.servlet.ServletContextAttributeEvent;
23  import javax.servlet.ServletContextAttributeListener;
24  import javax.servlet.ServletContextEvent;
25  import javax.servlet.ServletContextListener;
26  import javax.servlet.ServletRequestAttributeEvent;
27  import javax.servlet.ServletRequestAttributeListener;
28  import javax.servlet.ServletRequestEvent;
29  import javax.servlet.ServletRequestListener;
30  import javax.servlet.annotation.WebListener;
31  import javax.servlet.http.HttpSessionActivationListener;
32  import javax.servlet.http.HttpSessionAttributeListener;
33  import javax.servlet.http.HttpSessionBindingEvent;
34  import javax.servlet.http.HttpSessionEvent;
35  import javax.servlet.http.HttpSessionListener;
36  
37  
38  
39  @WebListener
40  public class AnnotatedListener implements HttpSessionListener,  HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
41  {
42  
43      @Resource(mappedName="maxAmount")
44      private Double maxAmount;
45  
46      public void attributeAdded(HttpSessionBindingEvent se)
47      {
48          // System.err.println("attributedAdded "+se);
49      }
50  
51      public void attributeRemoved(HttpSessionBindingEvent se)
52      {
53          // System.err.println("attributeRemoved "+se);
54      }
55  
56      public void attributeReplaced(HttpSessionBindingEvent se)
57      {
58          // System.err.println("attributeReplaced "+se);
59      }
60  
61      public void sessionWillPassivate(HttpSessionEvent se)
62      {
63          // System.err.println("sessionWillPassivate "+se);
64      }
65  
66      public void sessionDidActivate(HttpSessionEvent se)
67      {
68          // System.err.println("sessionDidActivate "+se);
69      }
70  
71      public void contextInitialized(ServletContextEvent sce)
72      {
73          sce.getServletContext().setAttribute("com.acme.AnnotationTest.sclInjectWebListenerTest", Boolean.valueOf(maxAmount!=null));
74      }
75  
76      public void contextDestroyed(ServletContextEvent sce)
77      {
78          // System.err.println("contextDestroyed "+sce);
79      }
80  
81      public void attributeAdded(ServletContextAttributeEvent scab)
82      {
83          // System.err.println("attributeAdded "+scab);
84      }
85  
86      public void attributeRemoved(ServletContextAttributeEvent scab)
87      {
88          // System.err.println("attributeRemoved "+scab);
89      }
90  
91      public void attributeReplaced(ServletContextAttributeEvent scab)
92      {
93          // System.err.println("attributeReplaced "+scab);
94      }
95  
96      public void requestDestroyed(ServletRequestEvent sre)
97      {
98          // System.err.println("requestDestroyed "+sre);
99      }
100 
101     public void requestInitialized(ServletRequestEvent sre)
102     {
103         // System.err.println("requestInitialized "+sre);
104     }
105 
106     public void attributeAdded(ServletRequestAttributeEvent srae)
107     {
108         // System.err.println("attributeAdded "+srae);
109     }
110 
111     public void attributeRemoved(ServletRequestAttributeEvent srae)
112     {
113         // System.err.println("attributeRemoved "+srae);
114     }
115 
116     public void attributeReplaced(ServletRequestAttributeEvent srae)
117     {
118         // System.err.println("attributeReplaced "+srae);
119     }
120 
121     public void sessionCreated(HttpSessionEvent se)
122     {
123         // System.err.println("sessionCreated "+se);
124     }
125 
126     public void sessionDestroyed(HttpSessionEvent se)
127     {
128         // System.err.println("sessionDestroyed "+se);
129     }
130 
131     public void requestCompleted(ServletRequestEvent rre)
132     {
133         // TODO Auto-generated method stub
134         
135     }
136 
137     public void requestResumed(ServletRequestEvent rre)
138     {
139         // TODO Auto-generated method stub
140         
141     }
142 
143     public void requestSuspended(ServletRequestEvent rre)
144     {
145         // TODO Auto-generated method stub
146         
147     }
148 
149 }