Subject XAResource implementation
Author mapofe
Hello,
tha JTA specs (3.4.6 Resource Sharing) include a paragraph which
states that a resource object can be shared by different transactions
under some circumnstances, and that the object used for the two-pase
commit protocol need not have been involved with the transaction being
completed.
AFAIK the resource object corresponds to the XAResource, and the
current FB implementation would not allow this sharing (tha my
application would like to use :) ), since the XAResource
implementation (org.firebirdsql.jca.FBManagedConnection) binds itself
to the first transaction (in the start(xid, flag) method) and tries to
use the bound transaction in all the other subsequent method calls
(end/prepare/commit/rollback).
The scenario presented in the JTA specs would then not be possible:

// Suppose we have some transactional connection-based
// resource r1 that is connected to an enterprise information
// service system.
//
XAResource xares = r1.getXAResource();
xares.start(xid1); // associate xid1 to the connection
..
xares.end(xid1); // dissociate xid1 to the connection
..
xares.start(xid2); // associate xid2 to the connection
..
// While the connection is associated with xid2,
// the TM starts the commit process for xid1
// --> Here JayBird would fail???
status = xares.prepare(xid1);
..
xares.commit(xid1, false);

Regards
Massimo