Package org.apache.felix.framework
Class ServiceRegistry
java.lang.Object
org.apache.felix.framework.ServiceRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<Class<?>, Set<ServiceReference<?>>> private final WeakHashMap
<ServiceReference<?>, ServiceReference<?>> private final ServiceRegistry.ServiceRegistryCallbacks
private long
private static final Class<?>[]
private final Map
<Bundle, ServiceRegistry.UsageCount[]> private final Map
<ServiceRegistration<?>, Object> private final Logger
private final CapabilitySet
private final Map
<Bundle, ServiceRegistration<?>[]> -
Constructor Summary
ConstructorsConstructorDescriptionServiceRegistry
(Logger logger, ServiceRegistry.ServiceRegistryCallbacks callbacks) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addHooks
(String[] classNames, Object svcObj, ServiceReference<?> ref) private static ServiceRegistration<?>[]
addServiceRegistration
(ServiceRegistration<?>[] regs, ServiceRegistration<?> reg) private ServiceRegistry.UsageCount
addUsageCount
(Bundle bundle, ServiceReference<?> ref, boolean isPrototype) Utility method to update the specified bundle's usage count array to include the specified service.private static <S> SortedSet
<ServiceReference<S>> (package private) void
blackListHook
(ServiceReference<?> sr) private void
flushUsageCount
(Bundle bundle, ServiceReference<?> ref, ServiceRegistry.UsageCount uc) Utility method to flush the specified bundle's usage count for the specified service reference.<S> Set
<ServiceReference<S>> ServiceReference<?>[]
getRegisteredServices
(Bundle bundle) <S> S
getService
(Bundle bundle, ServiceReference<S> ref, boolean isPrototype) getServiceReferences
(String className, SimpleFilter filter) ServiceReference<?>[]
getServicesInUse
(Bundle bundle) private ServiceRegistry.UsageCount
getUsageCount
(Bundle bundle, ServiceReference<?> ref, Object svcObj) Utility method to retrieve the specified bundle's usage count for the specified service reference.Bundle[]
getUsingBundles
(ServiceReference<?> ref) (package private) static boolean
(package private) boolean
registerService
(BundleContext context, String[] classNames, Object svcObj, Dictionary dict) private void
removeHook
(ServiceReference<?> ref) private static ServiceRegistration<?>[]
removeServiceRegistration
(ServiceRegistration<?>[] regs, ServiceRegistration<?> reg) (package private) void
servicePropertiesModified
(ServiceRegistration<?> reg, Dictionary oldProps) boolean
ungetService
(Bundle bundle, ServiceReference<?> ref, Object svcObj) void
ungetServices
(Bundle bundle) This is a utility method to release all services being used by the specified bundle.void
unregisterService
(Bundle bundle, ServiceRegistration<?> reg) void
unregisterServices
(Bundle bundle) This method retrieves all services registrations for the specified bundle and invokes ServiceRegistration.unregister() on each one.private void
updateHook
(ServiceReference<?> ref)
-
Field Details
-
m_logger
-
m_currentServiceId
private long m_currentServiceId -
m_regsMap
-
m_regCapSet
-
m_lockedRegsMap
-
m_inUseMap
-
m_callbacks
-
m_blackList
-
m_hookClasses
-
m_allHooks
-
-
Constructor Details
-
ServiceRegistry
-
-
Method Details
-
getRegisteredServices
-
registerService
public ServiceRegistration<?> registerService(BundleContext context, String[] classNames, Object svcObj, Dictionary dict) -
unregisterService
-
unregisterServices
This method retrieves all services registrations for the specified bundle and invokes ServiceRegistration.unregister() on each one. This method is only called be the framework to clean up after a stopped bundle.- Parameters:
bundle
- the bundle whose services should be unregistered.
-
getServiceReferences
-
getServicesInUse
-
getService
-
ungetService
-
ungetServices
This is a utility method to release all services being used by the specified bundle.- Parameters:
bundle
- the bundle whose services are to be released.
-
getUsingBundles
-
servicePropertiesModified
-
getLogger
-
addServiceRegistration
private static ServiceRegistration<?>[] addServiceRegistration(ServiceRegistration<?>[] regs, ServiceRegistration<?> reg) -
removeServiceRegistration
private static ServiceRegistration<?>[] removeServiceRegistration(ServiceRegistration<?>[] regs, ServiceRegistration<?> reg) -
getUsageCount
private ServiceRegistry.UsageCount getUsageCount(Bundle bundle, ServiceReference<?> ref, Object svcObj) Utility method to retrieve the specified bundle's usage count for the specified service reference.- Parameters:
bundle
- The bundle whose usage counts are being searched.ref
- The service reference to find in the bundle's usage counts.- Returns:
- The associated usage count or null if not found.
-
addUsageCount
private ServiceRegistry.UsageCount addUsageCount(Bundle bundle, ServiceReference<?> ref, boolean isPrototype) Utility method to update the specified bundle's usage count array to include the specified service. This method should only be called to add a usage count for a previously unreferenced service. If the service already has a usage count, then the existing usage count counter simply needs to be incremented.- Parameters:
bundle
- The bundle acquiring the service.ref
- The service reference of the acquired service.svcObj
- The service object of the acquired service.
-
flushUsageCount
Utility method to flush the specified bundle's usage count for the specified service reference. This should be called to completely remove the associated usage count object for the specified service reference. If the goal is to simply decrement the usage, then get the usage count and decrement its counter. This method will also remove the specified bundle from the "in use" map if it has no more usage counts after removing the usage count for the specified service reference.- Parameters:
bundle
- The bundle whose usage count should be removed.ref
- The service reference whose usage count should be removed.
-
isHookBlackListed
-
blackListHook
-
isHook
-
addHooks
-
updateHook
-
removeHook
-
getHooks
-
asTypedSortedSet
private static <S> SortedSet<ServiceReference<S>> asTypedSortedSet(SortedSet<ServiceReference<?>> ss)
-