com.redstarhackers.jta
Class TransactionEnclosure

java.lang.Object
  extended bycom.redstarhackers.jta.TransactionEnclosure
All Implemented Interfaces:
com.redstarhackers.func.Function

public class TransactionEnclosure
extends java.lang.Object
implements com.redstarhackers.func.Function

TODO Class summary sentence. Class documentation.

Version:
$Revision: 1202 $
Author:
$Author: kostya $

Constructor Summary
TransactionEnclosure()
          Default constructor.
TransactionEnclosure(com.redstarhackers.func.Function func)
          Constructs an enclosure to enclose the specified function.
 
Method Summary
 void addApplicationExceptionRollbackType(java.lang.Class classObj)
          Add a com.redstarhackers.exception.ApplicationException subtype that will trigger an automatic rollback if automatic rollback is enabled.
 void execute()
           
 java.util.Set getApplicationExceptionRollbackTypes()
          Get the specified com.redstarhackers.exception.ApplicationException subtypes that will trigger an automatic rollback if automatic rollback is enabled.
 com.redstarhackers.func.Function getEnclosed()
          Return the enclosed function.
 java.lang.Object getResult()
          Get the result of execution for the enclosed function, if any.
 javax.transaction.UserTransaction getUserTransaction()
          Return the user transaction used by this enclosure.
 boolean isApplicationExceptionRollbackEnabled()
          Return whether rollback will happen automatically when an com.redstarhackers.exception.ApplicationException occurs.
 void setApplicationExceptionRollbackEnabled(boolean val)
          Set whether or not a rollback will happen automatically when an com.redstarhackers.exception.ApplicationException occurs.
 void setEnclosed(com.redstarhackers.func.Function func)
          Set the function this enclosure encloses.
 void setUserTransaction(javax.transaction.UserTransaction usertx)
          Set the user transaction used by this enclosure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionEnclosure

public TransactionEnclosure()
Default constructor.


TransactionEnclosure

public TransactionEnclosure(com.redstarhackers.func.Function func)
Constructs an enclosure to enclose the specified function.

Parameters:
func - the function to enclose.
Method Detail

getUserTransaction

public javax.transaction.UserTransaction getUserTransaction()
Return the user transaction used by this enclosure.

Returns:
the user transaction

setUserTransaction

public void setUserTransaction(javax.transaction.UserTransaction usertx)
Set the user transaction used by this enclosure.

Parameters:
usertx - the new transaction to use (cannot be null).

isApplicationExceptionRollbackEnabled

public boolean isApplicationExceptionRollbackEnabled()
Return whether rollback will happen automatically when an com.redstarhackers.exception.ApplicationException occurs. The default setting for this is false.

Returns:
true if an application exception will trigger a rollback, false otherwise.

setApplicationExceptionRollbackEnabled

public void setApplicationExceptionRollbackEnabled(boolean val)
Set whether or not a rollback will happen automatically when an com.redstarhackers.exception.ApplicationException occurs.

Parameters:
val - the new value.

getApplicationExceptionRollbackTypes

public java.util.Set getApplicationExceptionRollbackTypes()
Get the specified com.redstarhackers.exception.ApplicationException subtypes that will trigger an automatic rollback if automatic rollback is enabled.

Returns:
a set of Class objects.

addApplicationExceptionRollbackType

public void addApplicationExceptionRollbackType(java.lang.Class classObj)
Add a com.redstarhackers.exception.ApplicationException subtype that will trigger an automatic rollback if automatic rollback is enabled.

Parameters:
classObj - the subtype that will trigger a rollback.

getEnclosed

public com.redstarhackers.func.Function getEnclosed()
Return the enclosed function.

Returns:
the enclosed function.

setEnclosed

public void setEnclosed(com.redstarhackers.func.Function func)
Set the function this enclosure encloses.

Parameters:
func - the new function instance (cannot be null).

getResult

public java.lang.Object getResult()
Get the result of execution for the enclosed function, if any.

Specified by:
getResult in interface com.redstarhackers.func.Function
Returns:
the result of the enclosed function, null if no result or it was undone.

execute

public void execute()
             throws com.redstarhackers.exception.ApplicationException,
                    com.redstarhackers.exception.SystemException
Specified by:
execute in interface com.redstarhackers.func.Function
Throws:
com.redstarhackers.exception.ApplicationException
com.redstarhackers.exception.SystemException