@Singleton public class ManagedObjectsFinalizer extends Object
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.Constructor and Description |
---|
ManagedObjectsFinalizer(InjectionManager injectionManager)
Creates a new instance of
ManagedObjectsFinalizer . |
Modifier and Type | Method and Description |
---|---|
void |
preDestroy() |
void |
registerForPreDestroyCall(Object object)
Register an object for invocation of its
PreDestroy method. |
public ManagedObjectsFinalizer(InjectionManager injectionManager)
ManagedObjectsFinalizer
.injectionManager
- injection manager call preDestroy
on managed objects.public void registerForPreDestroyCall(Object object)
PreDestroy
method.
It will be invoked when the injection manager is shut down.object
- an object to be registered.@PreDestroy public void preDestroy()
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.