@Singleton public class ManagedObjectsFinalizer extends Object
PreDestroymethods 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
PostConstructinvoked. Therefore methods annotated with
PreDestroyshould be invoked on such objects too, when they are destroyed. This service invokes
PreDestroyon 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|
Creates a new instance of
|Modifier and Type||Method and Description|
Register an object for invocation of its
public ManagedObjectsFinalizer(org.glassfish.jersey.internal.inject.InjectionManager injectionManager)
injectionManager- injection manager call
preDestroyon managed objects.
public void registerForPreDestroyCall(Object object)
PreDestroymethod. It will be invoked when the injection manager is shut down.
object- an object to be registered.
@PreDestroy public void preDestroy()
Copyright © 2007-2021, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.