Package org.jvnet.hk2.internal
Class ServiceHandleImpl<T>
java.lang.Object
org.jvnet.hk2.internal.ServiceHandleImpl<T>
- Type Parameters:
T- The type of service to create
- All Implemented Interfaces:
ServiceHandle<T>
This handle does the underlying work of getting the service. Only
at the time that the getService call is made is the service gotten
from the context. Once a service has been gotten, it is not looked
up again.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedList<Injectee> private final ServiceLocatorImplprivate final Objectprivate ActiveDescriptor<T> private Tprivate Objectprivate booleanprivate booleanprivate final LinkedList<ServiceHandleImpl<?>> -
Constructor Summary
ConstructorsConstructorDescriptionServiceHandleImpl(ServiceLocatorImpl locator, ActiveDescriptor<T> root, Injectee injectee) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSubHandle(ServiceHandleImpl<?> subHandle) Add a sub handle to this for proper destructionvoiddestroy()Will destroy this object and all PerLookup instances created because of this serviceReturns the ActiveDescriptor associated with this service handleprivate InjecteeGets the underlying service object(package private) TgetService(ServiceHandle<T> handle) Service 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 createdvoidvoidpushInjectee(Injectee push) voidsetServiceData(Object serviceData) Service data can be set on a service handle.toString()
-
Field Details
-
root
-
locator
-
injectees
-
lock
-
serviceDestroyed
private boolean serviceDestroyed -
serviceSet
private boolean serviceSet -
service
-
serviceData
-
subHandles
-
-
Constructor Details
-
ServiceHandleImpl
ServiceHandleImpl(ServiceLocatorImpl locator, ActiveDescriptor<T> root, Injectee injectee)
-
-
Method Details
-
getService
Description copied from interface:ServiceHandleGets the underlying service object- Specified by:
getServicein interfaceServiceHandle<T>- Returns:
- May return null (if the backing ActiveDescriptor returned null)
-
getLastInjectee
-
getService
-
getActiveDescriptor
Description copied from interface:ServiceHandleReturns the ActiveDescriptor associated with this service handle- Specified by:
getActiveDescriptorin interfaceServiceHandle<T>- 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
public boolean isActive()Description copied from interface:ServiceHandleThis returns true if the underlying service has already been created- Specified by:
isActivein interfaceServiceHandle<T>- Returns:
- true if the underlying service has been created
-
destroy
public void destroy()Description copied from interface:ServiceHandleWill destroy this object and all PerLookup instances created because of this service- Specified by:
destroyin interfaceServiceHandle<T>
-
setServiceData
Description copied from interface:ServiceHandleService 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- Specified by:
setServiceDatain interfaceServiceHandle<T>- Parameters:
serviceData- Sets the serviceData for the handle (may be null)
-
getServiceData
Description copied from interface:ServiceHandleService 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- Specified by:
getServiceDatain interfaceServiceHandle<T>- Returns:
- The service data for this service handle (may return null)
-
getSubHandles
Description copied from interface:ServiceHandleReturns a list of subordinate subhandles to this root handle- Specified by:
getSubHandlesin interfaceServiceHandle<T>- Returns:
- A non-null but possibly empty list of subhandles subordinate to this root
-
pushInjectee
-
popInjectee
public void popInjectee() -
addSubHandle
Add a sub handle to this for proper destruction- Parameters:
subHandle- A handle to add for proper destruction
-
getOriginalRequest
-
toString
-