On Sat, Apr 21, 2012 at 12:17 PM, Neil Bartlett <njbartlett_at_gmail.com> wrote:
> I am using an InjectableProvider to implement my own injection into fields
> annotated with @javax.inject.Inject. So far this works fine.
>
> However I additionally need to perform some clean-up of the injected value
> after the resource has finished using it. Since the injection is happening
> in the PerRequest scope, it seems I should be able to hook into the
> destruction of the resource instance after the HTTP processing has
> completed. Unfortunately I have not yet been able to work out how to do
> this. Could somebody please provide some pointers?
>
I don't know what's the proper way to do this. Some things that come
to mind (and possibly inaccurate info): take a look at Closeable /
CloseableService. Delegate construction to a DI provider somehow ...
(CDI / Spring, Guice did not support @PreDestroy AFAIR, Jersey
supports life-cycle callbacks, but I think only for resources and
providers which are managed by jersey itself).
regards,
George