Class BaseHolder<T>

Type Parameters:
T - the type of holder
All Implemented Interfaces:
Dumpable, LifeCycle
Direct Known Subclasses:
Holder, ListenerHolder

public abstract class BaseHolder<T> extends AbstractLifeCycle implements Dumpable
AbstractHolder Base class for all servlet-related classes that may be lazily instantiated (eg servlet, filter, listener), and/or require metadata to be held regarding their origin (web.xml, annotation, programmatic api etc).
  • Field Details

    • LOG

      private static final Logger LOG
    • _source

      private final Source _source
    • _class

      private Class<? extends T> _class
    • _className

      private String _className
    • _instance

      private T _instance
    • _servletHandler

      private ServletHandler _servletHandler
  • Constructor Details

    • BaseHolder

      protected BaseHolder(Source source)
  • Method Details

    • getSource

      public Source getSource()
    • initialize

      public void initialize() throws Exception
      Do any setup necessary after starting
      Throws:
      Exception - if unable to initialize
    • doStart

      public void doStart() throws Exception
      Overrides:
      doStart in class AbstractLifeCycle
      Throws:
      Exception
    • doStop

      public void doStop() throws Exception
      Overrides:
      doStop in class AbstractLifeCycle
      Throws:
      Exception
    • getClassName

      @ManagedAttribute(value="Class Name", readonly=true) public String getClassName()
    • getHeldClass

      public Class<? extends T> getHeldClass()
    • getServletHandler

      public ServletHandler getServletHandler()
      Returns:
      Returns the servletHandler.
    • setServletHandler

      public void setServletHandler(ServletHandler servletHandler)
      Parameters:
      servletHandler - The ServletHandler that will handle requests dispatched to this servlet.
    • setClassName

      public void setClassName(String className)
      Parameters:
      className - The className to set.
    • setHeldClass

      public void setHeldClass(Class<? extends T> held)
      Parameters:
      held - The class to hold
    • illegalStateIfContextStarted

      protected void illegalStateIfContextStarted()
    • setInstance

      protected void setInstance(T instance)
    • getInstance

      protected T getInstance()
    • isInstance

      public boolean isInstance()
      Returns:
      True if this holder was created for a specific instance.
    • wrap

      protected <W> T wrap(T component, Class<W> wrapperFunctionType, BiFunction<W,T,T> function)
      Wrap component using component specific Wrapper Function beans.
      Type Parameters:
      W - the "wrapper function" implementation. (eg: ServletHolder.WrapperFunction or FilterHolder.WrapperFunction, etc)
      Parameters:
      component - the component to optionally wrap
      wrapperFunctionType - the bean class type to look for in the ServletContextHandler
      function - the BiFunction to execute for each wrapperFunctionType Bean found (passing in the component and component type)
      Returns:
      the component that has passed through all Wrapper Function beans found.
    • unwrap

      protected T unwrap(T component)
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Description copied from interface: Dumpable
      Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
      Specified by:
      dump in interface Dumpable
      Parameters:
      out - The appendable to dump to
      indent - The indent to apply after any new lines.
      Throws:
      IOException - if unable to write to Appendable
    • dump

      public String dump()
      Specified by:
      dump in interface Dumpable