View Javadoc

1   // ========================================================================
2   // Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.plus.servlet;
15  
16  import javax.servlet.Filter;
17  import javax.servlet.Servlet;
18  
19  import org.eclipse.jetty.plus.annotation.InjectionCollection;
20  import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
21  
22  /**
23   * ServletHandler
24   *
25   *
26   */
27  public class ServletHandler extends org.eclipse.jetty.servlet.ServletHandler
28  {
29  
30      private InjectionCollection _injections = null;
31      private LifeCycleCallbackCollection _callbacks = null;
32      
33  
34  
35      /**
36       * @return the callbacks
37       */
38      public LifeCycleCallbackCollection getCallbacks()
39      {
40          return _callbacks;
41      }
42  
43  
44  
45      /**
46       * @param callbacks the callbacks to set
47       */
48      public void setCallbacks(LifeCycleCallbackCollection callbacks)
49      {
50          this._callbacks = callbacks;
51      }
52  
53  
54  
55      /**
56       * @return the injections
57       */
58      public InjectionCollection getInjections()
59      {
60          return _injections;
61      }
62  
63  
64  
65      /**
66       * @param injections the injections to set
67       */
68      public void setInjections(InjectionCollection injections)
69      {
70          this._injections = injections;
71      }
72      
73      /** 
74       * @see org.eclipse.jetty.servlet.ServletHandler#customizeFilter(javax.servlet.Filter)
75       */
76      public Filter customizeFilter(Filter filter) throws Exception
77      {
78          if (_injections != null)
79              _injections.inject(filter);
80          
81          if (_callbacks != null)
82              _callbacks.callPostConstructCallback(filter);
83          return super.customizeFilter(filter); 
84      }
85      
86      
87  
88      /** 
89       * @see org.eclipse.jetty.servlet.ServletHandler#customizeServlet(javax.servlet.Servlet)
90       */
91      public Servlet customizeServlet(Servlet servlet) throws Exception
92      {      
93          if (_injections != null)
94              _injections.inject(servlet);
95          if (_callbacks != null)
96              _callbacks.callPostConstructCallback(servlet);
97          return super.customizeServlet(servlet);
98      }
99  
100 
101 
102     /** 
103      * @see org.eclipse.jetty.servlet.servlet.ServletHandler#cusomizeFilterDestroy(javax.servlet.Filter)
104      */
105     public Filter customizeFilterDestroy(Filter filter) throws Exception
106     {
107         if (_callbacks != null)
108             _callbacks.callPreDestroyCallback(filter);
109         return super.customizeFilterDestroy(filter);
110     }
111 
112 
113 
114     /** 
115      * @see org.eclipse.jetty.servlet.servlet.ServletHandler#customizeServletDestroy(javax.servlet.Servlet)
116      */
117     public Servlet customizeServletDestroy(Servlet servlet) throws Exception
118     {
119         if (_callbacks != null)
120             _callbacks.callPreDestroyCallback(servlet);
121         return super.customizeServletDestroy(servlet);
122     }
123 }