org.apache.felix.ipojo.composite

## Class CompositeServiceContext

- java.lang.Object
- - org.apache.felix.ipojo.composite.CompositeServiceContext

All Implemented Interfaces:
  ServiceContext, TrackerCustomizer, org.osgi.framework.BundleContext, org.osgi.framework.BundleReference

    public class CompositeServiceContext
    extends java.lang.Object
    implements ServiceContext, TrackerCustomizer

CompositeServiceContext Class. This class provides an implementation of the service context for composite.

Author:
  Felix Project Team

### Constructor Summary

Constructors
Constructor and Description
`CompositeServiceContext(org.osgi.framework.BundleContext context)` Constructor.
`CompositeServiceContext(org.osgi.framework.BundleContext context, ComponentInstance instance)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addBundleListener(org.osgi.framework.BundleListener arg0)` Add a bundle listener.
`void` `addedService(org.osgi.framework.ServiceReference reference)` A matching reference has been added.
`void` `addFrameworkListener(org.osgi.framework.FrameworkListener arg0)` Add a framework listener.
`boolean` `addingService(org.osgi.framework.ServiceReference reference)` A new factory is detected.
`void` `addServiceListener(org.osgi.framework.ServiceListener arg0)` Add a service listener.
`void` `addServiceListener(org.osgi.framework.ServiceListener arg0, java.lang.String arg1)` Add a filtered service listener.
`org.osgi.framework.Filter` `createFilter(java.lang.String arg0)` Create a LDAP filter.
`org.osgi.framework.ServiceReference[]` `getAllServiceReferences(java.lang.String arg0, java.lang.String arg1)` Get all service references.
`org.osgi.framework.Bundle` `getBundle()` Get the current bundle.
`org.osgi.framework.Bundle` `getBundle(long bundleId)` Get the bundle object with the given id.
`org.osgi.framework.Bundle` `getBundle(java.lang.String location)`
`org.osgi.framework.Bundle[]` `getBundles()` Get installed bundles.
`java.io.File` `getDataFile(java.lang.String filename)` Get a data file.
`java.lang.String` `getProperty(java.lang.String key)` Get a property value.
`java.lang.Object` `getService(org.osgi.framework.ServiceReference arg0)` Get a service object for the given service reference.
`<S> org.osgi.framework.ServiceReference<S>` `getServiceReference(java.lang.Class<S> clazz)`
`org.osgi.framework.ServiceReference` `getServiceReference(java.lang.String arg0)` Get a service reference for the required interface.
`<S> java.util.Collection<org.osgi.framework.ServiceReference<S>>` `getServiceReferences(java.lang.Class<S> clazz, java.lang.String filter)`
`org.osgi.framework.ServiceReference[]` `getServiceReferences(java.lang.String clazz, java.lang.String filter)` Get all accessible service reference for the given query.
`org.osgi.framework.Bundle` `installBundle(java.lang.String location)` Install a bundle.
`org.osgi.framework.Bundle` `installBundle(java.lang.String location, java.io.InputStream input)` Install a bundle.
`void` `modifiedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)` An imported factory is modified.
`<S> org.osgi.framework.ServiceRegistration<S>` `registerService(java.lang.Class<S> clazz, S service, java.util.Dictionary<java.lang.String,?> properties)`
`org.osgi.framework.ServiceRegistration` `registerService(java.lang.String[] arg0, java.lang.Object arg1, java.util.Dictionary arg2)` Register a service inside the composite context.
`org.osgi.framework.ServiceRegistration` `registerService(java.lang.String arg0, java.lang.Object arg1, java.util.Dictionary arg2)` Register a service inside the composite context.
`void` `removeBundleListener(org.osgi.framework.BundleListener listener)` Remove a bundle listener.
`void` `removedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)` An imported factory disappears.
`void` `removeFrameworkListener(org.osgi.framework.FrameworkListener listener)` Remove a framework listener.
`void` `removeServiceListener(org.osgi.framework.ServiceListener arg0)` Remove a service listener.
`void` `start()` Start the registry management.
`void` `stop()` Stop the registry management.
`boolean` `ungetService(org.osgi.framework.ServiceReference arg0)` Unget a service.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CompositeServiceContext

    public CompositeServiceContext(org.osgi.framework.BundleContext context)

