org.jboss.test.jca.adapter
Class TestManagedConnection

java.lang.Object
  extended byorg.jboss.test.jca.adapter.TestManagedConnection
All Implemented Interfaces:
ManagedConnection (src) , XAResource (src)

public class TestManagedConnection
extends java.lang.Object
implements ManagedConnection (src) , XAResource (src)

TestManagedConnection.java Created: Mon Dec 31 17:07:16 2001


Field Summary
 
Fields inherited from interface javax.transaction.xa.XAResource (src)
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
TestManagedConnection(javax.security.auth.Subject subject, TestConnectionRequestInfo (src)  cri, int id)
           
 
Method Summary
 void addConnectionEventListener(ConnectionEventListener (src)  cel)
          Adds a connection event listener
 void associateConnection(java.lang.Object p)
          Associates a new application level connection handle with the connection.
 void cleanup()
          Application server calls this to force cleanup of connection.
 void commit(Xid (src)  xid, boolean onePhase)
          Commit the work done on this resource in the given transaction.
 void destroy()
          Destroys the connection to the underlying resource.
 void end(Xid (src)  xid, int flags)
          Called to disassociate the resource from a transaction.
 void forget(Xid (src)  xid)
          Tells the resource manager to forget about a heuristic decision.
 java.lang.Object getConnection(javax.security.auth.Subject param1, ConnectionRequestInfo (src)  param2)
          Creates a new connection handle for the underlying connection.
 LocalTransaction (src) getLocalTransaction()
          Returns a LocalTransaction instance.
 java.io.PrintWriter getLogWriter()
          Gets the logwriter for this instance.
 ManagedConnectionMetaData (src) getMetaData()
          Gets metadata inormation for this instances underlying resource manager instance.
 int getTransactionTimeout()
          Get the current transaction timeout value for this resource.
 XAResource (src) getXAResource()
          Returns an XAResource instance.
 boolean isSameRM(XAResource (src)  xar)
          Tells the caller if this resource has the same resource manager as the argument resource.
 int prepare(Xid (src)  xid)
          Prepare to commit the work done on this resource in the given transaction.
 Xid (src) [] recover(int param1)
          Return a list of transactions that are in a prepared or heuristically state.
 void removeConnectionEventListener(ConnectionEventListener (src)  cel)
          Removes a connection event listener
 void rollback(Xid (src)  xid)
          Roll back the work done on this resource in the given transaction.
 void setLogWriter(java.io.PrintWriter param1)
          Sets the logwriter for this instance.
 boolean setTransactionTimeout(int param1)
          Set the transaction timeout value for this resource.
 void start(Xid (src)  xid, int flags)
          Called to associate the resource with a transaction.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestManagedConnection

public TestManagedConnection(javax.security.auth.Subject subject,
                             TestConnectionRequestInfo (src)  cri,
                             int id)
Method Detail

destroy

public void destroy()
             throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Destroys the connection to the underlying resource.

Specified by:
destroy in interface ManagedConnection (src)
Throws:
ResourceException (src) -

cleanup

public void cleanup()
             throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Application server calls this to force cleanup of connection.

Specified by:
cleanup in interface ManagedConnection (src)
Throws:
ResourceException (src) -

getConnection

public java.lang.Object getConnection(javax.security.auth.Subject param1,
                                      ConnectionRequestInfo (src)  param2)
                               throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Creates a new connection handle for the underlying connection.

Specified by:
getConnection in interface ManagedConnection (src)
Parameters:
param1 -
param2 -
Returns:
Throws:
ResourceException (src) -

associateConnection

public void associateConnection(java.lang.Object p)
                         throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Associates a new application level connection handle with the connection.

Specified by:
associateConnection in interface ManagedConnection (src)
Parameters:
p - the connection
Throws:
ResourceException (src) -

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener (src)  cel)
Description copied from interface: ManagedConnection (src)
Adds a connection event listener

Specified by:
addConnectionEventListener in interface ManagedConnection (src)
Parameters:
cel - the listener

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener (src)  cel)
Description copied from interface: ManagedConnection (src)
Removes a connection event listener

Specified by:
removeConnectionEventListener in interface ManagedConnection (src)
Parameters:
cel - the listener

getXAResource

public XAResource (src)  getXAResource()
                         throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Returns an XAResource instance.

Specified by:
getXAResource in interface ManagedConnection (src)
Returns:
Throws:
ResourceException (src) -

getLocalTransaction

public LocalTransaction (src)  getLocalTransaction()
                                     throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Returns a LocalTransaction instance.

Specified by:
getLocalTransaction in interface ManagedConnection (src)
Returns:
Throws:
ResourceException (src) -

getMetaData

public ManagedConnectionMetaData (src)  getMetaData()
                                      throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Gets metadata inormation for this instances underlying resource manager instance.

Specified by:
getMetaData in interface ManagedConnection (src)
Returns:
Throws:
ResourceException (src) -

setLogWriter

public void setLogWriter(java.io.PrintWriter param1)
                  throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Sets the logwriter for this instance.

Specified by:
setLogWriter in interface ManagedConnection (src)
Parameters:
param1 -
Throws:
ResourceException (src) -

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws ResourceException (src) 
Description copied from interface: ManagedConnection (src)
Gets the logwriter for this instance.

Specified by:
getLogWriter in interface ManagedConnection (src)
Returns:
Throws:
ResourceException (src) -

start

public void start(Xid (src)  xid,
                  int flags)
           throws XAException (src) 
Description copied from interface: XAResource (src)
Called to associate the resource with a transaction. If the flags argument is XAResource.TMNOFLAGS, the transaction must not previously have been seen by this resource manager, or an XAException (src) with error code XAER_DUPID will be thrown. If the flags argument is XAResource.TMJOIN, the resource will join a transaction previously seen by tis resource manager. If the flags argument is XAResource.TMRESUME the resource will resume the transaction association that was suspended with end(TMSUSPEND).

Specified by:
start in interface XAResource (src)
Parameters:
xid - The id of the transaction to associate with.
flags - Must be either XAResource.TMNOFLAGS, XAResource.TMJOIN or XAResource.TMRESUME.
Throws:
XAException (src) -

end

public void end(Xid (src)  xid,
                int flags)
         throws XAException (src) 
Description copied from interface: XAResource (src)
Called to disassociate the resource from a transaction. If the flags argument is XAResource.TMSUCCESS, the portion of work was done sucessfully. If the flags argument is XAResource.TMFAIL, the portion of work failed. The resource manager may mark the transaction for rollback only to avoid the transaction being committed. If the flags argument is XAResource.TMSUSPEND the resource will temporarily suspend the transaction association. The transaction must later be re-associated by giving the XAResource.TMRESUME flag to the start method.

Specified by:
end in interface XAResource (src)
Parameters:
xid - The id of the transaction to disassociate from.
flags - Must be either XAResource.TMSUCCESS, XAResource.TMFAIL or XAResource.TMSUSPEND.
Throws:
XAException (src) -

commit

public void commit(Xid (src)  xid,
                   boolean onePhase)
            throws XAException (src) 
Description copied from interface: XAResource (src)
Commit the work done on this resource in the given transaction. If the onePhase argument is true, one-phase optimization is being used, and the prepare method must not have been called for this transaction. Otherwise, this is the second phase of the two-phase commit protocol.

Specified by:
commit in interface XAResource (src)
Parameters:
xid - The id of the transaction to commit work for.
onePhase - If true, the transaction manager is using one-phase optimization.
Throws:
XAException (src) -

rollback

public void rollback(Xid (src)  xid)
              throws XAException (src) 
Description copied from interface: XAResource (src)
Roll back the work done on this resource in the given transaction.

Specified by:
rollback in interface XAResource (src)
Parameters:
xid - The id of the transaction to commit work for.
Throws:
XAException (src) -

prepare

public int prepare(Xid (src)  xid)
            throws XAException (src) 
Description copied from interface: XAResource (src)
Prepare to commit the work done on this resource in the given transaction. This method cannot return a status indicating that the transaction should be rolled back. If the resource wants the transaction to be rolled back, it should throw an XAException at the caller.

Specified by:
prepare in interface XAResource (src)
Parameters:
xid - The id of the transaction to prepare to commit work for.
Returns:
Throws:
XAException (src) -

forget

public void forget(Xid (src)  xid)
            throws XAException (src) 
Description copied from interface: XAResource (src)
Tells the resource manager to forget about a heuristic decision.

Specified by:
forget in interface XAResource (src)
Parameters:
xid - The id of the transaction that was ended with a heuristic decision.
Throws:
XAException (src) -

recover

public Xid (src) [] recover(int param1)
              throws XAException (src) 
Description copied from interface: XAResource (src)
Return a list of transactions that are in a prepared or heuristically state. This method looks not only at the resource it is invoked on, but also on all other resources managed by the same resource manager. It is intended to be used by the application server when recovering after a server crash.

A recovery scan is done with one or more calls to this method. At the first call, XAResource.TMSTARTRSCAN must be in the flag argument to indicate that the scan should be started. During the recovery scan, the resource manager maintains an internal cursor that keeps track of the progress of the recovery scan. To end the recovery scan, the XAResource.TMENDRSCAN must be passed in the flag argument.

Specified by:
recover in interface XAResource (src)
Parameters:
param1 -
Returns:
Throws:
XAException (src) -

isSameRM

public boolean isSameRM(XAResource (src)  xar)
                 throws XAException (src) 
Description copied from interface: XAResource (src)
Tells the caller if this resource has the same resource manager as the argument resource. The transaction manager needs this method to be able to decide if the start method should be given the XAResource.TMJOIN flag.

Specified by:
isSameRM in interface XAResource (src)
Returns:
Throws:
XAException (src) -

getTransactionTimeout

public int getTransactionTimeout()
                          throws XAException (src) 
Description copied from interface: XAResource (src)
Get the current transaction timeout value for this resource.

Specified by:
getTransactionTimeout in interface XAResource (src)
Returns:
Throws:
XAException (src) -

setTransactionTimeout

public boolean setTransactionTimeout(int param1)
                              throws XAException (src) 
Description copied from interface: XAResource (src)
Set the transaction timeout value for this resource. If the seconds argument is 0, the timeout value is set to the default timeout value of the resource manager. Not all resource managers support setting the timeout value. If the resource manager does not support setting the timeout value, it should return false.

Specified by:
setTransactionTimeout in interface XAResource (src)
Parameters:
param1 -
Returns:
Throws:
XAException (src) -

toString

public java.lang.String toString()