com.atlassian.xwork.interceptors
Class XWorkTransactionInterceptor

java.lang.Object
  extended by com.atlassian.xwork.interceptors.XWorkTransactionInterceptor
All Implemented Interfaces:
com.opensymphony.xwork.interceptor.Interceptor, Serializable

public abstract class XWorkTransactionInterceptor
extends Object
implements com.opensymphony.xwork.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:
Serialized Form

Constructor Summary
XWorkTransactionInterceptor()
           
 
Method Summary
static org.springframework.transaction.TransactionStatus currentTransactionStatus()
          Deprecated. since atlassian-xwork 1.1 - you should really use Spring directly for this sort of thing
 void destroy()
           
abstract  org.springframework.transaction.PlatformTransactionManager getTransactionManager()
          Template method for retrieving the transaction manager for the current application.
 void init()
           
 String intercept(com.opensymphony.xwork.ActionInvocation invocation)
           
protected abstract  boolean shouldIntercept(com.opensymphony.xwork.ActionInvocation invocation)
          Determine if a certain action should be wrapped in a transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWorkTransactionInterceptor

public XWorkTransactionInterceptor()
Method Detail

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.xwork.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 interface com.opensymphony.xwork.interceptor.Interceptor

init

public void init()
Specified by:
init in interface com.opensymphony.xwork.interceptor.Interceptor

intercept

public String intercept(com.opensymphony.xwork.ActionInvocation invocation)
                 throws Exception
Specified by:
intercept in interface com.opensymphony.xwork.interceptor.Interceptor
Throws:
Exception

currentTransactionStatus

public static org.springframework.transaction.TransactionStatus currentTransactionStatus()
                                                                                  throws RuntimeException
Deprecated. since atlassian-xwork 1.1 - you should really use Spring directly for this sort of thing

Return the transaction status of the current method invocation. Mainly intended for code that wants to set the current transaction rollback-only but not throw an application exception.

Returns:
the status of the current transaction
Throws:
RuntimeException - if the invocation cannot be found, because the method was invoked outside an AOP invocation context


Copyright © 2011 Atlassian Pty Ltd. All Rights Reserved.