Constructor. This constructor instantiate a service registry with the given bundle context.

Parameters:
  `context` - : the bundle context

#### CompositeServiceContext

    public CompositeServiceContext(org.osgi.framework.BundleContext context,
                                   ComponentInstance instance)

Constructor.

Parameters:
  `context` - : the bundle context
  `instance` - : the component instance owning this context

### Method Detail

#### addServiceListener

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

Add a service listener.

Specified by:
  `addServiceListener` in interface `ServiceContext`
Specified by:
  `addServiceListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : The service listener to add
See Also:
  `ServiceContext.addServiceListener(org.osgi.framework.ServiceListener)`

#### addServiceListener

    public void addServiceListener(org.osgi.framework.ServiceListener arg0,
                                   java.lang.String arg1)
                            throws org.osgi.framework.InvalidSyntaxException

Add a filtered service listener.

Specified by:
  `addServiceListener` in interface `ServiceContext`
Specified by:
  `addServiceListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : the service listener object to add
  `arg1` - : the LDAP filter for this listener
Throws:
  `org.osgi.framework.InvalidSyntaxException` - : occurs if the LDAP filter is malformed
See Also:
  `ServiceContext.addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)`

#### getAllServiceReferences

    public org.osgi.framework.ServiceReference[] getAllServiceReferences(java.lang.String arg0,
                                                                         java.lang.String arg1)
                                                                  throws org.osgi.framework.InvalidSyntaxException

Get all service references.

Specified by:
  `getAllServiceReferences` in interface `ServiceContext`
Specified by:
  `getAllServiceReferences` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : The required service interface.
  `arg1` - : LDAP filter
Returns:
  the list of all service reference matching with the query
Throws:
  `org.osgi.framework.InvalidSyntaxException` - : occurs when the given filter is malformed
See Also:
  `ServiceContext.getAllServiceReferences(java.lang.String, java.lang.String)`

#### getService

    public java.lang.Object getService(org.osgi.framework.ServiceReference arg0)

Get a service object for the given service reference.

Specified by:
  `getService` in interface `ServiceContext`
Specified by:
  `getService` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : the service reference
Returns:
  the service object or null if the reference is no more valid or if the object is not accessible
See Also:
  `ServiceContext.getService(org.osgi.framework.ServiceReference)`

#### getServiceReference

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

Get a service reference for the required interface.

Specified by:
  `getServiceReference` in interface `ServiceContext`
Specified by:
  `getServiceReference` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : the required interface name
Returns:
  the service reference or null if no available provider
See Also:
  `ServiceContext.getServiceReference(java.lang.String)`

#### getServiceReference

    public <S> org.osgi.framework.ServiceReference<S> getServiceReference(java.lang.Class<S> clazz)

Specified by:
  `getServiceReference` in interface `org.osgi.framework.BundleContext`

#### getServiceReferences

    public <S> java.util.Collection<org.osgi.framework.ServiceReference<S>> getServiceReferences(java.lang.Class<S> clazz,
                                                                                                 java.lang.String filter)
                                                                                          throws org.osgi.framework.InvalidSyntaxException

Specified by:
  `getServiceReferences` in interface `org.osgi.framework.BundleContext`
Throws:
  `org.osgi.framework.InvalidSyntaxException`

#### getServiceReferences

    public org.osgi.framework.ServiceReference[] getServiceReferences(java.lang.String clazz,
                                                                      java.lang.String filter)
                                                               throws org.osgi.framework.InvalidSyntaxException

Get all accessible service reference for the given query.

Specified by:
  `getServiceReferences` in interface `ServiceContext`
Specified by:
  `getServiceReferences` in interface `org.osgi.framework.BundleContext`
Parameters:
  `clazz` - : required interface
  `filter` - : LDAP filter
Returns:
  the list (array) of service reference matching with the query.
Throws:
  `org.osgi.framework.InvalidSyntaxException` - : occurs when the LDAP filter is malformed
