Interface ServiceHandle<T>

  • Type Parameters:
    T - The type of the service that can be returned
    All Known Implementing Classes:
    ServiceHandleImpl

    public interface ServiceHandle<T>
    This service handle can be used to get a specific instance of a service, and can be used to destroy that service as well
    • Method Detail

      • 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 service
        java.lang.IllegalStateException - 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

        void destroy()
        Will destroy this object and all PerLookup instances created because of this service
      • setServiceData

        void setServiceData​(java.lang.Object serviceData)
        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

        java.lang.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

        java.util.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