net.customware.gwt.dispatch.server
Class AbstractDispatch

java.lang.Object
  extended by net.customware.gwt.dispatch.server.AbstractDispatch
All Implemented Interfaces:
Dispatch
Direct Known Subclasses:
SimpleDispatch

public abstract class AbstractDispatch
extends Object
implements Dispatch

Abstract base implementation of the Dispatch

Provides basic action handler lookup and execution support. Lifecycle methods may be overriden by implementors to receive notifications regarding action execution and execution results.

Author:
David Peterson, Robert Munteanu

Constructor Summary
AbstractDispatch()
           
 
Method Summary
<A extends Action<R>,R extends Result>
R
execute(A action)
          Executes the specified action and returns the appropriate result.
protected
<A extends Action<R>,R extends Result>
void
executed(A action, R result, ActionHandler<A,R> handler, ExecutionContext ctx)
          Method invoked after the specified action has been succesfully executed with the specified handler.
protected
<A extends Action<R>,R extends Result>
void
executing(A action, ActionHandler<A,R> handler, ExecutionContext ctx)
          Method invoked before executing the specified action with the specified handler.
protected
<A extends Action<R>,R extends Result>
void
failed(A action, Throwable e, ActionHandler<A,R> handler, ExecutionContext ctx)
          Method invoked after the specified action has been unsuccesfully executed with the specified handler.
protected abstract  ActionHandlerRegistry getHandlerRegistry()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDispatch

public AbstractDispatch()
Method Detail

execute

public <A extends Action<R>,R extends Result> R execute(A action)
                         throws DispatchException
Description copied from interface: Dispatch
Executes the specified action and returns the appropriate result.

Specified by:
execute in interface Dispatch
Parameters:
action - The Action.
Returns:
The action's result.
Throws:
DispatchException - if the action execution failed.

getHandlerRegistry

protected abstract ActionHandlerRegistry getHandlerRegistry()

executing

protected <A extends Action<R>,R extends Result> void executing(A action,
                                                                ActionHandler<A,R> handler,
                                                                ExecutionContext ctx)
                  throws DispatchException
Method invoked before executing the specified action with the specified handler.

Any exception thrown from this method will prevent the normal execution of the action and will be propagated.

Type Parameters:
A - the action type
R - the result type
Parameters:
action - the action to execute
handler - the handler to execute it with
ctx - the execution context
Throws:
DispatchException - if the action execution should be cancelled

executed

protected <A extends Action<R>,R extends Result> void executed(A action,
                                                               R result,
                                                               ActionHandler<A,R> handler,
                                                               ExecutionContext ctx)
Method invoked after the specified action has been succesfully executed with the specified handler.

This method must not throw any exceptions.

Type Parameters:
A - the action type
R - the result type
Parameters:
action - the action to execute
result - the execution result
handler - the handler to execute it with
ctx - the execution context

failed

protected <A extends Action<R>,R extends Result> void failed(A action,
                                                             Throwable e,
                                                             ActionHandler<A,R> handler,
                                                             ExecutionContext ctx)
Method invoked after the specified action has been unsuccesfully executed with the specified handler.

This method must not throw any exceptions.

Type Parameters:
A - the action type
R - the result type
Parameters:
action - the action to execute
e - the exception thrown by the handler or by the executing method
handler - the handler to execute it with
ctx - the execution context


Copyright © 2011 customware.net. All Rights Reserved.