Package org.apache.felix.framework
Class ServiceRegistrationImpl<S>
java.lang.Object
org.apache.felix.framework.ServiceRegistrationImpl<S>
- All Implemented Interfaces:
ServiceRegistration<S>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Bundleprivate final String[]private ServiceFactory<S> private booleanprivate final ServiceRegistrationImpl<S>.ServiceReferenceImpl<S> private final ServiceRegistryprivate final Longprivate Objectprivate final ThreadLocal<Boolean> private final Object -
Constructor Summary
ConstructorsConstructorDescriptionServiceRegistrationImpl(ServiceRegistry registry, Bundle bundle, String[] classes, Long serviceId, Object svcObj, Dictionary<String, Object> dict) -
Method Summary
Modifier and TypeMethodDescription(package private) booleanprivate SgetFactoryUnchecked(Bundle bundle) (package private) ObjectgetProperty(String key) private String[]Returns aServiceReferenceobject for a service being registered.(package private) ObjectThis 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) ObjectgetService(Bundle acqBundle) private Bundle[]private voidinitializeProperties(Dictionary<String, ?> dict) protected voidprivate booleanisClassAccessible(Class<?> clazz) This method determines if the class loader of the service object has access to the specified class.protected booleanisValid()(package private) voidvoidsetProperties(Dictionary<String, ?> dict) Updates the properties associated with a service.private voidungetFactoryUnchecked(Bundle bundle, S svcObj) (package private) voidungetService(Bundle relBundle, S svcObj) (package private) voidvoidUnregisters a service.
-
Field Details
-
m_registry
-
m_bundle
-
m_classes
-
m_serviceId
-
m_svcObj
-
m_factory
-
m_propMap
-
m_ref
-
m_isUnregistering
private volatile boolean m_isUnregistering -
m_threadLoopDetection
-
syncObject
-
-
Constructor Details
-
ServiceRegistrationImpl
public ServiceRegistrationImpl(ServiceRegistry registry, Bundle bundle, String[] classes, Long serviceId, Object svcObj, Dictionary<String, Object> dict)
-
-
Method Details
-
isValid
protected boolean isValid() -
invalidate
protected void invalidate() -
getReference
Description copied from interface:ServiceRegistrationReturns aServiceReferenceobject for a service being registered.The
ServiceReferenceobject may be shared with other bundles.- Specified by:
getReferencein interfaceServiceRegistration<S>- Returns:
ServiceReferenceobject.
-
setProperties
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<S>- 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<S>- See Also:
-
isClassAccessible
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
-
getPropertyKeys
-
getUsingBundles
-
getService
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
-
ungetService
-
initializeProperties
-
getFactoryUnchecked
-
ungetFactoryUnchecked
-
currentThreadMarked
boolean currentThreadMarked() -
markCurrentThread
void markCurrentThread() -
unmarkCurrentThread
void unmarkCurrentThread()
-