Class BaseHolder<T>

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.servlet.BaseHolder<T>
Type Parameters:
T - the type of holder
All Implemented Interfaces:
org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.LifeCycle
Direct Known Subclasses:
Holder, ListenerHolder, ServletContainerInitializerHolder

public abstract class BaseHolder<T> extends org.eclipse.jetty.util.component.AbstractLifeCycle implements org.eclipse.jetty.util.component.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).
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected T
     
    void
     
    void
     
     
    void
    dump(Appendable out, String indent)
     
     
    Class<? extends T>
     
    protected T
     
    jakarta.servlet.ServletContext
     
     
     
    protected void
     
    void
    Do any setup necessary after starting
    boolean
     
    void
    setClassName(String className)
     
    void
    setHeldClass(Class<? extends T> held)
     
    protected void
    setInstance(T instance)
     
    void
     
    protected T
    unwrap(T component)
     
    protected <W> T
    wrap(T component, Class<W> wrapperFunctionType, BiFunction<W,T,T> function)
    Wrap component using component specific Wrapper Function beans.

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    addEventListener, getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, setEventListeners, start, stop, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf
  • 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 org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • doStop

      public void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.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()
    • createInstance

      protected T createInstance() throws Exception
      Throws:
      Exception
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
    • 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
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Throws:
      IOException
    • dump

      public String dump()
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable