JCA-Resource Adapter: ManagedConnection holds several connections?
posted 10 years ago
I'm trying to write a Resource Adapter (Connector), and would appreciate hints on the relation between ManagedConnection and the underlying "Connection handle" (namely, the one returned by ManagedConnection.getConnection()).
It is possible to have multiple connection handles associated with the same ManagedConnection. An application server might call getConnection multiple times to enable sharing of a ManagedConnection across multiple connection handles. As a result, it is important that no states are kept in the connection handles. They should be treated as a stateless pipe, or pointer, to the ManagedConnection
Does that mean the same ManagedConnection should store multiple Connection "handles" at the *same time* ? Something like:
If so, what's the motivation? I mean, I understand the container (and its ConnectionManager) use ManagedConnections to handle pooling, transactions, and getting ConnectionEvents. But for this, isn't it enought for each ManagedConnection to hold a single connection handle ? (I realize container's behaviour is vendor-specific, but I'm looking for some reasonable scenario, or example, where it would make some sense).
posted 3 years ago
Yes it mostly uses a data structure such as SET to hold the connection handles. The connection handles are added and removed from the set all time.
If you review the specification the managed connection class implements the clear() method that is used to clear connection specific information (connection set).
P.S. J2EE samples from Oracle contains a sample resource adapter implementation which is very helpful indeed.