Class HandlerCollection

All Implemented Interfaces:
Handler, HandlerContainer, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
Direct Known Subclasses:
HandlerList

@ManagedObject("Handler of multiple handlers") public class HandlerCollection extends AbstractHandlerContainer
A collection of handlers.

The default implementations calls all handlers in list order, regardless of the response status or exceptions. Derived implementation may alter the order or the conditions of calling the contained handlers.

  • Field Details

  • Constructor Details

    • HandlerCollection

      public HandlerCollection()
    • HandlerCollection

      public HandlerCollection(Handler... handlers)
    • HandlerCollection

      public HandlerCollection(boolean mutableWhenRunning, Handler... handlers)
  • Method Details

    • getHandlers

      @ManagedAttribute(value="Wrapped handlers", readonly=true) public Handler[] getHandlers()
      Returns:
      the array of handlers.
    • setHandlers

      public void setHandlers(Handler[] handlers)
      Set the array of handlers to set..
      Parameters:
      handlers - the array of handlers to set.
    • newHandlers

      protected HandlerCollection.Handlers newHandlers(Handler[] handlers)
    • updateHandlers

      protected boolean updateHandlers(HandlerCollection.Handlers old, HandlerCollection.Handlers handlers)
    • handle

      public void handle(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
      Description copied from interface: Handler
      Handle a request.
      Specified by:
      handle in interface Handler
      Specified by:
      handle in class AbstractHandler
      Parameters:
      target - The target of the request - either a URI or a name.
      baseRequest - The original unwrapped request object.
      request - The request either as the Request object or a wrapper of that request.
      response - The response as the Response object or a wrapper of that request.
      Throws:
      IOException - if unable to handle the request or response processing
      javax.servlet.ServletException - if unable to handle the request or response due to underlying servlet issue
    • addHandler

      public void addHandler(Handler handler)
      Adds a handler. This implementation adds the passed handler to the end of the existing collection of handlers. If the handler is already added, it is removed and readded
    • prependHandler

      public void prependHandler(Handler handler)
      Prepends a handler. This implementation adds the passed handler to the start of the existing collection of handlers.
    • removeHandler

      public void removeHandler(Handler handler)
    • expandChildren

      protected void expandChildren(List<Handler> list, Class<?> byClass)
      Overrides:
      expandChildren in class AbstractHandlerContainer
    • destroy

      public void destroy()
      Description copied from class: ContainerLifeCycle
      Destroys the managed Destroyable beans in the reverse order they were added.
      Specified by:
      destroy in interface Destroyable
      Specified by:
      destroy in interface Handler
      Overrides:
      destroy in class AbstractHandler