Class ServiceHelper


  • public final class ServiceHelper
    extends Object
    The class helps to register and retrieve OSGi service registry.
    • Method Detail

      • overrideGlobalInstance

        public static <T> void overrideGlobalInstance​(Class<T> clazz,
                                                      T instance)
        Override a global instance. This should generally only be used for testing.
        Parameters:
        clazz - The target class.
        instance - The instance to return for the class.
      • getGlobalInstance

        public static Object getGlobalInstance​(Class<?> clazz,
                                               Object bundle)
        Retrieve global instance of a class via OSGI registry, if there are many only the first is returned.
        Parameters:
        clazz - The target class
        bundle - The caller
      • getGlobalInstance

        public static Object getGlobalInstance​(Class<?> clazz,
                                               Object bundle,
                                               String serviceFilter)
        Retrieve global instance of a class via OSGI registry, if there are many only the first is returned. On this version an LDAP type of filter is applied
        Parameters:
        clazz - The target class
        bundle - The caller
        serviceFilter - LDAP filter to be applied in the search