Hi,

Let me move the discussion to jboss-dev.
The subject now seems to me more complicated and interesting than
before.
Fisrt I'll review what I came away with from the preceding discussion.
At the end I'll state my new idea ;-)

The Review:
Minerva XADataSource implementation has garbage collector for
Connections, which as for me solves the problem. But does it really
support 2-phase commit? If yes, I'll prefer to use it rather than
XADataSource implementations from database vendors.
Aaron said that the problem exists only if the latter is not
available. Why? Do XADataSource implementations from database
vendors has their own garbage collectors?
I don't think so.
Or, maybe they hide actual Connections, ResultSets, etc. and put
the actual Connections back to the pool after each method invocation?
Impossible: AFAIK, Rickard didn't work neither in Sybase, nor in
Oracle :-)
Thus, the problem remains, and it should be solved not in Minerva
XADataSource implementation, since is should work with
any XADataSource.
Moreover, I think it might serve for other bean resource managers,
though I cannot give good examples right now.
Whether it will be the garbage collector for bean resources, or the
bean resource wrapper/hider, it should sit somewhere in container
services (interceptor, right?) and handle the resources.

The New Idea:
Assume that a Connection instance was got in the bean method and
then was not closed due to error, i.e. it wasn't assigned to
an instance field. I would expect that in this case JVM Garbage
Collector would collect the Connection instance and call finalize()
that in turn would call close().
I am not sure, but it seems to me that it is not true, since
the errors of this kind really cause the exhaustion of Connections.
Maybe the reference to the Connection instance is kept somewhere else?
Can anybody explain me this?
Assume, that I am right and some reference remains.
Maybe, the problem would be solved if all such referenced was replaced
by WeakReferences (and HashMaps by WeakHashMaps).
Now assume that this is impossible, some strong reference is needed.
Then let's wrap the Connection with an individual proxy object for
each bean and in finalize() method of the proxy object call close()
for the underlying Connection.

Best regards,
 Oleg Nitz    



Reply via email to