|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl
public class ServiceRegistrationImpl
A registered service.
The framework returns a ServiceRegistration object when a
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.
Field Summary | |
---|---|
protected AbstractBundle |
bundle
bundle which registered this service. |
protected java.lang.String[] |
clazzes
service classes for this registration. |
protected BundleContextImpl |
context
context which registered this service. |
protected java.util.ArrayList |
contextsUsing
list of contexts using the service. |
protected Framework |
framework
Internal framework object. |
protected org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl.Properties |
properties
properties for this registration. |
protected ServiceReferenceImpl |
reference
Reference to this registration. |
static int |
REGISTERED
|
protected java.lang.Object |
registrationLock
|
protected java.lang.Object |
service
service object for this registration. |
protected long |
serviceid
service id. |
protected int |
serviceranking
service ranking. |
protected int |
state
The registration state |
static int |
UNREGISTERED
|
static int |
UNREGISTERING
|
Constructor Summary | |
---|---|
protected |
ServiceRegistrationImpl(BundleContextImpl context,
java.lang.String[] clazzes,
java.lang.Object service,
java.util.Dictionary properties)
Construct a ServiceRegistration and register the service in the framework's service registry. |
Method Summary | |
---|---|
protected org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl.Properties |
createProperties(java.util.Dictionary props)
Construct a properties object from the dictionary for this ServiceRegistration. |
protected AbstractBundle |
getBundle()
Return the bundle which registered the service. |
protected java.lang.Object |
getProperty(java.lang.String key)
Get the value of a service's property. |
protected java.lang.String[] |
getPropertyKeys()
Get the list of key names for the service's properties. |
ServiceReference |
getReference()
Returns a ServiceReferenceImpl object for this registration. |
protected java.lang.Object |
getService(BundleContextImpl user)
Get a service object for the using BundleContext. |
protected AbstractBundle[] |
getUsingBundles()
Return the list of bundle which are using this service. |
protected void |
releaseService(BundleContextImpl user)
Release the service for the using BundleContext. |
void |
setProperties(java.util.Dictionary props)
Update the properties associated with this service. |
java.lang.String |
toString()
Return a String representation of this object. |
protected boolean |
ungetService(BundleContextImpl user)
Unget a service for the using BundleContext. |
void |
unregister()
Unregister the service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ServiceReferenceImpl reference
protected Framework framework
protected BundleContextImpl context
protected AbstractBundle bundle
protected java.util.ArrayList contextsUsing
protected java.lang.String[] clazzes
protected java.lang.Object service
protected org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl.Properties properties
protected long serviceid
protected int serviceranking
protected java.lang.Object registrationLock
protected int state
public static final int REGISTERED
public static final int UNREGISTERING
public static final int UNREGISTERED
Constructor Detail |
---|
protected ServiceRegistrationImpl(BundleContextImpl context, java.lang.String[] clazzes, java.lang.Object service, java.util.Dictionary properties)
Method Detail |
---|
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
java.lang.IllegalStateException
- If
this ServiceRegistration has already been unregistered.BundleContextImpl.ungetService(org.osgi.framework.ServiceReference)
public ServiceReference getReference()
ServiceReferenceImpl
object for this registration.
The ServiceReferenceImpl
object may be shared with other bundles.
getReference
in interface ServiceRegistration
ServiceReferenceImpl
object.
java.lang.IllegalStateException
- If
this ServiceRegistration has already been unregistered.public void setProperties(java.util.Dictionary 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
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.
java.lang.IllegalStateException
- If
this ServiceRegistration has already been unregistered.
java.lang.IllegalArgumentException
- If the properties
parameter contains case variants of the same key name.protected org.eclipse.osgi.framework.internal.core.ServiceRegistrationImpl.Properties createProperties(java.util.Dictionary props)
props
- The properties for this service.
protected java.lang.Object getProperty(java.lang.String key)
This method will continue to return property values after the service has been unregistered. This is so that references to unregistered service can be interrogated. (For example: ServiceReference objects stored in the log.)
key
- Name of the property.
null
if there is
no property by that name.protected java.lang.String[] getPropertyKeys()
This method will continue to return the keys after the service has been unregistered. This is so that references to unregistered service can be interrogated. (For example: ServiceReference objects stored in the log.)
protected AbstractBundle getBundle()
This method will always return null
when the
service has been unregistered. This can be used to
determine if the service has been unregistered.
protected java.lang.Object getService(BundleContextImpl user)
user
- BundleContext using service.
protected boolean ungetService(BundleContextImpl user)
user
- BundleContext using service.
false
if the context bundle's use count for the service
is zero or if the service has been unregistered,
otherwise true
.protected void releaseService(BundleContextImpl user)
user
- BundleContext using service.protected AbstractBundle[] getUsingBundles()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |