org.objectweb.speedo.jca
Class JdoManagedConnection

java.lang.Object
  extended byorg.objectweb.speedo.jca.JdoManagedConnection
All Implemented Interfaces:
javax.resource.cci.LocalTransaction, javax.resource.spi.LocalTransaction, javax.resource.spi.ManagedConnection, javax.resource.spi.ManagedConnectionMetaData, javax.transaction.xa.XAResource

public class JdoManagedConnection
extends java.lang.Object
implements javax.resource.spi.ManagedConnection, javax.resource.spi.LocalTransaction, javax.resource.cci.LocalTransaction, javax.transaction.xa.XAResource, javax.resource.spi.ManagedConnectionMetaData

Author:
P. Dechamboux

Field Summary
protected  JDOConnectionSpec cri
           
static java.lang.String EIS_PRODUCT_NAME
           
static java.lang.String EIS_PRODUCT_VERSION
           
static java.lang.String USER_NAME
           
 XAContext xac
          It is the current XAContext.
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Method Summary
 void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          Adds a listener to the listeners list if it has not already been done.
 void associateConnection(java.lang.Object o)
          Associates a new Connection to this ManagedConnection.
 void begin()
          Begins the LocalTransaction if it has not already been started.
 void cleanup()
          Cleans up the connection.
 void commit()
          Commits the LocalTransaction if it is active.
 void commit(javax.transaction.xa.Xid xid, boolean b)
          Unbind the PersistenceManager to the xid.
 void destroy()
          Called when ManagedConnection is removed.
protected  void dissociateConnection(java.lang.Object conn)
          Dissociates a Connection from the ones that are associated to this ManagedConnection.
 void end(javax.transaction.xa.Xid xid, int i)
          Unbind this instance to the PersistenceManager.
 void forget(javax.transaction.xa.Xid xid)
           
 java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo info)
          Delegates the creation of a Connection to the ConnectionFactory.
 java.lang.String getEISProductName()
           
 java.lang.String getEISProductVersion()
           
 javax.resource.spi.LocalTransaction getLocalTransaction()
           
 java.io.PrintWriter getLogWriter()
          Not supported yet.
 int getMaxConnections()
           
 javax.resource.spi.ManagedConnectionMetaData getMetaData()
           
protected  ProxyManager getProxyManager()
          Retrieves the right ProxyManager in according the managed connection state (in a local transaction, in a XA transaction or out of transaction)
 int getTransactionTimeout()
           
 java.lang.String getUserName()
           
 javax.transaction.xa.XAResource getXAResource()
          Retrieves an XA resource.
 boolean isSameRM(javax.transaction.xa.XAResource resource)
          Used by JTA in order to verify that it has not already registered a XAResource to manage this transaction context from this RM.
protected  boolean localTransactionTerminated()
          Specifies if this ManagedConnection still has an active LocalTransaction.
 int prepare(javax.transaction.xa.Xid xid)
          Prepares the underlying JdoTxContext (prepare phase of the 2PC).
 javax.transaction.xa.Xid[] recover(int i)
          Gets the Xid of distributed transactions to be recovered from the JDO manager.
 void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          Removes a listener from the listeners list.
 void rollback()
          Rollbacks the LocalTransaction if it is active.
 void rollback(javax.transaction.xa.Xid xid)
          Unbind the PersistenceManager to the xid.
 void setLogWriter(java.io.PrintWriter writer)
          Not supported yet.
 boolean setTransactionTimeout(int i)
           
 void start(javax.transaction.xa.Xid xid, int i)
          Assigns an actual JDO transaction context to the XAResource within the give DTP context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EIS_PRODUCT_NAME

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

EIS_PRODUCT_VERSION

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

USER_NAME

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

xac

public XAContext xac
It is the current XAContext. It is not null when the ManagedConnection is used in a XA transaction through the XAResource interface.


cri

protected JDOConnectionSpec cri
Method Detail

getProxyManager

protected ProxyManager getProxyManager()
Retrieves the right ProxyManager in according the managed connection state (in a local transaction, in a XA transaction or out of transaction)

Returns:
a ProxyManager instance (never null).

localTransactionTerminated

protected boolean localTransactionTerminated()
Specifies if this ManagedConnection still has an active LocalTransaction.

Returns:
true if a LocalTransaction is still active.

dissociateConnection

protected void dissociateConnection(java.lang.Object conn)
                             throws javax.resource.ResourceException
Dissociates a Connection from the ones that are associated to this ManagedConnection.

Parameters:
conn - The Connection to be dissociated.
Throws:
javax.resource.ResourceException

getEISProductName

public java.lang.String getEISProductName()
                                   throws javax.resource.ResourceException
Specified by:
getEISProductName in interface javax.resource.spi.ManagedConnectionMetaData
Throws:
javax.resource.ResourceException

getEISProductVersion

public java.lang.String getEISProductVersion()
                                      throws javax.resource.ResourceException
Specified by:
getEISProductVersion in interface javax.resource.spi.ManagedConnectionMetaData
Throws:
javax.resource.ResourceException

getMaxConnections

public int getMaxConnections()
                      throws javax.resource.ResourceException