See Also:
  `ServiceContext.getServiceReferences(java.lang.String, java.lang.String)`

#### registerService

    public org.osgi.framework.ServiceRegistration registerService(java.lang.String[] arg0,
                                                                  java.lang.Object arg1,
                                                                  java.util.Dictionary arg2)

Register a service inside the composite context.

Specified by:
  `registerService` in interface `ServiceContext`
Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : list of interfaces to register.
  `arg1` - : service object
  `arg2` - : properties list
Returns:
  the service registration
See Also:
  `ServiceContext.registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)`

#### registerService

    public org.osgi.framework.ServiceRegistration registerService(java.lang.String arg0,
                                                                  java.lang.Object arg1,
                                                                  java.util.Dictionary arg2)

Register a service inside the composite context.

Specified by:
  `registerService` in interface `ServiceContext`
Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : interface to register.
  `arg1` - : service object
  `arg2` - : properties list
Returns:
  the service registration
See Also:
  `ServiceContext.registerService(java.lang.String, java.lang.Object, java.util.Dictionary)`

#### removeServiceListener

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

Remove a service listener.

Specified by:
  `removeServiceListener` in interface `ServiceContext`
Specified by:
  `removeServiceListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : the service listener to remove
See Also:
  `ServiceContext.removeServiceListener(org.osgi.framework.ServiceListener)`

#### ungetService

    public boolean ungetService(org.osgi.framework.ServiceReference arg0)

Unget a service.

Specified by:
  `ungetService` in interface `ServiceContext`
Specified by:
  `ungetService` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - the service reference to unget
Returns:
  true
See Also:
  `ServiceContext.ungetService(org.osgi.framework.ServiceReference)`

#### start

    public void start()

Start the registry management.

#### stop

    public void stop()

Stop the registry management.

#### addBundleListener

    public void addBundleListener(org.osgi.framework.BundleListener arg0)

Add a bundle listener. Delegate on the global bundle context.

Specified by:
  `addBundleListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : bundle listener to add
See Also:
  `BundleContext.addBundleListener(org.osgi.framework.BundleListener)`

#### addFrameworkListener

    public void addFrameworkListener(org.osgi.framework.FrameworkListener arg0)

Add a framework listener. Delegate on the global bundle context.

