Class SortedServiceList<T>

java.lang.Object
org.codice.ddf.platform.util.SortedServiceList<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>

public class SortedServiceList<T> extends Object implements List<T>
This utility object sorts Services by their service rankings first and then breaks ties with service ids.

It is an implementation of List but is backed by a sorted TreeMap of <@link ServiceReference, T> where the ServiceReference objects are what is used to maintain the list order but the objects passed by this List to clients are the actual service objects and not the service references.

For instance if this was a SortedServiceList<@link AuthenticationHandler> object, then in the internal TreeMap the ServiceReference objects would be maintained as keys but AuthenticationHandler objects would be what is passed to clients. Therefore, a call to a populated SortedServiceList list such as list.get(0) would return the first AuthenticationHandler object.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor accepting OSGi bundle context.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int arg0, T arg1)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
    add(T arg0)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
    addAll(int arg0, Collection<? extends T> arg1)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
    addAll(Collection<? extends T> arg0)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    void
    bindPlugin(org.osgi.framework.ServiceReference ref)
    Adds the newly bound OSGi service and its service reference to the internally maintained and sorted serviceMap.
    void
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
     
    boolean
     
    get(int arg0)
     
    protected org.osgi.framework.BundleContext
     
    int
     
    boolean
     
     
    int
     
     
    listIterator(int arg0)
     
    remove(int arg0)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
    remove(Object arg0)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    boolean
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    set(int arg0, T arg1)
    Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
    int
     
    subList(int arg0, int arg1)
     
     
    <T> T[]
    toArray(T[] arg0)
     
    void
    unbindPlugin(org.osgi.framework.ServiceReference ref)
    Removes the newly bound OSGi service and its service reference to the internally maintained and sorted serviceMap.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.util.Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.List

    equals, hashCode, replaceAll, sort, spliterator
  • Constructor Details

    • SortedServiceList

      public SortedServiceList()
      Constructor accepting OSGi bundle context. This constructor is currently invoked by the ddf-catalog-framework bundle's blueprint and the fanout-catalogframework bundle's blueprint upon framework construction.
  • Method Details

    • getContext

      protected org.osgi.framework.BundleContext getContext()
    • bindPlugin

      public void bindPlugin(org.osgi.framework.ServiceReference ref)
      Adds the newly bound OSGi service and its service reference to the internally maintained and sorted serviceMap. This method is invoked when a plugin is bound (created/installed). This includes preingest, postingest, prequery, postquery, preresource, postresource plugins.
      Parameters:
      ref - the OSGi service reference
    • unbindPlugin

      public void unbindPlugin(org.osgi.framework.ServiceReference ref)
      Removes the newly bound OSGi service and its service reference to the internally maintained and sorted serviceMap. This method is invoked when a plugin is unbound (removed/uninstalled). This includes preingest, postingest, prequery, postquery, preresource, postresource plugins.
      Parameters:
      ref - the OSGi service reference
    • add

      public boolean add(T arg0)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      add in interface Collection<T>
      Specified by:
      add in interface List<T>
    • add

      public void add(int arg0, T arg1)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      add in interface List<T>
    • addAll

      public boolean addAll(Collection<? extends T> arg0)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      addAll in interface Collection<T>
      Specified by:
      addAll in interface List<T>
    • addAll

      public boolean addAll(int arg0, Collection<? extends T> arg1)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      addAll in interface List<T>
    • clear

      public void clear()
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      clear in interface Collection<T>
      Specified by:
      clear in interface List<T>
    • contains

      public boolean contains(Object arg0)
      Specified by:
      contains in interface Collection<T>
      Specified by:
      contains in interface List<T>
    • containsAll

      public boolean containsAll(Collection<?> arg0)
      Specified by:
      containsAll in interface Collection<T>
      Specified by:
      containsAll in interface List<T>
    • get

      public T get(int arg0)
      Specified by:
      get in interface List<T>
    • indexOf

      public int indexOf(Object arg0)
      Specified by:
      indexOf in interface List<T>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<T>
      Specified by:
      isEmpty in interface List<T>
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Collection<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface List<T>
    • lastIndexOf

      public int lastIndexOf(Object arg0)
      Specified by:
      lastIndexOf in interface List<T>
    • listIterator

      public ListIterator<T> listIterator()
      Specified by:
      listIterator in interface List<T>
    • listIterator

      public ListIterator<T> listIterator(int arg0)
      Specified by:
      listIterator in interface List<T>
    • remove

      public boolean remove(Object arg0)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      remove in interface Collection<T>
      Specified by:
      remove in interface List<T>
    • remove

      public T remove(int arg0)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      remove in interface List<T>
    • removeAll

      public boolean removeAll(Collection<?> arg0)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      removeAll in interface Collection<T>
      Specified by:
      removeAll in interface List<T>
    • retainAll

      public boolean retainAll(Collection<?> arg0)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      retainAll in interface Collection<T>
      Specified by:
      retainAll in interface List<T>
    • set

      public T set(int arg0, T arg1)
      Unsupported operation, throws an UnsupportedOperationException since this list is read-only.
      Specified by:
      set in interface List<T>
    • size

      public int size()
      Specified by:
      size in interface Collection<T>
      Specified by:
      size in interface List<T>
    • subList

      public List<T> subList(int arg0, int arg1)
      Specified by:
      subList in interface List<T>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface List<T>
    • toArray

      public <T> T[] toArray(T[] arg0)
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface List<T>