org.objectweb.jonas.dbm
Class PoolItem

java.lang.Object
  extended byorg.objectweb.jonas.dbm.PoolItem
All Implemented Interfaces:
org.objectweb.transaction.api.ResourceManagerEvent, javax.transaction.Synchronization

public class PoolItem
extends java.lang.Object
implements org.objectweb.transaction.api.ResourceManagerEvent, javax.transaction.Synchronization

This class represents a connection stored in the pool. It may be in different states: - available and reuseable for this user (open=0, tx=null) - reusable for the same transaction, not already committed (open=?, tx!=null) - still open, but not involved in a Tx (open=1, tx=null) These 2 cases must be considered: close after commit, commit after close. We cannot suppose what shema the user will use and we must handle both correctly.


Constructor Summary
PoolItem(Pool pool, javax.sql.XAConnection xac, java.lang.String user)
           
 
Method Summary
 void afterCompletion(int status)
          synchronization implementation
 void beforeCompletion()
          synchronization implementation
 boolean close()
          notify as closed
 void enlistConnection(javax.transaction.Transaction transaction)
          implementation of resource manager event
 int getOpenCount()
           
 javax.transaction.Transaction getTx()
           
 javax.sql.XAConnection getXACon()
           
 boolean inactive()
          Check if the connection has been unused for too long time.
 boolean isAged()
           
 boolean isClosed()
           
 boolean isOpen()
           
 boolean isRME()
           
 void open()
          Notify as opened
 void remove()
          remove this item
 void setRME(boolean rme)
          set/unset as RME
 void setTx(javax.transaction.Transaction tx)
          Set the associated transaction
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PoolItem

public PoolItem(Pool pool,
                javax.sql.XAConnection xac,
                java.lang.String user)
Method Detail

toString

public java.lang.String toString()

enlistConnection

public void enlistConnection(javax.transaction.Transaction transaction)
                      throws javax.transaction.SystemException
implementation of resource manager event

Specified by:
enlistConnection in interface org.objectweb.transaction.api.ResourceManagerEvent
Throws:
javax.transaction.SystemException

beforeCompletion

public void beforeCompletion()
synchronization implementation

Specified by:
beforeCompletion in interface javax.transaction.Synchronization

afterCompletion

public void afterCompletion(int status)
synchronization implementation

Specified by:
afterCompletion in interface javax.transaction.Synchronization

isAged

public boolean isAged()
Returns:
true if connection max age has expired

isOpen

public boolean isOpen()
Returns:
true if connection is still open

getOpenCount

public int getOpenCount()
Returns:
open count

inactive

public boolean inactive()
Check if the connection has been unused for too long time. This occurs usually when the caller forgot to call close().

Returns:
true if open time has been reached, and not involved in a tx.

isClosed

public boolean isClosed()
Returns:
true if connection is closed

open

public void open()
Notify as opened


close

public boolean close()
notify as closed

Returns:
true if normal close.

getXACon

public javax.sql.XAConnection getXACon()
Returns:
the associated XAConnection

setTx

public void setTx(javax.transaction.Transaction tx)
Set the associated transaction

Parameters:
tx - Transaction

getTx

public javax.transaction.Transaction getTx()
Returns:
the Transaction

isRME

public boolean isRME()
Returns:
true if registered as RME

setRME

public void setRME(boolean rme)
set/unset as RME


remove

public void remove()
remove this item