Class StandardPipeline

  • All Implemented Interfaces:
    Contained, Lifecycle, Pipeline
    Direct Known Subclasses:
    VirtualServerPipeline, WebPipeline

    public class StandardPipeline
    extends Object
    implements Pipeline, Contained, Lifecycle
    Standard implementation of a processing Pipeline that will invoke a series of Valves that have been configured to be called in order. This implementation can be used for any type of Container. IMPLEMENTATION WARNING - This implementation assumes that no calls to addValve() or removeValve are allowed while a request is currently being processed. Otherwise, the mechanism by which per-thread state is maintained will need to be modified.
    Author:
    Craig R. McClanahan
    • Field Detail

      • basic

        protected GlassFishValve basic
        The basic Valve (if any) associated with this Pipeline.
      • container

        protected Container container
        The Container with which this Pipeline is associated.
      • lifecycle

        protected LifecycleSupport lifecycle
        The lifecycle event support for this component.
      • started

        protected boolean started
        Has this component been started yet?
      • valves

        protected GlassFishValve[] valves
        The set of Valves (not including the Basic one, if any) associated with this Pipeline.
    • Constructor Detail

      • StandardPipeline

        public StandardPipeline()
        Construct a new StandardPipeline instance with no associated Container.
      • StandardPipeline

        public StandardPipeline​(Container container)
        Construct a new StandardPipeline instance that is associated with the specified Container.
        Parameters:
        container - The container we should be associated with
    • Method Detail

      • getInfo

        public String getInfo()
        Return descriptive information about this implementation class.
      • getContainer

        public Container getContainer()
        Return the Container with which this Pipeline is associated.
        Specified by:
        getContainer in interface Contained
      • setContainer

        public void setContainer​(Container container)
        Set the Container with which this Pipeline is associated.
        Specified by:
        setContainer in interface Contained
        Parameters:
        container - The new associated container
      • addLifecycleListener

        public void addLifecycleListener​(LifecycleListener listener)
        Add a lifecycle event listener to this component.
        Specified by:
        addLifecycleListener in interface Lifecycle
        Parameters:
        listener - The listener to add
      • removeLifecycleListener

        public void removeLifecycleListener​(LifecycleListener listener)
        Remove a lifecycle event listener from this component.
        Specified by:
        removeLifecycleListener in interface Lifecycle
        Parameters:
        listener - The listener to remove
      • getBasic

        public GlassFishValve getBasic()

        Return the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any).

        Specified by:
        getBasic in interface Pipeline
      • setBasic

        public void setBasic​(GlassFishValve valve)

        Set the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any). Prior to setting the basic Valve, the Valve's setContainer() will be called, if it implements Contained, with the owning Container as an argument. The method may throw an IllegalArgumentException if this Valve chooses not to be associated with this Container, or IllegalStateException if it is already associated with a different Container.

        Specified by:
        setBasic in interface Pipeline
        Parameters:
        valve - Valve to be distinguished as the basic Valve
      • addValve

        public void addValve​(GlassFishValve valve)

        Add a new Valve to the end of the pipeline associated with this Container. Prior to adding the Valve, the Valve's setContainer() method will be called, if it implements Contained, with the owning Container as an argument. The method may throw an IllegalArgumentException if this Valve chooses not to be associated with this Container, or IllegalStateException if it is already associated with a different Container.

        Specified by:
        addValve in interface Pipeline
        Parameters:
        valve - Valve to be added
        Throws:
        IllegalArgumentException - if this Container refused to accept the specified Valve
        IllegalArgumentException - if the specified Valve refuses to be associated with this Container
        IllegalStateException - if the specified Valve is already associated with a different Container
      • addValve

        public void addValve​(Valve valve)
        Add Tomcat-style valve.
        Specified by:
        addValve in interface Pipeline
        Parameters:
        valve - the Tomcat-style valve to be added
      • getValves

        public GlassFishValve[] getValves()
        Return the set of Valves in the pipeline associated with this Container, including the basic Valve (if any). If there are no such Valves, a zero-length array is returned.
        Specified by:
        getValves in interface Pipeline
      • hasNonBasicValves

        public boolean hasNonBasicValves()
        Specified by:
        hasNonBasicValves in interface Pipeline
        Returns:
        true if this pipeline has any non basic valves, false otherwise
      • getValveObjectNames

        public ObjectName[] getValveObjectNames()
      • invoke

        public void invoke​(Request request,
                           Response response)
                    throws IOException,
                           jakarta.servlet.ServletException
        Cause the specified request and response to be processed by the Valves associated with this pipeline, until one of these valves causes the response to be created and returned. The implementation must ensure that multiple simultaneous requests (on different threads) can be processed through the same Pipeline without interfering with each other's control flow.
        Specified by:
        invoke in interface Pipeline
        Parameters:
        request - The servlet request we are processing
        response - The servlet response we are creating
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet exception is thrown
      • doChainInvoke

        public void doChainInvoke​(Request request,
                                  Response response)
                           throws IOException,
                                  jakarta.servlet.ServletException
        Throws:
        IOException
        jakarta.servlet.ServletException
      • removeValve

        public void removeValve​(GlassFishValve valve)
        Remove the specified Valve from the pipeline associated with this Container, if it is found; otherwise, do nothing. If the Valve is found and removed, the Valve's setContainer(null) method will be called if it implements Contained.
        Specified by:
        removeValve in interface Pipeline
        Parameters:
        valve - Valve to be removed
      • log

        protected void log​(String message)
        Log a message on the Logger associated with our Container (if any).
        Parameters:
        message - Message to be logged
      • log

        protected void log​(String message,
                           Throwable t)
        Logs the given message to the Logger associated with the Container (if any) of this StandardPipeline.
        Parameters:
        message - the message
        t - the Throwable