You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Tom Muldoon <to...@firstbest.com> on 2007/04/05 13:42:31 UTC
Re: pool - cleaning up resources on JVM exit
Try adding a shutdown hook. e.g.
new ShutdownHook().register();
/**
* Provides a shutdown hook for shutting down the pool.
*/
private class ShutdownHook extends Thread {
/**
* Registers this hook for invocation during shutdown.
*/
public void register() {
Runtime.getRuntime().addShutdownHook(this);
}
/**
* Closes the pool and each of the objects within it.
*/
public void run() {
try {
// Do something.
}
catch (Exception e) {
throw new SystemException(e);
}
}
}
Conrad CRAMPTON PSE 52704 wrote:
> Hi,
> Is there anyway of clearing up resources from a GenericObjectPool when
> the JMV closes (crashes)? I have objects that maintain a connection to a
> service that need to be closed when the web server is restarted or
> crashes.
> Also, if an object is borrowed from the pool and isn't returned because
> of interruption in the web application flow or some other reason, does
> it get 'swept up' by the evictor thread eventually or is there some
> other way of returning this to the pool or simply just destroying it for
> it to be recreated in the pool when necessary?
>
> Thanks for your consideration
> Conrad
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org