org.qi4j.library.struts2
Class UnitOfWorkInterceptor
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
org.qi4j.library.struts2.UnitOfWorkInterceptor
- All Implemented Interfaces:
- com.opensymphony.xwork2.interceptor.Interceptor, Serializable
public class UnitOfWorkInterceptor
- extends com.opensymphony.xwork2.interceptor.AbstractInterceptor
An interceptor to be used to start a UnitOfWork if one has not yet been started. If this interceptor creates a
new UnitOfWork it will also add a PreResultListener to make sure the unit of work is completed or discarded before
the result is executed. This is important so that the rendering of the result does not make any changes to the
entities it is dealing with (we can maybe make this an option, to keep the UnitOfWork open until the invocation stack
returns to this interceptor or if it should use the PreResultListener, but for now I like the PreResultListener
better as it is safer).
When a new UnitOfWork is created by this interceptor a decision must be made when closing it whether to discard
the UnitOfWork or complete it. For now, if the resultCode is "success", we complete the UnitOfWork, otherwise we
discard it. There are many things we can do here to make it more flexible, e.g. allow the user to specify result
codes to complete or, conversely, codes that should result in the UnitOfWork being discarded. Since we have access
to the action invocation we could also do something with annotations on the method to be executed to allow user to
specify more specifically for that method what results should result in discards or completions.
- See Also:
- Serialized Form
Method Summary |
String |
intercept(com.opensymphony.xwork2.ActionInvocation invocation)
|
protected boolean |
shouldComplete(com.opensymphony.xwork2.ActionInvocation invocation,
String resultCode)
|
Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor |
destroy, init |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UnitOfWorkInterceptor
public UnitOfWorkInterceptor()
intercept
public String intercept(com.opensymphony.xwork2.ActionInvocation invocation)
throws Exception
- Specified by:
intercept
in interface com.opensymphony.xwork2.interceptor.Interceptor
- Specified by:
intercept
in class com.opensymphony.xwork2.interceptor.AbstractInterceptor
- Throws:
Exception
shouldComplete
protected boolean shouldComplete(com.opensymphony.xwork2.ActionInvocation invocation,
String resultCode)