aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JCA-Resource Adapter: ManagedConnection holds several connections? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JCA-Resource Adapter: ManagedConnection holds several connections?" Watch "JCA-Resource Adapter: ManagedConnection holds several connections?" New topic
Author

JCA-Resource Adapter: ManagedConnection holds several connections?

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311
Hi,

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()).

Addison Wesley's "J2EE Connector Architecture" says:

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).

Thanks
sam sepassi
Greenhorn

Joined: Sep 23, 2012
Posts: 7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JCA-Resource Adapter: ManagedConnection holds several connections?