IBM WebSphere Extended Deployment (XD)TM
Release 6.0.1

com.ibm.websphere.objectgrid.plugins
TransactionCallback



Calling methods on Session will send corresponding events to the TransactionCallback. An ObjectGrid can have zero or 1 TransactionCallback. BackingMaps defined on an ObjectGrid with a TransactionCallback should have corresponding Loaders.

The TransactionCallback can work with the Loaders and place transaction specific objects in slots on the TxID object that the Loaders can obtain. Examples are database connections, prepared statement caches etc. The TransactionCallback should reserve slots in the TxID by calling ObjectGrid.reserveSlot using the name TxID.SLOT_NAME. The TransactionCallback can then put an object at that index in the TxID. The Loader can retrieve the index used by the TransactionCallback by calling a private method on the TransactionCallback and a reference to that can be found using the TxID.getSession().getObjectGrid().getTransactionCallback() code sequence.
See Also:

    reserveSlot(String)putSlot(int, Object)getSlot(int)getSession()getObjectGrid()setTransactionCallback(TransactionCallback)getTransactionCallback()



Method Summary
public  voidinitialize(com.ibm.websphere.objectgrid.ObjectGrid)
           This is a one time method called by the ObjectGrid to initialize this callback.
public  voidbegin(com.ibm.websphere.objectgrid.TxID)
           This method will be used when starting a cache-local transaction. The TransactionCallback.
public  voidcommit(com.ibm.websphere.objectgrid.TxID)
           The cache wants to commit the transaction and passes the begin state Object to the callee. The caller.
public  voidrollback(com.ibm.websphere.objectgrid.TxID)
           This is called when the transaction rolls back.
public  booleanisExternalTransactionActive(com.ibm.websphere.objectgrid.Session)
           This is called when an application attempts to use a Session with no transaction active. The.

Method Detail

initialize

public void initialize(ObjectGrid objectGrid)
This is a one time method called by the ObjectGrid to initialize this callback.
Parameters:
    objectGrid - A reference to the ObjectGrid.


Throws:
    com.ibm.websphere.objectgrid.plugins.TransactionCallbackException


begin

public void begin(TxID id)
This method will be used when starting a cache-local transaction. The TransactionCallback can then communicate the begin processing (along with the TxID) to the appropriate BaseMap and/or Loader. The Loader may use this signal to start a corresponding transaction on the underlying connection to the database.
Parameters:
    id - transaction identifer (TxID)


Throws:
    com.ibm.websphere.objectgrid.plugins.TransactionCallbackException


commit

public void commit(TxID id)
The cache wants to commit the transaction and passes the begin state Object to the callee. The caller should commit the transaction and return any underlying connection back to the pool.
Parameters:
    id - transaction identifier (TxID)


Throws:
    com.ibm.websphere.objectgrid.plugins.TransactionCallbackException


rollback

public void rollback(TxID id)
This is called when the transaction rolls back.
Parameters:
    id - transaction identifier (TxID)


Throws:
    com.ibm.websphere.objectgrid.plugins.TransactionCallbackException


isExternalTransactionActive

public boolean isExternalTransactionActive(Session session)
This is called when an application attempts to use a Session with no transaction active. The callback can return true in which case an auto begin is executed. If false is returns then an application exception is thrown indicating no transaction is active. This event is usually used when integrating with a J2EE environment such as WebSphere.
Parameters:
    session - The session which the application is using


Returns:
     true if an auto begin should be done, false if this is not the case


IBM WebSphere Extended Deployment (XD)TM
Release 6.0.1