Class ManagedObjectsFinalizer
java.lang.Object
org.glassfish.jersey.model.internal.ManagedObjectsFinalizer
Invokes
PreDestroy
methods on all registered objects, when the injection manager is shut down.
Some objects managed by Jersey are created using InjectionManager.createAndInitialize(java.lang.Class<T>)
. This means
that such objects are created, dependencies injected and methods annotated with PostConstruct
invoked. Therefore methods annotated with PreDestroy
should be invoked on such objects too, when they are destroyed.
This service invokes PreDestroy
on all registered objects when InjectionManager.shutdown()
is invoked
on the injection manager where this service is registered. Therefore only classes with their lifecycle linked
to the injection manager that created them should be registered here.- Author:
- Petr Janouch
-
Constructor Summary
ConstructorDescriptionManagedObjectsFinalizer
(InjectionManager injectionManager) Creates a new instance ofManagedObjectsFinalizer
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
registerForPreDestroyCall
(Object object) Register an object for invocation of itsPreDestroy
method.
-
Constructor Details
-
ManagedObjectsFinalizer
Creates a new instance ofManagedObjectsFinalizer
.- Parameters:
injectionManager
- injection manager callpreDestroy
on managed objects.
-
-
Method Details
-
registerForPreDestroyCall
Register an object for invocation of itsPreDestroy
method. It will be invoked when the injection manager is shut down.- Parameters:
object
- an object to be registered.
-
preDestroy
@PreDestroy public void preDestroy()
-