org.eclipse.osgi.framework.internal.core
Class ServiceRegistryImpl

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.ServiceRegistryImpl
All Implemented Interfaces:
ServiceRegistry

public class ServiceRegistryImpl
extends java.lang.Object
implements ServiceRegistry

A default implementation of the ServiceRegistry.


Field Summary
protected  java.util.ArrayList allPublishedServices
          All published services.
protected  java.util.HashMap publishedServicesByClass
          Published services by class name.
protected  java.util.HashMap publishedServicesByContext
          Published services by BundleContext.
 
Constructor Summary
ServiceRegistryImpl()
           
 
Method Summary
 void initialize()
          Initializes the internal data structures of this ServiceRegistry.
 ServiceReference[] lookupServiceReferences(BundleContext context)
          Performs a lookup for ServiceReferences that are bound to this ServiceRegistry using the specified BundleContext.
 ServiceReference[] lookupServiceReferences(java.lang.String clazz, Filter filter)
          Performs a lookup for ServiceReferences that are bound to this ServiceRegistry.
 void publishService(BundleContext context, ServiceRegistration serviceReg)
          Publishes a service to this ServiceRegistry.
 void unpublishService(BundleContext context, ServiceRegistration serviceReg)
          Unpublishes a service from this ServiceRegistry
 void unpublishServices(BundleContext context)
          Unpublishes all services from this ServiceRegistry that the specified BundleContext registered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publishedServicesByClass

protected java.util.HashMap publishedServicesByClass
Published services by class name. Key is a String class name; Value is a ArrayList of ServiceRegistrations


allPublishedServices

protected java.util.ArrayList allPublishedServices
All published services. Value is ServiceRegistrations


publishedServicesByContext

protected java.util.HashMap publishedServicesByContext
Published services by BundleContext. Key is a BundleContext; Value is a ArrayList of ServiceRegistrations

Constructor Detail

ServiceRegistryImpl

public ServiceRegistryImpl()
Method Detail

initialize

public void initialize()
Initializes the internal data structures of this ServiceRegistry.


publishService

public void publishService(BundleContext context,
                           ServiceRegistration serviceReg)
Description copied from interface: ServiceRegistry
Publishes a service to this ServiceRegistry.

Specified by:
publishService in interface ServiceRegistry
Parameters:
context - the BundleContext that registered the service.
serviceReg - the ServiceRegistration to register.
See Also:
ServiceRegistry.publishService(BundleContext, ServiceRegistration)

unpublishService

public void unpublishService(BundleContext context,
                             ServiceRegistration serviceReg)
Description copied from interface: ServiceRegistry
Unpublishes a service from this ServiceRegistry

Specified by:
unpublishService in interface ServiceRegistry
Parameters:
context - the BundleContext that registered the service.
serviceReg - the ServiceRegistration to unpublish.
See Also:
ServiceRegistry.unpublishService(BundleContext, ServiceRegistration)

unpublishServices

public void unpublishServices(BundleContext context)
Description copied from interface: ServiceRegistry
Unpublishes all services from this ServiceRegistry that the specified BundleContext registered.

Specified by:
unpublishServices in interface ServiceRegistry
Parameters:
context - the BundleContext to unpublish all services for.
See Also:
ServiceRegistry.unpublishServices(BundleContext)

lookupServiceReferences

public ServiceReference[] lookupServiceReferences(java.lang.String clazz,
                                                  Filter filter)
Description copied from interface: ServiceRegistry
Performs a lookup for ServiceReferences that are bound to this ServiceRegistry. If both clazz and filter are null then all bound ServiceReferences are returned.

Specified by:
lookupServiceReferences in interface ServiceRegistry
Parameters:
clazz - A fully qualified class name. All ServiceReferences that reference an object that implement this class are returned. May be null.
filter - Used to match against published Services. All ServiceReferences that match the filter are returned. If a clazz is specified then all ServiceReferences that match the clazz and the filter parameter are returned. May be null.
Returns:
An array of all matching ServiceReferences or null if none exist.
See Also:
ServiceRegistry.lookupServiceReferences(String, Filter)

lookupServiceReferences

public ServiceReference[] lookupServiceReferences(BundleContext context)
Description copied from interface: ServiceRegistry
Performs a lookup for ServiceReferences that are bound to this ServiceRegistry using the specified BundleContext.

Specified by:
lookupServiceReferences in interface ServiceRegistry
Parameters:
context - The BundleContext to lookup the ServiceReferences on.
Returns:
An array of all matching ServiceReferences or null if none exist.
See Also:
ServiceRegistry.lookupServiceReferences(BundleContext)