Class BundleContextServiceLocator

    • Constructor Summary

      Constructors 
      Constructor Description
      BundleContextServiceLocator​(org.osgi.framework.BundleContext bundleContext)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> java.util.List<T> findServices​(java.lang.Class<T> clazz, java.lang.String query)
      Find services of class clazz registered in the OSGI Service Registry.
      <T> T findSingleService​(java.lang.Class<T> clazz, java.util.function.Predicate<T> postFilter, java.lang.String bundleContextFilter)
      Finds a service registered with the OSGI Service Registry of type clazz.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BundleContextServiceLocator

        public BundleContextServiceLocator​(org.osgi.framework.BundleContext bundleContext)
    • Method Detail

      • findSingleService

        public <T> T findSingleService​(java.lang.Class<T> clazz,
                                       java.util.function.Predicate<T> postFilter,
                                       java.lang.String bundleContextFilter)
        Description copied from interface: ServiceLocator
        Finds a service registered with the OSGI Service Registry of type clazz. If a bundleContextFilter is provided, it is used to query for the service, e.g. "(operation.label=My Label*)". In addition each clazz of type T found in the OSGI Service Registry must afterwards pass the provided postFilter. If multiple services are found, only the first one is returned.
        Specified by:
        findSingleService in interface ServiceLocator
        Returns:
        A object of type clazz or null.
      • findServices

        public <T> java.util.List<T> findServices​(java.lang.Class<T> clazz,
                                                  java.lang.String query)
        Description copied from interface: ServiceLocator
        Find services of class clazz registered in the OSGI Service Registry. The optional filter criteria query is used.
        Specified by:
        findServices in interface ServiceLocator
        Returns:
        All found services registered in the OSGI Service Registry of type clazz.