Class XWorkTransactionInterceptor
java.lang.Object
com.atlassian.crowd.xwork.interceptors.XWorkTransactionInterceptor
- All Implemented Interfaces:
com.opensymphony.xwork2.interceptor.Interceptor
,Serializable
- Direct Known Subclasses:
CrowdXWorkTransactionInterceptor
public abstract class XWorkTransactionInterceptor
extends Object
implements com.opensymphony.xwork2.interceptor.Interceptor
Manages two separate database transactions around the action execution and result execution
in XWork, using the Spring PlatformTransactionManager.
The first transaction begins as soon as this interceptor executes. It is committed in a PreResultListener
which runs just before the result executes. The second transaction is opened
in the same listener. The second transaction is committed when control returns to the interceptor
after the action and result executions are both complete.
The active transaction will be rolled back if an exception is caught by this interceptor during the execution of either the action or the result.
Implementations should override getTransactionManager()
to provide the Spring transaction
manager, and shouldIntercept(ActionInvocation)
to configure when transactions should be
applied to actions.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
abstract org.springframework.transaction.PlatformTransactionManager
Template method for retrieving the transaction manager for the current application.void
init()
intercept
(com.opensymphony.xwork2.ActionInvocation invocation) protected abstract boolean
shouldIntercept
(com.opensymphony.xwork2.ActionInvocation invocation) Determine if a certain action should be wrapped in a transaction.
-
Constructor Details
-
XWorkTransactionInterceptor
public XWorkTransactionInterceptor()
-
-
Method Details
-
getTransactionManager
public abstract org.springframework.transaction.PlatformTransactionManager getTransactionManager()Template method for retrieving the transaction manager for the current application.- Returns:
- the transaction manager for this application
-
shouldIntercept
protected abstract boolean shouldIntercept(com.opensymphony.xwork2.ActionInvocation invocation) Determine if a certain action should be wrapped in a transaction. Applications should override this method if they want to prevent specific actions from being intercepted, or want to prevent transactions from being created before the system is fully set up.- Parameters:
invocation
- the action being invoked- Returns:
- true if the action should be wrapped in a transaction
-
destroy
public void destroy()- Specified by:
destroy
in interfacecom.opensymphony.xwork2.interceptor.Interceptor
-
init
public void init()- Specified by:
init
in interfacecom.opensymphony.xwork2.interceptor.Interceptor
-
intercept
- Specified by:
intercept
in interfacecom.opensymphony.xwork2.interceptor.Interceptor
- Throws:
Exception
-