Specified by:
  `addFrameworkListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : framework listener to add.
See Also:
  `BundleContext.addFrameworkListener(org.osgi.framework.FrameworkListener)`

#### createFilter

    public org.osgi.framework.Filter createFilter(java.lang.String arg0)
                                           throws org.osgi.framework.InvalidSyntaxException

Create a LDAP filter.

Specified by:
  `createFilter` in interface `org.osgi.framework.BundleContext`
Parameters:
  `arg0` - : String-form of the filter
Returns:
  the created filter object
Throws:
  `org.osgi.framework.InvalidSyntaxException` - : if the given argument is not a valid against the LDAP grammar.
See Also:
  `BundleContext.createFilter(java.lang.String)`

#### getBundle

    public org.osgi.framework.Bundle getBundle(java.lang.String location)

Specified by:
  `getBundle` in interface `org.osgi.framework.BundleContext`

#### getBundle

    public org.osgi.framework.Bundle getBundle()

Get the current bundle.

Specified by:
  `getBundle` in interface `org.osgi.framework.BundleContext`
Specified by:
  `getBundle` in interface `org.osgi.framework.BundleReference`
Returns:
  the current bundle
See Also:
  `BundleContext.getBundle()`

#### getBundle

    public org.osgi.framework.Bundle getBundle(long bundleId)

Get the bundle object with the given id.

Specified by:
  `getBundle` in interface `org.osgi.framework.BundleContext`
Parameters:
  `bundleId` - : bundle id
Returns:
  the bundle object
See Also:
  `BundleContext.getBundle(long)`

#### getBundles

    public org.osgi.framework.Bundle[] getBundles()

Get installed bundles.

Specified by:
  `getBundles` in interface `org.osgi.framework.BundleContext`
Returns:
  the list of installed bundles
See Also:
  `BundleContext.getBundles()`

#### getDataFile

    public java.io.File getDataFile(java.lang.String filename)

Get a data file.

Specified by:
  `getDataFile` in interface `org.osgi.framework.BundleContext`
Parameters:
  `filename` - : File name.
Returns:
  the File object
See Also:
  `BundleContext.getDataFile(java.lang.String)`

#### getProperty

    public java.lang.String getProperty(java.lang.String key)

Get a property value.

Specified by:
  `getProperty` in interface `org.osgi.framework.BundleContext`
Parameters:
  `key` - : key of the asked property
Returns:
  the property value (object) or null if no property are associated with the given key
See Also:
  `BundleContext.getProperty(java.lang.String)`

#### installBundle

    public org.osgi.framework.Bundle installBundle(java.lang.String location)
                                            throws org.osgi.framework.BundleException

Install a bundle.

Specified by:
  `installBundle` in interface `org.osgi.framework.BundleContext`
Parameters:
  `location` - : URL of the bundle to install
Returns:
  the installed bundle
Throws:
  `org.osgi.framework.BundleException` - : if the bundle cannot be installed correctly
See Also:
  `BundleContext.installBundle(java.lang.String)`

#### installBundle

    public org.osgi.framework.Bundle installBundle(java.lang.String location,
                                                   java.io.InputStream input)
                                            throws org.osgi.framework.BundleException

Install a bundle.

Specified by:
  `installBundle` in interface `org.osgi.framework.BundleContext`
Parameters:
  `location` - : URL of the bundle to install
  `input` - :
Returns:
  the installed bundle
Throws:
  `org.osgi.framework.BundleException` - : if the bundle cannot be installed correctly
See Also:
  `BundleContext.installBundle(java.lang.String, java.io.InputStream)`

#### removeBundleListener

    public void removeBundleListener(org.osgi.framework.BundleListener listener)

Remove a bundle listener.

Specified by:
  `removeBundleListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `listener` - : the listener to remove
See Also:
  `BundleContext.removeBundleListener(org.osgi.framework.BundleListener)`

#### removeFrameworkListener

    public void removeFrameworkListener(org.osgi.framework.FrameworkListener listener)

Remove a framework listener.

Specified by:
  `removeFrameworkListener` in interface `org.osgi.framework.BundleContext`
Parameters:
  `listener` - : the listener to remove
See Also:
  `BundleContext.removeFrameworkListener(org.osgi.framework.FrameworkListener)`

#### registerService

    public <S> org.osgi.framework.ServiceRegistration<S> registerService(java.lang.Class<S> clazz,
                                                                         S service,
                                                                         java.util.Dictionary<java.lang.String,?> properties)

Specified by:
  `registerService` in interface `org.osgi.framework.BundleContext`

#### addingService

    public boolean addingService(org.osgi.framework.ServiceReference reference)

A new factory is detected.

Specified by:
  `addingService` in interface `TrackerCustomizer`
Parameters:
  `reference` - : service reference
Returns:
  true if not already imported.
See Also:
  `TrackerCustomizer.addingService(org.osgi.framework.ServiceReference)`

#### addedService

    public void addedService(org.osgi.framework.ServiceReference reference)

A matching reference has been added. The import factory can now be imported.

Specified by:
  `addedService` in interface `TrackerCustomizer`
Parameters:
  `reference` - : the added reference.
See Also:
  `TrackerCustomizer.addedService(org.osgi.framework.ServiceReference)`

#### modifiedService

    public void modifiedService(org.osgi.framework.ServiceReference reference,
                                java.lang.Object service)

An imported factory is modified.

Specified by:
  `modifiedService` in interface `TrackerCustomizer`
Parameters:
  `reference` - : modified reference
  `service` - : factory object.
See Also:
  `TrackerCustomizer.modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)`

#### removedService

    public void removedService(org.osgi.framework.ServiceReference reference,
                               java.lang.Object service)

An imported factory disappears.

Specified by:
  `removedService` in interface `TrackerCustomizer`
Parameters:
  `reference` - : reference
  `service` - : factory object.
See Also:
  `TrackerCustomizer.removedService(org.osgi.framework.ServiceReference, java.lang.Object)`