class ServiceRegistrationImpl extends java.lang.Object implements ServiceRegistration
| Modifier and Type | Class and Description |
|---|---|
private class |
ServiceRegistrationImpl.ServiceFactoryPrivileged
This simple class is used to ensure that when a service factory
is called, that no other classes on the call stack interferes
with the permissions of the factory itself.
|
(package private) class |
ServiceRegistrationImpl.ServiceReferenceImpl |
private class |
ServiceRegistrationImpl.ServiceReferenceMap |
| Modifier and Type | Field and Description |
|---|---|
private Bundle |
m_bundle |
private java.lang.String[] |
m_classes |
private ServiceFactory |
m_factory |
private boolean |
m_isUnregistering |
private java.util.Map<java.lang.String,java.lang.Object> |
m_propMap |
private ServiceRegistrationImpl.ServiceReferenceImpl |
m_ref |
private ServiceRegistry |
m_registry |
private java.lang.Long |
m_serviceId |
private java.lang.Object |
m_svcObj |
private java.lang.ThreadLocal<java.lang.Boolean> |
m_threadLoopDetection |
private java.lang.Object |
syncObject |
| Constructor and Description |
|---|
ServiceRegistrationImpl(ServiceRegistry registry,
Bundle bundle,
java.lang.String[] classes,
java.lang.Long serviceId,
java.lang.Object svcObj,
java.util.Dictionary dict) |
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
currentThreadMarked() |
private java.lang.Object |
getFactoryUnchecked(Bundle bundle) |
(package private) java.lang.Object |
getProperty(java.lang.String key) |
private java.lang.String[] |
getPropertyKeys() |
ServiceReference |
getReference()
Returns a
ServiceReference object for a service being registered. |
(package private) java.lang.Object |
getService()
This method provides direct access to the associated service object;
it generally should not be used by anyone other than the service registry
itself.
|
(package private) java.lang.Object |
getService(Bundle acqBundle) |
private Bundle[] |
getUsingBundles() |
private void |
initializeProperties(java.util.Dictionary<java.lang.String,java.lang.Object> dict) |
protected void |
invalidate() |
private boolean |
isClassAccessible(java.lang.Class clazz)
This method determines if the class loader of the service object
has access to the specified class.
|
protected boolean |
isValid() |
(package private) void |
markCurrentThread() |
void |
setProperties(java.util.Dictionary dict)
Updates the properties associated with a service.
|
private void |
ungetFactoryUnchecked(Bundle bundle,
java.lang.Object svcObj) |
(package private) void |
ungetService(Bundle relBundle,
java.lang.Object svcObj) |
(package private) void |
unmarkCurrentThread() |
void |
unregister()
Unregisters a service.
|
private final ServiceRegistry m_registry
private final Bundle m_bundle
private final java.lang.String[] m_classes
private final java.lang.Long m_serviceId
private volatile java.lang.Object m_svcObj
private volatile ServiceFactory m_factory
private volatile java.util.Map<java.lang.String,java.lang.Object> m_propMap
private final ServiceRegistrationImpl.ServiceReferenceImpl m_ref
private volatile boolean m_isUnregistering
private final java.lang.ThreadLocal<java.lang.Boolean> m_threadLoopDetection
private final java.lang.Object syncObject
public ServiceRegistrationImpl(ServiceRegistry registry, Bundle bundle, java.lang.String[] classes, java.lang.Long serviceId, java.lang.Object svcObj, java.util.Dictionary dict)
protected boolean isValid()
protected void invalidate()
public ServiceReference getReference()
ServiceRegistrationServiceReference object for a service being registered.
The ServiceReference object may be shared with other bundles.
getReference in interface ServiceRegistrationServiceReference object.public void setProperties(java.util.Dictionary dict)
ServiceRegistration
The Constants.OBJECTCLASS, Constants.SERVICE_BUNDLEID,
Constants.SERVICE_ID and Constants.SERVICE_SCOPE keys
cannot be modified by this method. These values are set by the Framework
when the service is registered in the OSGi environment.
The following steps are required to modify service properties:
ServiceEvent.MODIFIED is fired.setProperties in interface ServiceRegistrationdict - The properties for this service. See Constants
for a list of standard service property keys. Changes should not
be made to this object after calling this method. To update the
service's properties this method should be called again.public void unregister()
ServiceRegistrationServiceRegistration object from
the Framework service registry. All ServiceReference objects
associated with this ServiceRegistration object can no longer be
used to interact with the service once unregistration is complete.
The following steps are required to unregister a service:
ServiceEvent.UNREGISTERING is fired
so that bundles using this service can release their use of the service.
Once delivery of the service event is complete, the
ServiceReference objects for the service may no longer be used to
get a service object for the service.ServiceFactory object,
the ServiceFactory.ungetService method is called to release the
service object for the bundle.unregister in interface ServiceRegistrationBundleContext.ungetService(ServiceReference),
ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)private boolean isClassAccessible(java.lang.Class clazz)
clazz - the class to test for reachability.java.lang.Object getProperty(java.lang.String key)
private java.lang.String[] getPropertyKeys()
private Bundle[] getUsingBundles()
java.lang.Object getService()
java.lang.Object getService(Bundle acqBundle)
void ungetService(Bundle relBundle, java.lang.Object svcObj)
private void initializeProperties(java.util.Dictionary<java.lang.String,java.lang.Object> dict)
private java.lang.Object getFactoryUnchecked(Bundle bundle)
private void ungetFactoryUnchecked(Bundle bundle, java.lang.Object svcObj)
boolean currentThreadMarked()
void markCurrentThread()
void unmarkCurrentThread()