View Javadoc

    1   //========================================================================
    2   //$Id: ServletHandler.java 1448 2006-12-29 20:46:57Z janb $
    3   //Copyright 2006 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 org.mortbay.jetty.plus.servlet;
    17
    18  import javax.servlet.Filter;
    19  import javax.servlet.Servlet;
    20
    21  import org.mortbay.jetty.plus.annotation.InjectionCollection;
    22  import org.mortbay.jetty.plus.annotation.LifeCycleCallbackCollection;
    23
    24  /**
    25   * ServletHandler
    26   *
    27   *
    28   */
    29  public class ServletHandler extends org.mortbay.jetty.servlet.ServletHandler
    30  {
    31
    32      private InjectionCollection _injections = null;
    33      private LifeCycleCallbackCollection _callbacks = null;
    34
    35
    36
    37      /**
    38       * @return the callbacks
    39       */
    40      public LifeCycleCallbackCollection getCallbacks()
    41      {
    42          return _callbacks;
    43      }
    44
    45
    46
    47      /**
    48       * @param callbacks the callbacks to set
    49       */
    50      public void setCallbacks(LifeCycleCallbackCollection callbacks)
    51      {
    52          this._callbacks = callbacks;
    53      }
    54
    55
    56
    57      /**
    58       * @return the injections
    59       */
    60      public InjectionCollection getInjections()
    61      {
    62          return _injections;
    63      }
    64
    65
    66
    67      /**
    68       * @param injections the injections to set
    69       */
    70      public void setInjections(InjectionCollection injections)
    71      {
    72          this._injections = injections;
    73      }
    74
    75      /**
    76       * @see org.mortbay.jetty.servlet.ServletHandler#customizeFilter(javax.servlet.Filter)
    77       */
    78      public Filter customizeFilter(Filter filter) throws Exception
    79      {
    80          if (_injections != null)
    81              _injections.inject(filter);
    82
    83          if (_callbacks != null)
    84              _callbacks.callPostConstructCallback(filter);
    85          return super.customizeFilter(filter);
    86      }
    87
    88
    89
    90      /**
    91       * @see org.mortbay.jetty.servlet.ServletHandler#customizeServlet(javax.servlet.Servlet)
    92       */
    93      public Servlet customizeServlet(Servlet servlet) throws Exception
    94      {
    95          if (_injections != null)
    96              _injections.inject(servlet);
    97          if (_callbacks != null)
    98              _callbacks.callPostConstructCallback(servlet);
    99          return super.customizeServlet(servlet);
    100     }
    101
    102
    103
    104     /**
    105      * @see org.mortbay.jetty.servlet.ServletHandler#cusomizeFilterDestroy(javax.servlet.Filter)
    106      */
    107     public Filter customizeFilterDestroy(Filter filter) throws Exception
    108     {
    109         if (_callbacks != null)
    110             _callbacks.callPreDestroyCallback(filter);
    111         return super.customizeFilterDestroy(filter);
    112     }
    113
    114
    115
    116     /**
    117      * @see org.mortbay.jetty.servlet.ServletHandler#customizeServletDestroy(javax.servlet.Servlet)
    118      */
    119     public Servlet customizeServletDestroy(Servlet servlet) throws Exception
    120     {
    121         if (_callbacks != null)
    122             _callbacks.callPreDestroyCallback(servlet);
    123         return super.customizeServletDestroy(servlet);
    124     }
    125 }