org.osgi.framework.ServiceReference Maven / Gradle / Ivy
/*
* Copyright (c) OSGi Alliance (2000, 2017). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.osgi.framework;
import java.util.Dictionary;
import org.osgi.annotation.versioning.ProviderType;
/**
* A reference to a service.
*
*
* The Framework returns {@code ServiceReference} objects from the
* {@code BundleContext.getServiceReference} and
* {@code BundleContext.getServiceReferences} methods.
*
* A {@code ServiceReference} object may be shared between bundles and can be
* used to examine the properties of the service and to get the service object.
*
* Every service registered in the Framework has a unique
* {@code ServiceRegistration} object and may have multiple, distinct
* {@code ServiceReference} objects referring to it. {@code ServiceReference}
* objects associated with a {@code ServiceRegistration} object have the same
* {@code hashCode} and are considered equal (more specifically, their
* {@code equals()} method will return {@code true} when compared).
*
* If the same service object is registered multiple times,
* {@code ServiceReference} objects associated with different
* {@code ServiceRegistration} objects are not equal.
*
* @param Type of Service.
* @see BundleContext#getServiceReference(Class)
* @see BundleContext#getServiceReference(String)
* @see BundleContext#getServiceReferences(Class, String)
* @see BundleContext#getServiceReferences(String, String)
* @see BundleContext#getService(ServiceReference)
* @see BundleContext#getServiceObjects(ServiceReference)
* @ThreadSafe
* @author $Id: 1454244c30992b7a52ac3838b03bc584c3495816 $
*/
@ProviderType
public interface ServiceReference extends Comparable