- Type Parameters:
T- The type of the service that can be returned
- All Superinterfaces:
AutoCloseable,Closeable
This service handle can be used to get a specific instance
of a service, and can be used to destroy that service as well
- Author:
- jwells
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Will destroy this object and all PerLookup instances created because of this servicedefault voiddestroy()Deprecated.since 2.6.Returns the ActiveDescriptor associated with this service handleGets the underlying service objectService data can be set on a service handle.List<ServiceHandle<?>>Returns a list of subordinate subhandles to this root handlebooleanisActive()This returns true if the underlying service has already been createdvoidsetServiceData(Object serviceData) Service data can be set on a service handle.
-
Method Details
-
getService
T getService()Gets the underlying service object- Returns:
- May return null (if the backing ActiveDescriptor returned null)
- Throws:
MultiException- if there was an error creating the serviceIllegalStateException- if the handle was previously destroyed
-
getActiveDescriptor
ActiveDescriptor<T> getActiveDescriptor()Returns the ActiveDescriptor associated with this service handle- Returns:
- The ActiveDescriptor associated with this handle. Can return null in cases where the Handle describes a service not associated with an hk2 service, such as a constant service
-
isActive
boolean isActive()This returns true if the underlying service has already been created- Returns:
- true if the underlying service has been created
-
destroy
Deprecated.since 2.6. Useclose()insteadWill destroy this object and all PerLookup instances created because of this service -
close
default void close()Will destroy this object and all PerLookup instances created because of this service- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
setServiceData
Service data can be set on a service handle. If the service data is set prior to the services associated Context has created an instance then this service data can be used to influence the context's creation of the service. The service data is associated with a handle, not with the service itself- Parameters:
serviceData- Sets the serviceData for the handle (may be null)
-
getServiceData
Object getServiceData()Service data can be set on a service handle. If the service data is set prior to the services associated Context has created an instance then this service data can be used to influence the context's creation of the service. The service data is associated with a handle, not with the service itself- Returns:
- The service data for this service handle (may return null)
-
getSubHandles
List<ServiceHandle<?>> getSubHandles()Returns a list of subordinate subhandles to this root handle- Returns:
- A non-null but possibly empty list of subhandles subordinate to this root
-