public class ServiceRegistrationImpl<S> extends Object implements ServiceRegistration<S>, Comparable<ServiceRegistrationImpl<?>>
BundleContext.registerService
method is successful. This object is for the private use of
the registering bundle and should not be shared with other bundles.
The ServiceRegistration object may be used to update the properties for the service or to unregister the service.
If the ServiceRegistration is garbage collected the framework may remove the service. This implies that if a bundle wants to keep its service registered, it should keep the ServiceRegistration object referenced.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ServiceRegistrationImpl<?> other)
Compares this
ServiceRegistrationImpl with the specified
ServiceRegistrationImpl for order. |
org.eclipse.osgi.internal.serviceregistry.ServiceProperties |
getProperties()
Return the properties object.
|
ServiceReference<S> |
getReference()
Returns a
ServiceReferenceImpl object for this registration. |
Bundle |
getRegisteringBundle()
This method returns the bundle which registered the
service regardless of the registration status of this
service registration.
|
void |
setProperties(Dictionary<String,?> props)
Update the properties associated with this service.
|
String |
toString()
Return a String representation of this object.
|
void |
unregister()
Unregister the service.
|
public void setProperties(Dictionary<String,?> props)
The key "objectClass" cannot be modified by this method. It's value is set when the service is registered.
The following steps are followed to modify a service's properties:
ServiceEvent
of type ServiceEvent.MODIFIED
is synchronously sent.
setProperties
in interface ServiceRegistration<S>
props
- The properties for this service.
Changes should not be made to this object after calling this method.
To update the service's properties this method should be called again.IllegalStateException
- If
this ServiceRegistration has already been unregistered.IllegalArgumentException
- If the properties
parameter contains case variants of the same key name.public void unregister()
ServiceReferenceImpl
objects for this registration
can no longer be used to interact with the service.
The following steps are followed to unregister a service:
ServiceReferenceImpl
s for the service may no longer be used
to get a service object for the service.
ServiceEvent
of type ServiceEvent.UNREGISTERING
is synchronously sent so that bundles using this service
may release their use of the service.
ServiceFactory
,
the ServiceFactory.ungetService
method
is called to release the service object for the bundle.
unregister
in interface ServiceRegistration<S>
IllegalStateException
- If
this ServiceRegistration has already been unregistered.BundleContextImpl.ungetService(org.osgi.framework.ServiceReference<?>)
public ServiceReference<S> getReference()
ServiceReferenceImpl
object for this registration.
The ServiceReferenceImpl
object may be shared with other bundles.getReference
in interface ServiceRegistration<S>
ServiceReferenceImpl
object.IllegalStateException
- If
this ServiceRegistration has already been unregistered.public org.eclipse.osgi.internal.serviceregistry.ServiceProperties getProperties()
public Bundle getRegisteringBundle()
public String toString()
public int compareTo(ServiceRegistrationImpl<?> other)
ServiceRegistrationImpl
with the specified
ServiceRegistrationImpl
for order.
This does a reverse comparison so that the highest item is sorted to the left. We keep ServiceRegistationImpls in sorted lists such that the highest ranked service is at element 0 for quick retrieval.
compareTo
in interface Comparable<ServiceRegistrationImpl<?>>
other
- The ServiceRegistrationImpl
to be compared.ServiceRegistrationImpl
is greater than, equal to, or
less than the specified ServiceRegistrationImpl
.Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.