org.apache.felix.ipojo.dependency.impl

## Class ComparatorBasedServiceRankingInterceptor

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

All Implemented Interfaces:
  DependencyInterceptor, ServiceRankingInterceptor

    public class ComparatorBasedServiceRankingInterceptor
    extends java.lang.Object
    implements ServiceRankingInterceptor

A comparator based version of the ranking interceptor.

### Field Summary

### Fields inherited from interface org.apache.felix.ipojo.dependency.interceptors.DependencyInterceptor

`TARGET_PROPERTY`

### Constructor Summary

Constructors
Constructor and Description
`ComparatorBasedServiceRankingInterceptor(java.util.Comparator<org.osgi.framework.ServiceReference> cmp)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close(DependencyModel dependency)` The interceptor won't be use anymore by the given dependency.
`java.util.List<org.osgi.framework.ServiceReference>` `getServiceReferences(DependencyModel dependency, java.util.List<org.osgi.framework.ServiceReference> matching)` Gets the sorted set of selected reference.
`java.util.List<org.osgi.framework.ServiceReference>` `onServiceArrival(DependencyModel dependency, java.util.List<org.osgi.framework.ServiceReference> matching, org.osgi.framework.ServiceReference<?> reference)` A new service arrives in the matching set.
`java.util.List<org.osgi.framework.ServiceReference>` `onServiceDeparture(DependencyModel dependency, java.util.List<org.osgi.framework.ServiceReference> matching, org.osgi.framework.ServiceReference<?> reference)` A service leaves the matching set.
`java.util.List<org.osgi.framework.ServiceReference>` `onServiceModified(DependencyModel dependency, java.util.List<org.osgi.framework.ServiceReference> matching, org.osgi.framework.ServiceReference<?> reference)` A service from the matching set was modified.
`void` `open(DependencyModel dependency)` The interceptor is plugged to the given dependency.

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

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

### Constructor Detail

#### ComparatorBasedServiceRankingInterceptor

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

### Method Detail

#### open

    public void open(DependencyModel dependency)

Description copied from interface: `DependencyInterceptor`
The interceptor is plugged to the given dependency.

Specified by:
  `open` in interface `DependencyInterceptor`
Parameters:
  `dependency` - the dependency starting using the interceptor.

#### getServiceReferences

    public java.util.List<org.osgi.framework.ServiceReference> getServiceReferences(DependencyModel dependency,
                                                                                    java.util.List<org.osgi.framework.ServiceReference> matching)

Description copied from interface: `ServiceRankingInterceptor`
Gets the sorted set of selected reference.

Specified by:
  `getServiceReferences` in interface `ServiceRankingInterceptor`
Parameters:
  `dependency` - the dependency
  `matching` - the set of service to sort
Returns:
  the sorted set of selected reference. This set is a sub-set potentially empty of the given list of references.

#### onServiceArrival

    public java.util.List<org.osgi.framework.ServiceReference> onServiceArrival(DependencyModel dependency,
                                                                                java.util.List<org.osgi.framework.ServiceReference> matching,
                                                                                org.osgi.framework.ServiceReference<?> reference)

Description copied from interface: `ServiceRankingInterceptor`
A new service arrives in the matching set. This method is called to retrieve the new sorted set of selected services.

Specified by:
  `onServiceArrival` in interface `ServiceRankingInterceptor`
Parameters:
  `dependency` - the dependency
  `matching` - the set of matching service
  `reference` - the arriving reference
Returns:
  the new sorted set of service

#### onServiceDeparture

    public java.util.List<org.osgi.framework.ServiceReference> onServiceDeparture(DependencyModel dependency,
                                                                                  java.util.List<org.osgi.framework.ServiceReference> matching,
                                                                                  org.osgi.framework.ServiceReference<?> reference)

Description copied from interface: `ServiceRankingInterceptor`
A service leaves the matching set. This method is called to retrieve the new sorted set of selected services.

Specified by:
  `onServiceDeparture` in interface `ServiceRankingInterceptor`
Parameters:
  `dependency` - the dependency
  `matching` - the set of matching service
  `reference` - the leaving reference
Returns:
  the new sorted set of service

#### onServiceModified

    public java.util.List<org.osgi.framework.ServiceReference> onServiceModified(DependencyModel dependency,
                                                                                 java.util.List<org.osgi.framework.ServiceReference> matching,
                                                                                 org.osgi.framework.ServiceReference<?> reference)

Description copied from interface: `ServiceRankingInterceptor`
A service from the matching set was modified. This method is called to retrieve the new sorted set of selected services.

Specified by:
  `onServiceModified` in interface `ServiceRankingInterceptor`
Parameters:
  `dependency` - the dependency
  `matching` - the set of matching service
  `reference` - the modified service
Returns:
  the new sorted set of service

#### close

    public void close(DependencyModel dependency)

Description copied from interface: `DependencyInterceptor`
The interceptor won't be use anymore by the given dependency. This method is called either when the interceptor is replace or when the instance's dependency is stopping.

Specified by:
  `close` in interface `DependencyInterceptor`
Parameters:
  `dependency` - the dependency stopping its use of the interceptor