Top Description Methods
org.glassfish.hk2.api

public @Interface Immediate

extends Annotation
Known Direct Implementers
org.glassfish.hk2.utilities.ServiceLocatorUtilities.ImmediateImpl
Annotations
@Documented
@Retention:RUNTIME
@Scope
@Target:TYPE, METHOD
Static Imports
java.lang.annotation.ElementType.METHOD, .ElementType.TYPE, .RetentionPolicy.RUNTIME

Immediate is a scope that operates like jakarta.inject.Singleton scope, except that instances are created as soon as their corresponding Descriptors are added. When the corresponding Descriptor is removed from the locator the Immediate scope service is destroyed. In particular Immediate scope services are not destroyed if the ServiceHandle#destroy() method is called. Care should be taken with the services injected into an immediate service, as they also become virtual immediate services

The 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 the org.glassfish.hk2.utilities.ServiceLocatorUtilities#enableImmediateScope(ServiceLocator) method.

Author
jwells

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString