org.mentawai.filter
Class TransactionFilter

java.lang.Object
  extended by org.mentawai.filter.TransactionFilter
All Implemented Interfaces:
Filter

public class TransactionFilter
extends Object
implements Filter

Mentawai filter for transaction managment. This filters starts a transaction before the action's execution and commits or rollbacks the transaction after the action's execution, depending on the the action's execution result.

The default value for commiting the transaction is SUCCESS but this can be configurated, passing a list of results that allow the commit of the transactionon.

Also, if a exception is throwed by the action's execution, the transaction is rollbacked.

The transaction filter requires that in the moment that the action's executed is filtered the action's input have an object of a org.mentawai.transaction.Transation implementation class. This object may be injected by the IoCFilter. See the site documentation for details.

The default expected key of the transaction is "transaction", but that can be changed.

Author:
Rubem Azenha (rubem.azenha@gmail.com), Sergio Oliveira Jr. (sergio.oliveira.jr@gmail.com)

Field Summary
static String TRANSACTION_KEY
           
 
Constructor Summary
TransactionFilter()
          Creates a new TransactionFilter using the default key for the transaction and the default result for the transaction commit.
TransactionFilter(boolean onlyPost)
           
TransactionFilter(String transaction_key)
          Creates a new TransactionFilter using the given key for the transaction and the default result for the transaction commit.
TransactionFilter(String transaction_key, boolean onlyPost)
           
 
Method Summary
 TransactionFilter commitOn(String... results)
           
 void destroy()
          Do nothing.
 String filter(InvocationChain chain)
          Filters the action, begining a transaction before the action's execution and commiting or rollbacking the trasaction after the action's exection depending on the result.
 Set<String> getResultsForCommit()
           
 Set<String> getResultsForRollback()
           
 TransactionFilter rollbackOn(String... results)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSACTION_KEY

public static String TRANSACTION_KEY
Constructor Detail

TransactionFilter

public TransactionFilter()
Creates a new TransactionFilter using the default key for the transaction and the default result for the transaction commit.


TransactionFilter

public TransactionFilter(boolean onlyPost)

TransactionFilter

public TransactionFilter(String transaction_key)
Creates a new TransactionFilter using the given key for the transaction and the default result for the transaction commit.

Parameters:
transaction_key -

TransactionFilter

public TransactionFilter(String transaction_key,
                         boolean onlyPost)
Method Detail

commitOn

public TransactionFilter commitOn(String... results)

rollbackOn

public TransactionFilter rollbackOn(String... results)

filter

public String filter(InvocationChain chain)
              throws Exception
Filters the action, begining a transaction before the action's execution and commiting or rollbacking the trasaction after the action's exection depending on the result.

Specified by:
filter in interface Filter
Parameters:
chain - The InvocationChain for the action this filter is being applied to.
Returns:
The result of the filter or the action the filter is being applied to.
Throws:
Exception

getResultsForCommit

public Set<String> getResultsForCommit()
Returns:
the results that will make the transaction be commited after the action's execution.

getResultsForRollback

public Set<String> getResultsForRollback()

destroy

public void destroy()
Do nothing.

Specified by:
destroy in interface Filter


Copyright © 2013. All Rights Reserved.