Specified by:
getMaxConnections in interface javax.resource.spi.ManagedConnectionMetaData
Throws:
javax.resource.ResourceException

getUserName

public java.lang.String getUserName()
                             throws javax.resource.ResourceException
Specified by:
getUserName in interface javax.resource.spi.ManagedConnectionMetaData
Throws:
javax.resource.ResourceException

getConnection

public java.lang.Object getConnection(javax.security.auth.Subject subject,
                                      javax.resource.spi.ConnectionRequestInfo info)
                               throws javax.resource.ResourceException
Delegates the creation of a Connection to the ConnectionFactory. "subject" and "info" parameters are ignored.

Specified by:
getConnection in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

cleanup

public void cleanup()
             throws javax.resource.ResourceException
Cleans up the connection.

Specified by:
cleanup in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

destroy

public void destroy()
             throws javax.resource.ResourceException
Called when ManagedConnection is removed.

Specified by:
destroy in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

associateConnection

public void associateConnection(java.lang.Object o)
                         throws javax.resource.ResourceException
Associates a new Connection to this ManagedConnection. Nothing is done if it has already been associated (enforces no duplicate).

Specified by:
associateConnection in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

addConnectionEventListener

public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Adds a listener to the listeners list if it has not already been done. This means that duplicates are ignored. It first creates this list if needed (creation at first add).

Specified by:
addConnectionEventListener in interface javax.resource.spi.ManagedConnection

removeConnectionEventListener

public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Removes a listener from the listeners list. If the list does not eist (null), or if this listener does not belong to this list, nothing is done.

Specified by:
removeConnectionEventListener in interface javax.resource.spi.ManagedConnection

getXAResource

public javax.transaction.xa.XAResource getXAResource()
                                              throws javax.resource.ResourceException
Retrieves an XA resource. Switches running mode to XA.

Specified by:
getXAResource in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

getLocalTransaction

public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                        throws javax.resource.ResourceException
Specified by:
getLocalTransaction in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

getMetaData

public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                         throws javax.resource.ResourceException
Specified by:
getMetaData in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

setLogWriter

public void setLogWriter(java.io.PrintWriter writer)
                  throws javax.resource.ResourceException
Not supported yet.

Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws javax.resource.ResourceException
Not supported yet.

Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException

begin

public void begin()
           throws javax.resource.ResourceException
Begins the LocalTransaction if it has not already been started.

Specified by:
begin in interface javax.resource.spi.LocalTransaction
Throws:
javax.resource.ResourceException

commit

public void commit()
            throws javax.resource.ResourceException
Commits the LocalTransaction if it is active.

Specified by:
commit in interface javax.resource.spi.LocalTransaction
Throws:
javax.resource.ResourceException

rollback

public void rollback()
              throws javax.resource.ResourceException
Rollbacks the LocalTransaction if it is active.

Specified by:
rollback in interface javax.resource.spi.LocalTransaction
Throws:
javax.resource.ResourceException

start

public void start(javax.transaction.xa.Xid xid,
                  int i)
           throws javax.transaction.xa.XAException
Assigns an actual JDO transaction context to the XAResource within the give DTP context.

Specified by:
start in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

end

public void end(javax.transaction.xa.Xid xid,
                int i)
         throws javax.transaction.xa.XAException
Unbind this instance to the PersistenceManager.

Specified by:
end in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

isSameRM

public boolean isSameRM(javax.transaction.xa.XAResource resource)
                 throws javax.transaction.xa.XAException
Used by JTA in order to verify that it has not already registered a XAResource to manage this transaction context from this RM. If it is the case, both XAResource are warned of this fact (endWithNoSameRM = false). This means that these XAResource will be released at "end" time.

Specified by:
isSameRM in interface javax.transaction.xa.XAResource
Parameters:
resource - The resource to be compared against this one wrt RM.
Throws:
javax.transaction.xa.XAException

prepare

public int prepare(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Prepares the underlying JdoTxContext (prepare phase of the 2PC).

Specified by:
prepare in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

commit

public void commit(javax.transaction.xa.Xid xid,
                   boolean b)
            throws javax.transaction.xa.XAException
Unbind the PersistenceManager to the xid. The real commit is done by the PersistenceManager registered as a Synchronization.

Specified by:
commit in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

rollback

public void rollback(javax.transaction.xa.Xid xid)
              throws javax.transaction.xa.XAException
Unbind the PersistenceManager to the xid. The real commit is done by the PersistenceManager registered as a Synchronization.

Specified by:
rollback in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

forget

public void forget(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Specified by:
forget in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

recover

public javax.transaction.xa.Xid[] recover(int i)
                                   throws javax.transaction.xa.XAException
Gets the Xid of distributed transactions to be recovered from the JDO manager.

Specified by:
recover in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

getTransactionTimeout

public int getTransactionTimeout()
                          throws javax.transaction.xa.XAException
Specified by:
getTransactionTimeout in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException

setTransactionTimeout

public boolean setTransactionTimeout(int i)
                              throws javax.transaction.xa.XAException
Specified by:
setTransactionTimeout in interface javax.transaction.xa.XAResource
Throws:
javax.transaction.xa.XAException