org.loom.interceptor
Class InterceptorProxy

java.lang.Object
  extended by org.loom.interceptor.InterceptorProxy
All Implemented Interfaces:
CreateInterceptor, ErrorListener, ExecuteInterceptor, FinallyListener, Interceptor, PopulateInterceptor, ResolutionInterceptor, ValidateInterceptor, ButtonDecorator, FormDecorator, LinkDecorator

public class InterceptorProxy
extends java.lang.Object
implements CreateInterceptor, PopulateInterceptor, ValidateInterceptor, ExecuteInterceptor, FinallyListener, ResolutionInterceptor, ErrorListener, LinkDecorator, FormDecorator, ButtonDecorator

Maintains a list of listeners. For performance, this listener maintains a separate list for each phase of the event execution.


Constructor Summary
InterceptorProxy()
           
 
Method Summary
<T extends Interceptor>
void
addListener(T listener)
          Adds a listener that implements one or more of the listener interfaces
 Resolution afterCreate(ParsedAction action)
           
 Resolution beforeExecute(ParsedAction action)
           
 Resolution beforePopulate(ParsedAction action)
           
 void beforeResolution(ParsedAction action, Resolution resolution)
          Gets invoked before resolution.resolve()
 Resolution beforeValidate(ParsedAction action)
           
 void decorate(Button button)
           
 void decorate(Form form)
           
 void decorate(Link link)
          Modify a link pointing here.
 void doFinally(ParsedAction action, java.lang.Exception e)
           
<T extends Interceptor>
java.util.Set<T>
findInterceptorsWithClass(java.lang.Class<T> interceptorClass)
           
 java.util.List<CreateInterceptor> getCreateListeners()
           
 java.util.List<ErrorListener> getErrorListeners()
           
 java.util.List<ExecuteInterceptor> getExecuteListeners()
           
 java.util.List<FinallyListener> getFinallyListeners()
           
 java.util.List<PopulateInterceptor> getPopulateListeners()
           
 java.util.List<ValidateInterceptor> getValidateListeners()
           
 boolean isEmpty()
           
 Resolution onError(ParsedAction action)
           
 void remove(Interceptor listener)
          Remove the supplied interceptor instance from this list
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InterceptorProxy

public InterceptorProxy()
Method Detail

addListener

public <T extends Interceptor> void addListener(T listener)
Adds a listener that implements one or more of the listener interfaces


findInterceptorsWithClass

public <T extends Interceptor> java.util.Set<T> findInterceptorsWithClass(java.lang.Class<T> interceptorClass)
Returns:
a Set of all registered interceptors of the supplied class

remove

public void remove(Interceptor listener)
Remove the supplied interceptor instance from this list

Parameters:
listener - the instance to be removed

afterCreate

public Resolution afterCreate(ParsedAction action)
Specified by:
afterCreate in interface CreateInterceptor
Parameters:
action - the action and event that is being executed
Returns:
if return value != null, stops the execution of the workflow and return the provided resolution

beforePopulate

public Resolution beforePopulate(ParsedAction action)
Specified by:
beforePopulate in interface PopulateInterceptor
Parameters:
action - the action and event that is being executed
Returns:
if return value != null, stops the execution of the workflow and return the provided resolution

beforeValidate

public Resolution beforeValidate(ParsedAction action)
Specified by:
beforeValidate in interface ValidateInterceptor
Parameters:
action - the action and event that is being executed
Returns:
if return value != null, stops the execution of the workflow and return the provided resolution

beforeExecute

public Resolution beforeExecute(ParsedAction action)
Specified by:
beforeExecute in interface ExecuteInterceptor
Parameters:
action - the action and event that is being executed
Returns:
if return value != null, stops the execution of the workflow and return the provided resolution

beforeResolution

public void beforeResolution(ParsedAction action,
                             Resolution resolution)
Description copied from interface: ResolutionInterceptor
Gets invoked before resolution.resolve()

Specified by:
beforeResolution in interface ResolutionInterceptor
Parameters:
action - the action and event that is being executed
resolution - the action and event that is being executed

onError

public Resolution onError(ParsedAction action)
Specified by:
onError in interface ErrorListener
Parameters:
action - the action and event that were being executed
Returns:
if return value != null, stops the execution of the workflow and return the provided resolution

doFinally

public void doFinally(ParsedAction action,
                      java.lang.Exception e)
Specified by:
doFinally in interface FinallyListener
Parameters:
action - the action and event that is being executed
e - If any exception was thrown in any phase (populate, validate, execute), null if none.

toString

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

isEmpty

public boolean isEmpty()

decorate

public void decorate(Link link)
Description copied from interface: LinkDecorator
Modify a link pointing here.

Specified by:
decorate in interface LinkDecorator

decorate

public void decorate(Form form)
Specified by:
decorate in interface FormDecorator

decorate

public void decorate(Button button)
Specified by:
decorate in interface ButtonDecorator

getCreateListeners

public java.util.List<CreateInterceptor> getCreateListeners()

getPopulateListeners

public java.util.List<PopulateInterceptor> getPopulateListeners()

getValidateListeners

public java.util.List<ValidateInterceptor> getValidateListeners()

getExecuteListeners

public java.util.List<ExecuteInterceptor> getExecuteListeners()

getFinallyListeners

public java.util.List<FinallyListener> getFinallyListeners()

getErrorListeners

public java.util.List<ErrorListener> getErrorListeners()