org.apache.felix.ipojo.context

## Class ServiceRegistry

- java.lang.Object
- - org.apache.felix.ipojo.context.ServiceRegistry

    public class ServiceRegistry
    extends java.lang.Object

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

Author:
  Felix Project Team

### Constructor Summary

Constructors
Constructor and Description
`ServiceRegistry(org.osgi.framework.BundleContext context)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addServiceListener(org.osgi.framework.ServiceListener arg0)` Add a given service listener with no filter.
`void` `addServiceListener(org.osgi.framework.ServiceListener listener, java.lang.String filter)` Add a service listener with a filter.
`org.osgi.framework.ServiceReference[]` `getAllServiceReferences(java.lang.String clazz, java.lang.String filter)` Get all service references consistent with the given interface and filter.
`java.lang.Object` `getService(ComponentInstance instance, org.osgi.framework.ServiceReference ref)` Get a service object.
`org.osgi.framework.ServiceReference` `getServiceReference(java.lang.String clazz)` Look for a service reference.
`org.osgi.framework.ServiceReference[]` `getServiceReferences(java.lang.String className, java.lang.String expr)` Get available (and accessible) service references.
`org.osgi.framework.ServiceRegistration` `registerService(ComponentInstance instance, java.lang.String[] clazzes, java.lang.Object svcObj, java.util.Dictionary dict)` Register a service.
`org.osgi.framework.ServiceRegistration` `registerService(ComponentInstance instance, java.lang.String clazz, java.lang.Object svcObj, java.util.Dictionary dict)` Register a service.
`void` `removeServiceListener(org.osgi.framework.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, org.osgi.framework.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(org.osgi.framework.BundleContext context)

Constructor.

Parameters:
  `context` - : bundle context.

### Method Detail

#### addServiceListener

    public void addServiceListener(org.osgi.framework.ServiceListener arg0)

Add a given service listener with no filter.

Parameters:
  `arg0` - : the service listener to add

#### ungetService

    public boolean ungetService(ComponentInstance instance,
                                org.osgi.framework.ServiceReference ref)

Unget a service.

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

#### removeServiceListener

    public void removeServiceListener(org.osgi.framework.ServiceListener arg0)

Unregister a service listener.

Parameters:
  `arg0` - : the service listener to remove

#### registerService

    public org.osgi.framework.ServiceRegistration registerService(ComponentInstance instance,
                                                                  java.lang.String clazz,
                                                                  java.lang.Object svcObj,
                                                                  java.util.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 org.osgi.framework.ServiceRegistration registerService(ComponentInstance instance,
                                                                  java.lang.String[] clazzes,
                                                                  java.lang.Object svcObj,
                                                                  java.util.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 org.osgi.framework.ServiceReference[] getServiceReferences(java.lang.String className,
                                                                      java.lang.String expr)
                                                               throws org.osgi.framework.InvalidSyntaxException

Get available (and accessible) service references.

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

#### getServiceReference

    public org.osgi.framework.ServiceReference getServiceReference(java.lang.String clazz)

Look for a service reference.

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

#### getService

    public java.lang.Object getService(ComponentInstance instance,
                                       org.osgi.framework.ServiceReference ref)

Get a service object.

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

#### getAllServiceReferences

    public org.osgi.framework.ServiceReference[] getAllServiceReferences(java.lang.String clazz,
                                                                         java.lang.String filter)
                                                                  throws org.osgi.framework.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:
  `org.osgi.framework.InvalidSyntaxException` - occurs when the LDAP filter is malformed.

#### addServiceListener

    public void addServiceListener(org.osgi.framework.ServiceListener listener,
                                   java.lang.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.