org.apache.felix.ipojo.dependency.impl

## Class ServiceReferenceManager

- java.lang.Object
- - org.apache.felix.ipojo.dependency.impl.ServiceReferenceManager

All Implemented Interfaces:
  TrackerCustomizer

    public class ServiceReferenceManager
    extends java.lang.Object
    implements TrackerCustomizer

This class is handling the transformations between the base service set and the selected service set. It handles the matching services and the selected service set. As this class is tied to the dependency model, it reuses the same locks objects.

### Nested Class Summary

Nested Classes
`class` `ServiceReferenceManager.ChangeSet`

### Constructor Summary

Constructors
Constructor and Description
`ServiceReferenceManager(DependencyModel dep, org.osgi.framework.Filter filter, java.util.Comparator<org.osgi.framework.ServiceReference> comparator)` Creates the service reference manager.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addedService(org.osgi.framework.ServiceReference reference)` A service tracked by the Tracker object has been added in the list.
`boolean` `addingService(org.osgi.framework.ServiceReference reference)` A service is being added to the Tracker object.
`void` `close()`
`boolean` `contains(org.osgi.framework.ServiceReference ref)`
`java.util.List<org.osgi.framework.ServiceReference>` `getBindingInterceptorReferences()` Gets the list of binding interceptors attached to the current service dependency.
`java.util.Comparator<org.osgi.framework.ServiceReference>` `getComparator()`
`org.osgi.framework.Filter` `getFilter()`
`org.osgi.framework.ServiceReference` `getFirstService()`
`java.util.List<org.osgi.framework.ServiceReference>` `getMatchingServices()`
`org.osgi.framework.ServiceReference` `getRankingInterceptorReference()` Gets the service reference of the currently attached ranking interceptor.
`java.util.List<org.osgi.framework.ServiceReference>` `getSelectedServices()`
`java.util.List<org.osgi.framework.ServiceReference>` `getTrackingInterceptorReferences()` Gets the list of tracking interceptors attached to the current service dependency.
`void` `invalidateMatchingServices()`
`void` `invalidateSelectedServices()`
`boolean` `isEmpty()`
`void` `modifiedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)` A service tracked by the Tracker object has been modified.
`void` `onDepartureOfAMatchingService(TransformedServiceReference reference, java.lang.Object service)`
`void` `open()`
`void` `removedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)` A service tracked by the Tracker object has been removed.
`void` `reset()`
`void` `setComparator(java.util.Comparator<org.osgi.framework.ServiceReference> cmp)`
`ServiceReferenceManager.ChangeSet` `setFilter(org.osgi.framework.Filter filter, Tracker tracker)` A new filter is set.
`void` `setRankingInterceptor(ServiceRankingInterceptor interceptor)`
`void` `unweavingServiceBinding(DependencyModel.ServiceBindingHolder sbh)`
`java.lang.Object` `weavingServiceBinding(DependencyModel.ServiceBindingHolder sbh)`

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

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

### Constructor Detail

#### ServiceReferenceManager

    public ServiceReferenceManager(DependencyModel dep,
                                   org.osgi.framework.Filter filter,
                                   java.util.Comparator<org.osgi.framework.ServiceReference> comparator)

Creates the service reference manager.

Parameters:
  `dep` - the dependency
  `filter` - the filter
  `comparator` - the comparator

### Method Detail

#### open

    public void open()

#### weavingServiceBinding

    public java.lang.Object weavingServiceBinding(DependencyModel.ServiceBindingHolder sbh)

#### unweavingServiceBinding

    public void unweavingServiceBinding(DependencyModel.ServiceBindingHolder sbh)

#### getMatchingServices

    public java.util.List<org.osgi.framework.ServiceReference> getMatchingServices()

#### getSelectedServices

    public java.util.List<org.osgi.framework.ServiceReference> getSelectedServices()

#### getFirstService

    public org.osgi.framework.ServiceReference getFirstService()

#### contains

    public boolean contains(org.osgi.framework.ServiceReference ref)

#### reset

    public void reset()

#### addingService

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

Description copied from interface: `TrackerCustomizer`
A service is being added to the Tracker object. This method is called before a service which matched the search parameters of the Tracker object is added to it. This method should return the service object to be tracked for this ServiceReference object. If this method returns `true`, the service object becomes available from the `Tracker.getService()` and `Tracker.getServices()` methods. However notice that the service is still not accessible at that time.

Specified by:
  `addingService` in interface `TrackerCustomizer`
Parameters:
  `reference` - the Reference to service being added to the Tracker object.
Returns:
  `true` if the service reference must be tracked. `false` ff the service reference must be ignored (un-tracked)

#### addedService

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

Description copied from interface: `TrackerCustomizer`
A service tracked by the Tracker object has been added in the list. This method is called when a service has been added in the managed list (after addingService) and if the service has not disappeared before during the callback. In this method, the service object is accessible from the `Tracker.getService()` and `Tracker.getServices()` method.

Specified by:
  `addedService` in interface `TrackerCustomizer`
Parameters:
  `reference` - the added reference.

#### modifiedService

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

Description copied from interface: `TrackerCustomizer`
A service tracked by the Tracker object has been modified. This method is called when a service tracked by the Tracker has its properties modified.

Specified by:
  `modifiedService` in interface `TrackerCustomizer`
Parameters:
  `reference` - the reference to service that has been modified.
  `service` - The service object for the modified service.

#### onDepartureOfAMatchingService

    public void onDepartureOfAMatchingService(TransformedServiceReference reference,
                                              java.lang.Object service)

#### removedService

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

Description copied from interface: `TrackerCustomizer`
A service tracked by the Tracker object has been removed. This method is called when a tracked service is no longer being tracked by the Tracker object. Notice that some OSGi implementations does not support getting the service object from the bundle context in this method. The cached (given) object must be used.

Specified by:
  `removedService` in interface `TrackerCustomizer`
Parameters:
  `reference` - the reference to service that has been removed.
  `service` - The service object for the removed service.

#### setFilter

    public ServiceReferenceManager.ChangeSet setFilter(org.osgi.framework.Filter filter,
                                                       Tracker tracker)

A new filter is set. We have to recompute the set of matching services.

Parameters:
  `filter` - the new filter
  `tracker` - the tracker

#### isEmpty

    public boolean isEmpty()

#### getComparator

    public java.util.Comparator<org.osgi.framework.ServiceReference> getComparator()

#### setComparator

    public void setComparator(java.util.Comparator<org.osgi.framework.ServiceReference> cmp)

#### getFilter

    public org.osgi.framework.Filter getFilter()

#### setRankingInterceptor

    public void setRankingInterceptor(ServiceRankingInterceptor interceptor)

#### close

    public void close()

#### invalidateMatchingServices

    public void invalidateMatchingServices()

#### invalidateSelectedServices

    public void invalidateSelectedServices()

#### getTrackingInterceptorReferences

    public java.util.List<org.osgi.framework.ServiceReference> getTrackingInterceptorReferences()

Gets the list of tracking interceptors attached to the current service dependency.

Returns:
  the list of service references of the tracking interceptors participating to the resolution of the current service dependency. An empty list is returned is there are no participating interceptors.
Since:
  1.11.0

#### getBindingInterceptorReferences

    public java.util.List<org.osgi.framework.ServiceReference> getBindingInterceptorReferences()

Gets the list of binding interceptors attached to the current service dependency.

Returns:
  the list of service references of the binding interceptors participating to the resolution of the current service dependency. An empty list is returned is there are no participating interceptors.
Since:
  1.11.0

#### getRankingInterceptorReference

    public org.osgi.framework.ServiceReference getRankingInterceptorReference()

Gets the service reference of the currently attached ranking interceptor. As only one ranking interceptor can be attached at a point on time, this is not a list but only one reference.

Returns:
  the service reference of the ranking interceptor participating to the resolution of the current service dependency. `null` if no (external) ranking interceptor is currently attached.
Since:
  1.11.0