org.apache.felix.ipojo.context
Class ServiceRegistry

java.lang.Object
  extended by org.apache.felix.ipojo.context.ServiceRegistry

public class ServiceRegistry
extends Object

Internal Service Registry. This class is used for in the composition.

Author:
Felix Project Team

Constructor Summary
ServiceRegistry(BundleContext context)
          Constructor.
 
Method Summary
 void addServiceListener(ServiceListener arg0)
          Add a given service listener with no filter.
 void addServiceListener(ServiceListener listener, String filter)
          Add a service listener with a filter.
 ServiceReference[] getAllServiceReferences(String clazz, String filter)
          Get all service references consistent with the given interface and filter.
 Object getService(ComponentInstance instance, ServiceReference ref)
          Get a service object.
 ServiceReference getServiceReference(String clazz)
          Look for a service reference.
 ServiceReference[] getServiceReferences(String className, String expr)
          Get available (and accessible) service references.
 ServiceRegistration registerService(ComponentInstance instance, String[] clazzes, Object svcObj, Dictionary dict)
          Register a service.
 ServiceRegistration registerService(ComponentInstance instance, String clazz, Object svcObj, Dictionary dict)
          Register a service.
 void removeServiceListener(ServiceListener arg0)
          Unregister a service listener.
 void reset()
          Reset the service registry.
 void servicePropertiesModified(ServiceRegistrationImpl reg)
          Dispatch a service properties modified event.
 boolean ungetService(ComponentInstance instance, ServiceReference ref)
          Unget a service.
 void unregisterService(ServiceRegistrationImpl reg)
          Unregister a service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceRegistry

public ServiceRegistry(BundleContext context)
Constructor.

Parameters:
context - : bundle context.
Method Detail

addServiceListener

public void addServiceListener(ServiceListener arg0)
Add a given service listener with no filter.

Parameters:
arg0 - : the service listener to add

ungetService

public boolean ungetService(ComponentInstance instance,
                            ServiceReference ref)
Unget a service.

Parameters:
instance - : instance releasing the service.
ref - : released reference.
Returns:
true if the unget success

removeServiceListener

public void removeServiceListener(ServiceListener arg0)
Unregister a service listener.

Parameters:
arg0 - : the service listener to remove

registerService

public ServiceRegistration registerService(ComponentInstance instance,
                                           String clazz,
                                           Object svcObj,
                                           Dictionary dict)
Register a service.

Parameters:
instance - : provider instance.
clazz - : provided interface.
svcObj - : service object of service factory object.
dict - : service properties.
Returns:
the created service registration.

registerService

public ServiceRegistration registerService(ComponentInstance instance,
                                           String[] clazzes,
                                           Object svcObj,
                                           Dictionary dict)
Register a service.

Parameters:
instance - : provider instance.
clazzes - : provided interfaces.
svcObj - : service object of service factory object.
dict - : service properties.
Returns:
the created service registration.

getServiceReferences

public ServiceReference[] getServiceReferences(String className,
                                               String expr)
                                        throws InvalidSyntaxException
Get available (and accessible) service references.

Parameters:
className - : required interface
expr - : LDAP filter
Returns:
: the list of available service references.
Throws:
InvalidSyntaxException - occurs when the LDAP filter is malformed.

getServiceReference

public ServiceReference getServiceReference(String clazz)
Look for a service reference.

Parameters:
clazz - : required interface.
Returns:
the first available provider or null if none available.

getService

public Object getService(ComponentInstance instance,
                         ServiceReference ref)
Get a service object.

Parameters:
instance - : component instance requiring the service.
ref - : the required reference.
Returns:
the service object.

getAllServiceReferences

public ServiceReference[] getAllServiceReferences(String clazz,
                                                  String filter)
                                           throws InvalidSyntaxException
Get all service references consistent with the given interface and filter.

Parameters:
clazz - : the required interface.
filter - : the LDAP filter.
Returns:
the list of all service reference or null if none available.
Throws:
InvalidSyntaxException - occurs when the LDAP filter is malformed.

addServiceListener

public void addServiceListener(ServiceListener listener,
                               String filter)
Add a service listener with a filter.

Parameters:
listener - : the service listener to add
filter - : LDAP filter

servicePropertiesModified

public void servicePropertiesModified(ServiceRegistrationImpl reg)
Dispatch a service properties modified event.

Parameters:
reg - : the implicated service registration.

unregisterService

public void unregisterService(ServiceRegistrationImpl reg)
Unregister a service.

Parameters:
reg - : the service registration to unregister

reset

public void reset()
Reset the service registry.



Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.