Package org.apache.axis2.engine
Class Phase
- java.lang.Object
-
- org.apache.axis2.engine.Phase
-
- All Implemented Interfaces:
Handler
- Direct Known Subclasses:
DispatchPhase
public class Phase extends Object implements Handler
A Phase is an ordered collection of Handlers.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.axis2.engine.Handler
Handler.InvocationResponse
-
-
Field Summary
Fields Modifier and Type Field Description static StringALL_PHASES
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(HandlerDescription handlerDesc)Add a HandlerDescription to the PhasevoidaddHandler(Handler handler)Add a handler to the Phase.voidaddHandler(Handler handler, int index)Add a Handler at a particular index within the Phase.voidcheckPostConditions(MessageContext msgContext)Confirm that all post-conditions of this Phase are met.voidcheckPreconditions(MessageContext msgContext)Check the preconditions for a Phase.voidflowComplete(MessageContext msgContext)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.intgetHandlerCount()HandlerDescriptiongetHandlerDesc()Gets the HandlerDescription of a handler.List<Handler>getHandlers()Gets all the handlers in the phase.StringgetName()Return the name of this HandlerParametergetParameter(String name)Get a Parameter from this HandlerStringgetPhaseName()voidinit(HandlerDescription handlerdesc)Initialize a Handler.Handler.InvocationResponseinvoke(MessageContext msgctx)Invoke all the handlers in this PhasevoidremoveHandler(HandlerDescription handlerDesc)Remove a given Handler from a phase using a HandlerDescriptionvoidsetName(String phaseName)voidsetPhaseFirst(Handler handler)Add a Handler to the Phase in the very first position, and ensure no other Handler will come before it.voidsetPhaseLast(Handler handler)Add a Handler to the Phase in the very last position, and ensure no other Handler will come after it.StringtoString()
-
-
-
Field Detail
-
ALL_PHASES
public static final String ALL_PHASES
- See Also:
- Constant Field Values
-
-
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 addindex- 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:HandlerInitialize a Handler.
-
invoke
public final Handler.InvocationResponse invoke(MessageContext msgctx) throws AxisFault
Invoke all the handlers in this Phase
-
flowComplete
public void flowComplete(MessageContext msgContext)
Description copied from interface:HandlerThis 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:
flowCompletein interfaceHandler- Parameters:
msgContext- theMessageContextto process with thisHandler.
-
getHandlerCount
public int getHandlerCount()
-
getHandlerDesc
public HandlerDescription getHandlerDesc()
Description copied from interface:HandlerGets the HandlerDescription of a handler.- Specified by:
getHandlerDescin interfaceHandler- 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:HandlerReturn the name of this Handler
-
getParameter
public Parameter getParameter(String name)
Description copied from interface:HandlerGet a Parameter from this Handler- Specified by:
getParameterin interfaceHandler- 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
-
-