Releases the service object referenced by the specified {@code ServiceReference} object. If the context module's use count forthe service is zero, this method returns {@code false}. Otherwise, the context module's use count for the service is decremented by one.
The service's service object should no longer be used and all references to it should be destroyed when a module's use count for the service drops to zero.
The following steps are required to unget the service object:
- If the context module's use count for the service is zero or the service has been unregistered, {@code false} is returned.
- The context module's use count for this service is decremented by one.
- If the context module's use count for the service is currently zero and the service was registered with a {@code ServiceFactory} object, the{@link ServiceFactory#ungetService(Module,ServiceRegistration,Object)}method is called to release the service object for the context module.
- {@code true} is returned.
@param reference A reference to the service to be released.
@return {@code false} if the context module's use count for the serviceis zero or if the service has been unregistered; {@code true}otherwise.
@throws IllegalStateException If this ModuleContext is no longer valid.
@throws IllegalArgumentException If the specified{@code ServiceReference} was not created by the same frameworkinstance as this {@code ModuleContext}.
@see #getService(ServiceReference)
@see ServiceFactory