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 String
ALL_PHASES
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(HandlerDescription handlerDesc)
Add a HandlerDescription to the Phasevoid
addHandler(Handler handler)
Add a handler to the Phase.void
addHandler(Handler handler, int index)
Add a Handler at a particular index within the Phase.void
checkPostConditions(MessageContext msgContext)
Confirm that all post-conditions of this Phase are met.void
checkPreconditions(MessageContext msgContext)
Check the preconditions for a Phase.void
flowComplete(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.int
getHandlerCount()
HandlerDescription
getHandlerDesc()
Gets the HandlerDescription of a handler.List<Handler>
getHandlers()
Gets all the handlers in the phase.String
getName()
Return the name of this HandlerParameter
getParameter(String name)
Get a Parameter from this HandlerString
getPhaseName()
void
init(HandlerDescription handlerdesc)
Initialize a Handler.Handler.InvocationResponse
invoke(MessageContext msgctx)
Invoke all the handlers in this Phasevoid
removeHandler(HandlerDescription handlerDesc)
Remove a given Handler from a phase using a HandlerDescriptionvoid
setName(String phaseName)
void
setPhaseFirst(Handler handler)
Add a Handler to the Phase in the very first position, and ensure no other Handler will come before it.void
setPhaseLast(Handler handler)
Add a Handler to the Phase in the very last position, and ensure no other Handler will come after it.String
toString()
-
-
-
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:Handler
Initialize 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: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 interfaceHandler
- Parameters:
msgContext
- theMessageContext
to process with thisHandler
.
-
getHandlerCount
public int getHandlerCount()
-
getHandlerDesc
public HandlerDescription getHandlerDesc()
Description copied from interface:Handler
Gets the HandlerDescription of a handler.- Specified by:
getHandlerDesc
in 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:Handler
Return the name of this Handler
-
getParameter
public Parameter getParameter(String name)
Description copied from interface:Handler
Get a Parameter from this Handler- Specified by:
getParameter
in 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
-
-