users@jersey.java.net

[Jersey] Re: Proper shutdown / destroy when using com.sun.jersey.spi.container.servlet.ServletContainer

From: Matthew Hall <mhall_at_mhcomputing.net>
Date: Mon, 29 Apr 2013 14:38:28 -0700

Hi Joe,

Upon careful review of the thread it seems they're saying @PreDestroy only
works on a per-request basis, so it's close but not a full cigar.

I need something that gets called when the entire servlet is destoyed and
reloaded, such as in a hot code replace type of situation.

Does anyone know how this could be done? There was a sentence saying, "In the
above I presuming that the injection of PersistenceManager instances are
pre-request. Is that correct? If not then it will be necessary to override the
ServletContainer and the destroy method to clean up singleton-based
instances."

Is this still the only way to do it, or is there a new way now which is able
to do so that's been created since 2009?

Thanks,
Matthew.

On Fri, Apr 12, 2013 at 01:27:11AM +0000, Joseph Mocker wrote:
> This is an old thread but appears to cover the topic
>
> http://jersey.576304.n2.nabble.com/Destroying-injected-context-at-the-end-of-resource-lifecycle-td2280004.html
>
> --joe