Class BaseHolder<T>

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

    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).
    • Constructor Detail

      • BaseHolder

        protected BaseHolder​(Source source)
    • Method Detail

      • getSource

        public Source getSource()
      • initialize

        public void initialize()
                        throws java.lang.Exception
        Do any setup necessary after starting
        java.lang.Exception - if unable to initialize
      • doStart

        public void doStart()
                     throws java.lang.Exception
        Description copied from class: AbstractLifeCycle
        Method to override to start the lifecycle
        doStart in class AbstractLifeCycle
        AbstractLifeCycle.StopException - If thrown, the lifecycle will immediately be stopped.
        java.lang.Exception - If there was a problem starting. Will cause a transition to FAILED state
      • doStop

        public void doStop()
                    throws java.lang.Exception
        Description copied from class: AbstractLifeCycle
        Method to override to stop the lifecycle
        doStop in class AbstractLifeCycle
        java.lang.Exception - If there was a problem stopping. Will cause a transition to FAILED state
      • getHeldClass

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

        public ServletHandler getServletHandler()
        Returns the servletHandler.
      • setServletHandler

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

        public void setClassName​(java.lang.String className)
        className - The className to set.
      • setHeldClass

        public void setHeldClass​(java.lang.Class<? extends T> held)
        held - The class to hold
      • illegalStateIfContextStarted

        protected void illegalStateIfContextStarted()
      • setInstance

        protected void setInstance​(T instance)
      • getInstance

        protected T getInstance()
      • createInstance

        protected T createInstance()
                            throws java.lang.Exception
      • getServletContext

        public javax.servlet.ServletContext getServletContext()
      • isInstance

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

        protected <W> T wrap​(T component,
                             java.lang.Class<W> wrapperFunctionType,
                             java.util.function.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)
        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)
        the component that has passed through all Wrapper Function beans found.
      • unwrap

        protected T unwrap​(T component)
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
        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
        out - The appendable to dump to
        indent - The indent to apply after any new lines.
        Throws: - if unable to write to Appendable
      • dump

        public java.lang.String dump()
        Specified by:
        dump in interface Dumpable