billhorsman wrote:
But I'm intrigued by your problem of sharing a single instance of Proxool. This is possible if the class loader and your environment allows it. In a web container this could occur if the Proxool library is in a system classpath (as opposed to within WEB-INF/lib). The problem with your proposed solution is that it's not thread safe. Granted, it would be very unlikely for another component to register a pool during this code snippet but it is possible.
Currently, the ProxoolConnectionProvider can be configured so it borrows a Proxool pool configured from the outside. In this case, the Hibernate shutdown shouldn't do anything with the pool - leave it asis.
The second mode is where the ProxoolConnectionProvider is responsible to configure the Proxool pool itself - the pool will not be shared. In this case, the pool should be destroyed when Hibernate is shutted down.
Considering these two cases, I don't think we have any race conditions and the solution I made above should be ok (including ProxoolFacade.shutdown()).
billhorsman wrote:
I propose a change to Proxool such that if you remove a connection pool then it automatically checks for any remaining pools (in a thread safe manner). If there are none then it shuts itself down. Note that there is nothing to stop Proxool restarting itself when a fresh pool is registered.
Not sure it is needed - cfr. above.
billhorsman wrote:
In the meantime, I recommend calling shutdown(0) and to make your life simpler by not sharing an instance of Proxool.
Hibernate knows when the pool is shared. In this case nothing would be made on shutdown (cfr. above).