org.jbpm.tx
Class StandardTransaction

java.lang.Object
  extended by org.jbpm.util.DefaultObservable
      extended by org.jbpm.tx.StandardTransaction
All Implemented Interfaces:
java.io.Serializable, Transaction, Listener, Observable

public class StandardTransaction
extends DefaultObservable
implements Transaction, java.io.Serializable, Listener

simple 2 phase commit transaction. no logging or recovery. non thread safe (which is ok).

Author:
Tom Baeyens
See Also:
Serialized Form

Field Summary
protected  Environment environment
           
protected  java.util.List<Resource> resources
           
protected  java.lang.String state
           
static java.lang.String STATE_ACTIVE
           
static java.lang.String STATE_COMMITTED
           
static java.lang.String STATE_COMMITTING
           
static java.lang.String STATE_MARKED_ROLLBACK
           
static java.lang.String STATE_ROLLEDBACK
           
static java.lang.String STATE_ROLLING_BACK
           
 
Fields inherited from class org.jbpm.util.DefaultObservable
listeners
 
Fields inherited from interface org.jbpm.tx.Transaction
EVENT_AFTERCOMPLETION, EVENT_BEFORECOMPLETION, EVENT_FLUSH
 
Constructor Summary
StandardTransaction()
           
 
Method Summary
 void commit()
          implements simplest two phase commit.
 void enlistResource(Resource resource)
           
 void event(java.lang.Object source, java.lang.String eventName, java.lang.Object info)
          This transaction will always listen to the close of the block context.
 boolean isCommitted()
           
 boolean isRollbackOnly()
           
 boolean isRolledBack()
           
 void rollback()
           
 void rollback(boolean fireBeforeCompletionEvent)
           
 void setEnvironment(Environment environment)
           
 void setRollbackOnly()
          marks a transaction for rollback only.
 java.lang.String toString()
           
 
Methods inherited from class org.jbpm.util.DefaultObservable
addListener, addListener, addListener, fire, fire, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jbpm.util.Observable
addListener, addListener, addListener, fire, fire, removeListener
 

Field Detail

STATE_ACTIVE

public static final java.lang.String STATE_ACTIVE
See Also:
Constant Field Values

STATE_COMMITTING

public static final java.lang.String STATE_COMMITTING
See Also:
Constant Field Values

STATE_COMMITTED

public static final java.lang.String STATE_COMMITTED
See Also:
Constant Field Values

STATE_MARKED_ROLLBACK

public static final java.lang.String STATE_MARKED_ROLLBACK
See Also:
Constant Field Values

STATE_ROLLING_BACK

public static final java.lang.String STATE_ROLLING_BACK
See Also:
Constant Field Values

STATE_ROLLEDBACK

public static final java.lang.String STATE_ROLLEDBACK
See Also:
Constant Field Values

environment

protected Environment environment

resources

protected java.util.List<Resource> resources

state

protected java.lang.String state
Constructor Detail

StandardTransaction

public StandardTransaction()
Method Detail

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: Transaction
marks a transaction for rollback only. The transaction will be rolled back upon closing the environment.

Specified by:
setRollbackOnly in interface Transaction

isRollbackOnly

public boolean isRollbackOnly()
Specified by:
isRollbackOnly in interface Transaction

isCommitted

public boolean isCommitted()
Specified by:
isCommitted in interface Transaction

isRolledBack

public boolean isRolledBack()
Specified by:
isRolledBack in interface Transaction

enlistResource

public void enlistResource(Resource resource)

event

public void event(java.lang.Object source,
                  java.lang.String eventName,
                  java.lang.Object info)
This transaction will always listen to the close of the block context. If the transaction is still active at that time, it will be committed. If it is marked for rollback it will be rolled back.

Specified by:
event in interface Listener
Parameters:
source - Observable that fired the event.
eventName - name of the event.
info - informations about the fired event.

commit

public void commit()
implements simplest two phase commit.


rollback

public void rollback()

rollback

public void rollback(boolean fireBeforeCompletionEvent)

setEnvironment

public void setEnvironment(Environment environment)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object