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