Class Phase

  • All Implemented Interfaces:
    Handler
    Direct Known Subclasses:
    DispatchPhase

    public class Phase
    extends Object
    implements Handler
    A Phase is an ordered collection of Handlers.
    • Constructor Detail

      • Phase

        public Phase()
        Default constructor
      • Phase

        public Phase​(String phaseName)
        Create a named Phase
        Parameters:
        phaseName - the name for this Phase
    • Method Detail

      • addHandler

        public void addHandler​(Handler handler)
        Add a handler to the Phase.
        Parameters:
        handler - the Handler to add
      • addHandler

        public void addHandler​(HandlerDescription handlerDesc)
                        throws PhaseException
        Add a HandlerDescription to the Phase
        Parameters:
        handlerDesc - the HandlerDescription to add
        Throws:
        PhaseException - if there is a problem
      • addHandler

        public void addHandler​(Handler handler,
                               int index)
        Add a Handler at a particular index within the Phase. If we have a Phase with (H1, H2), calling addHandler(H3, 1) will result in (H1, H3, H2)
        Parameters:
        handler - the Handler to add
        index - the position in the Phase at which to place the Handler
      • checkPostConditions

        public void checkPostConditions​(MessageContext msgContext)
                                 throws AxisFault
        Confirm that all post-conditions of this Phase are met. After all Handlers in a Phase are invoke()d, this method will be called. Subclasses should override it in order to confirm that the purpose of the given Phase has been acheived.
        Parameters:
        msgContext - the active MessageContext
        Throws:
        AxisFault - if a post-condition has not been met, or other problems occur
      • checkPreconditions

        public void checkPreconditions​(MessageContext msgContext)
                                throws AxisFault
        Check the preconditions for a Phase. This method will be called when the Phase is invoked, BEFORE any Handlers are invoked. Subclasses should override it in order to confirm that necessary preconditions are met before the Phase does its work. They should throw an appropriate AxisFault if not.
        Parameters:
        msgContext - the active MessageContext
        Throws:
        AxisFault - if a precondition is not met, or in case of other problem
      • init

        public void init​(HandlerDescription handlerdesc)
        Description copied from interface: Handler
        Initialize a Handler.
        Specified by:
        init in interface Handler
        Parameters:
        handlerdesc - the HandlerDescription for this Handler
      • flowComplete

        public void flowComplete​(MessageContext msgContext)
        Description copied from interface: Handler
        This method will be called on each registered handler that had its invoke(...) method called during the processing of the message, once the message processing has completed. During execution of the flowComplete's, handlers are invoked in the opposite order that they were invoked originally. Note that implementations SHOULD check msgContext.getFailureReason() to see if this is an error or a normal completion.
        Specified by:
        flowComplete in interface Handler
        Parameters:
        msgContext - the MessageContext to process with this Handler.
      • getHandlerCount

        public int getHandlerCount()
      • getHandlerDesc

        public HandlerDescription getHandlerDesc()
        Description copied from interface: Handler
        Gets the HandlerDescription of a handler.
        Specified by:
        getHandlerDesc in interface Handler
        Returns:
        Returns HandlerDescription.
      • getHandlers

        public List<Handler> getHandlers()
        Gets all the handlers in the phase.
        Returns:
        Returns an ArrayList of Handlers
      • getName

        public String getName()
        Description copied from interface: Handler
        Return the name of this Handler
        Specified by:
        getName in interface Handler
        Returns:
        the handler's name as a String
      • getParameter

        public Parameter getParameter​(String name)
        Description copied from interface: Handler
        Get a Parameter from this Handler
        Specified by:
        getParameter in interface Handler
        Parameters:
        name - the name of the desired value
        Returns:
        the Parameter, or null.
      • getPhaseName

        public String getPhaseName()
        Returns:
        Returns the name.
      • setName

        public void setName​(String phaseName)
      • setPhaseFirst

        public void setPhaseFirst​(Handler handler)
                           throws PhaseException
        Add a Handler to the Phase in the very first position, and ensure no other Handler will come before it.
        Parameters:
        handler - the Handler to add
        Throws:
        PhaseException - if another Handler is already set as phaseFirst
      • setPhaseLast

        public void setPhaseLast​(Handler handler)
                          throws PhaseException
        Add a Handler to the Phase in the very last position, and ensure no other Handler will come after it.
        Parameters:
        handler - the Handler to add
        Throws:
        PhaseException - if another Handler is already set as phaseLast
      • removeHandler

        public void removeHandler​(HandlerDescription handlerDesc)
        Remove a given Handler from a phase using a HandlerDescription
        Parameters:
        handlerDesc - the HandlerDescription to remove