public class ServiceRegistry
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
ServiceRegistry.ServiceHolder |
static interface |
ServiceRegistry.ServiceRegistryCallbacks |
(package private) static class |
ServiceRegistry.UsageCount |
| Modifier and Type | Field and Description |
|---|---|
private HookRegistry |
hookRegistry |
private ServiceRegistry.ServiceRegistryCallbacks |
m_callbacks |
private java.util.concurrent.atomic.AtomicLong |
m_currentServiceId
Counter for the service id
|
private java.util.concurrent.ConcurrentMap<Bundle,ServiceRegistry.UsageCount[]> |
m_inUseMap |
private Logger |
m_logger |
private CapabilitySet |
m_regCapSet |
private java.util.concurrent.ConcurrentMap<Bundle,java.util.List<ServiceRegistration<?>>> |
m_regsMap |
| Constructor and Description |
|---|
ServiceRegistry(Logger logger,
ServiceRegistry.ServiceRegistryCallbacks callbacks) |
| Modifier and Type | Method and Description |
|---|---|
private void |
checkCountOverflow(long c) |
(package 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.
|
HookRegistry |
getHookRegistry() |
Logger |
getLogger() |
ServiceReference<?>[] |
getRegisteredServices(Bundle bundle)
Get all service references for a bundle
|
<S> S |
getService(Bundle bundle,
ServiceReference<S> ref,
boolean isServiceObjects) |
java.util.Collection<Capability> |
getServiceReferences(java.lang.String className,
SimpleFilter filter) |
ServiceReference<?>[] |
getServicesInUse(Bundle bundle) |
Bundle[] |
getUsingBundles(ServiceReference<?> ref) |
private void |
incrementToPositiveValue(java.util.concurrent.atomic.AtomicLong al) |
(package private) ServiceRegistry.UsageCount |
obtainUsageCount(Bundle bundle,
ServiceReference<?> ref,
java.lang.Object svcObj,
java.lang.Boolean isPrototype)
Obtain a UsageCount object, by looking for an existing one or creating a new one (if possible).
|
ServiceRegistration<?> |
registerService(Bundle bundle,
java.lang.String[] classNames,
java.lang.Object svcObj,
java.util.Dictionary<?,?> dict)
Register a new service
Caller must fire service event as this method is not doing it!
|
(package private) void |
servicePropertiesModified(ServiceRegistration<?> reg,
java.util.Dictionary<?,?> oldProps) |
boolean |
ungetService(Bundle bundle,
ServiceReference<?> ref,
java.lang.Object svcObj) |
void |
ungetServices(Bundle bundle)
This is a utility method to release all services being
used by the specified bundle.
|
private void |
ungetServices(ServiceReference<?> ref) |
void |
unregisterService(Bundle bundle,
ServiceRegistration<?> reg)
Unregister a service
|
void |
unregisterServices(Bundle bundle)
This method retrieves all services registrations for the specified
bundle and invokes ServiceRegistration.unregister() on each
one.
|
private final Logger m_logger
private final java.util.concurrent.atomic.AtomicLong m_currentServiceId
private final java.util.concurrent.ConcurrentMap<Bundle,java.util.List<ServiceRegistration<?>>> m_regsMap
private final CapabilitySet m_regCapSet
private final java.util.concurrent.ConcurrentMap<Bundle,ServiceRegistry.UsageCount[]> m_inUseMap
private final ServiceRegistry.ServiceRegistryCallbacks m_callbacks
private final HookRegistry hookRegistry
public ServiceRegistry(Logger logger, ServiceRegistry.ServiceRegistryCallbacks callbacks)
public ServiceReference<?>[] getRegisteredServices(Bundle bundle)
bundle - null.public ServiceRegistration<?> registerService(Bundle bundle, java.lang.String[] classNames, java.lang.Object svcObj, java.util.Dictionary<?,?> dict)
bundle - The bundle registering the serviceclassNames - The service class namessvcObj - The service objectdict - Optional service propertiespublic void unregisterService(Bundle bundle, ServiceRegistration<?> reg)
bundle - The bundle unregistering the servicereg - The service registrationprivate void ungetServices(ServiceReference<?> ref)
public void unregisterServices(Bundle bundle)
bundle - the bundle whose services should be unregistered.public java.util.Collection<Capability> getServiceReferences(java.lang.String className, SimpleFilter filter)
public ServiceReference<?>[] getServicesInUse(Bundle bundle)
public <S> S getService(Bundle bundle, ServiceReference<S> ref, boolean isServiceObjects)
private void incrementToPositiveValue(java.util.concurrent.atomic.AtomicLong al)
private void checkCountOverflow(long c)
public boolean ungetService(Bundle bundle, ServiceReference<?> ref, java.lang.Object svcObj)
public void ungetServices(Bundle bundle)
bundle - the bundle whose services are to be released.public Bundle[] getUsingBundles(ServiceReference<?> ref)
void servicePropertiesModified(ServiceRegistration<?> reg, java.util.Dictionary<?,?> oldProps)
public Logger getLogger()
ServiceRegistry.UsageCount obtainUsageCount(Bundle bundle, ServiceReference<?> ref, java.lang.Object svcObj, java.lang.Boolean isPrototype)
m_inUseMap. If one is found then
this is returned, otherwise a UsageCount object will be created, but this can only be done if
the isPrototype parameter is not null. If isPrototype is TRUE
then a new UsageCount object will always be created.bundle - The bundle using the service.ref - The Service Reference.svcObj - A Service Object, if applicable.isPrototype - TRUE if we know that this is a prototype, if we know that
it isn't. There are cases where we don't know (the pure lookup case), in that case use null.null otherwise.void flushUsageCount(Bundle bundle, ServiceReference<?> ref, ServiceRegistry.UsageCount uc)
bundle - The bundle whose usage count should be removed.ref - The service reference whose usage count should be removed.public HookRegistry getHookRegistry()