Package org.glassfish.hk2.api
Annotation Type Immediate
-
@Documented @Retention(RUNTIME) @Scope @Target({TYPE,METHOD}) public @interface Immediate
Immediate is a scope that operates likeSingleton
scope, except that instances are created as soon as their correspondingDescriptor
s are added. When the correspondingDescriptor
is removed from the locator the Immediate scope service is destroyed. In particular Immediate scope services are not destroyed if theServiceHandle.destroy()
method is called. Care should be taken with the services injected into an immediate service, as they also become virtual immediate servicesThe Immediate scope is not automatically handled by a new ServiceLocator. In order to enable the Immediate scope the user can either add an implementation of
Context
which handles it or it can use theServiceLocatorUtilities.enableImmediateScope(ServiceLocator)
method.- Author:
- jwells