org.apache.axis2.engine
Class Phase

java.lang.Object
  extended by org.apache.axis2.engine.Phase
All Implemented Interfaces:
Handler
Direct Known Subclasses:
DispatchPhase

public class Phase
extends java.lang.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
static java.lang.String ALL_PHASES
           
 
Constructor Summary
Phase()
          Default constructor
Phase(java.lang.String phaseName)
          Create a named Phase
 
Method Summary
 void addHandler(Handler handler)
          Add a handler to the Phase.
 void addHandler(HandlerDescription handlerDesc)
          Add a HandlerDescription 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 cleanup()
           
 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.
 java.util.List getHandlers()
          Gets all the handlers in the phase.
 java.lang.String getName()
          Return the name of this Handler
 Parameter getParameter(java.lang.String name)
          Get a Parameter from this Handler
 java.lang.String getPhaseName()
           
 void init(HandlerDescription handlerdesc)
          Initialize a Handler.
 Handler.InvocationResponse invoke(MessageContext msgctx)
          Invoke all the handlers in this Phase
 void removeHandler(HandlerDescription handlerDesc)
          Remove a given Handler from a phase using a HandlerDescription
 void setName(java.lang.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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_PHASES

public static final java.lang.String ALL_PHASES
See Also:
Constant Field Values
Constructor Detail

Phase

public Phase()
Default constructor


Phase

public Phase(java.lang.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

cleanup

public void cleanup()
Specified by:
cleanup in interface Handler

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

invoke

public final Handler.InvocationResponse invoke(MessageContext msgctx)
                                        throws AxisFault
Invoke all the handlers in this Phase

Specified by:
invoke in interface Handler
Parameters:
msgctx - the current MessageContext
Returns:
An InvocationResponse that indicates what the next step in the message processing should be.
Throws:
AxisFault

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.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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 java.util.List getHandlers()
Gets all the handlers in the phase.

Returns:
Returns an ArrayList of Handlers

getName

public java.lang.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(java.lang.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 java.lang.String getPhaseName()
Returns:
Returns the name.

setName

public void setName(java.lang.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


Copyright © 2007 Apache Web Services Project. All Rights Reserved.