Package org.apache.felix.framework
Class ServiceRegistrationImpl
- java.lang.Object
-
- org.apache.felix.framework.ServiceRegistrationImpl
-
- All Implemented Interfaces:
ServiceRegistration
class ServiceRegistrationImpl extends java.lang.Object implements ServiceRegistration
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classServiceRegistrationImpl.ServiceFactoryPrivilegedThis 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) classServiceRegistrationImpl.ServiceReferenceImplprivate classServiceRegistrationImpl.ServiceReferenceMap
-
Field Summary
Fields Modifier and Type Field Description private Bundlem_bundleprivate java.lang.String[]m_classesprivate ServiceFactorym_factoryprivate booleanm_isUnregisteringprivate java.util.Map<java.lang.String,java.lang.Object>m_propMapprivate ServiceRegistrationImpl.ServiceReferenceImplm_refprivate ServiceRegistrym_registryprivate java.lang.Longm_serviceIdprivate java.lang.Objectm_svcObj
-
Constructor Summary
Constructors Constructor Description ServiceRegistrationImpl(ServiceRegistry registry, Bundle bundle, java.lang.String[] classes, java.lang.Long serviceId, java.lang.Object svcObj, java.util.Dictionary dict)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.ObjectgetFactoryUnchecked(Bundle bundle)(package private) java.lang.ObjectgetProperty(java.lang.String key)private java.lang.String[]getPropertyKeys()ServiceReferencegetReference()Returns aServiceReferenceobject for a service being registered.(package private) java.lang.ObjectgetService()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.ObjectgetService(Bundle acqBundle)private Bundle[]getUsingBundles()private voidinitializeProperties(java.util.Dictionary<java.lang.String,java.lang.Object> dict)protected voidinvalidate()private booleanisClassAccessible(java.lang.Class clazz)This method determines if the class loader of the service object has access to the specified class.protected booleanisValid()voidsetProperties(java.util.Dictionary dict)Updates the properties associated with a service.private voidungetFactoryUnchecked(Bundle bundle, java.lang.Object svcObj)(package private) voidungetService(Bundle relBundle, java.lang.Object svcObj)voidunregister()Unregisters a service.
-
-
-
Field Detail
-
m_registry
private final ServiceRegistry m_registry
-
m_bundle
private final Bundle m_bundle
-
m_classes
private final java.lang.String[] m_classes
-
m_serviceId
private final java.lang.Long m_serviceId
-
m_svcObj
private volatile java.lang.Object m_svcObj
-
m_factory
private volatile ServiceFactory m_factory
-
m_propMap
private volatile java.util.Map<java.lang.String,java.lang.Object> m_propMap
-
m_ref
private final ServiceRegistrationImpl.ServiceReferenceImpl m_ref
-
m_isUnregistering
private volatile boolean m_isUnregistering
-
-
Constructor Detail
-
ServiceRegistrationImpl
public ServiceRegistrationImpl(ServiceRegistry registry, Bundle bundle, java.lang.String[] classes, java.lang.Long serviceId, java.lang.Object svcObj, java.util.Dictionary dict)
-
-
Method Detail
-
isValid
protected boolean isValid()
-
invalidate
protected void invalidate()
-
getReference
public ServiceReference getReference()
Description copied from interface:ServiceRegistrationReturns aServiceReferenceobject for a service being registered.The
ServiceReferenceobject may be shared with other bundles.- Specified by:
getReferencein interfaceServiceRegistration- Returns:
ServiceReferenceobject.
-
setProperties
public void setProperties(java.util.Dictionary dict)
Description copied from interface:ServiceRegistrationUpdates the properties associated with a service.The
Constants.OBJECTCLASS,Constants.SERVICE_BUNDLEID,Constants.SERVICE_IDandConstants.SERVICE_SCOPEkeys 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:
- The service's properties are replaced with the provided properties.
- A service event of type
ServiceEvent.MODIFIEDis fired.
- Specified by:
setPropertiesin interfaceServiceRegistration- Parameters:
dict- The properties for this service. SeeConstantsfor 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.
-
unregister
public void unregister()
Description copied from interface:ServiceRegistrationUnregisters a service. Remove aServiceRegistrationobject from the Framework service registry. AllServiceReferenceobjects associated with thisServiceRegistrationobject can no longer be used to interact with the service once unregistration is complete.The following steps are required to unregister a service:
- The service is removed from the Framework service registry so that it can no longer be obtained.
- A service event of type
ServiceEvent.UNREGISTERINGis fired so that bundles using this service can release their use of the service. Once delivery of the service event is complete, theServiceReferenceobjects for the service may no longer be used to get a service object for the service. - For each bundle whose use count for this service is greater than
zero:
- The bundle's use count for this service is set to zero.
- If the service was registered with a
ServiceFactoryobject, theServiceFactory.ungetServicemethod is called to release the service object for the bundle.
- Specified by:
unregisterin interfaceServiceRegistration- See Also:
BundleContext.ungetService(ServiceReference),ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)
-
isClassAccessible
private boolean isClassAccessible(java.lang.Class clazz)
This method determines if the class loader of the service object has access to the specified class.- Parameters:
clazz- the class to test for reachability.- Returns:
- true if the specified class is reachable from the service object's class loader, false otherwise.
-
getProperty
java.lang.Object getProperty(java.lang.String key)
-
getPropertyKeys
private java.lang.String[] getPropertyKeys()
-
getUsingBundles
private Bundle[] getUsingBundles()
-
getService
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.- Returns:
- The service object associated with the registration.
-
getService
java.lang.Object getService(Bundle acqBundle)
-
ungetService
void ungetService(Bundle relBundle, java.lang.Object svcObj)
-
initializeProperties
private void initializeProperties(java.util.Dictionary<java.lang.String,java.lang.Object> dict)
-
getFactoryUnchecked
private java.lang.Object getFactoryUnchecked(Bundle bundle)
-
ungetFactoryUnchecked
private void ungetFactoryUnchecked(Bundle bundle, java.lang.Object svcObj)
-
-