Class OsgiServiceLookup


  • public class OsgiServiceLookup
    extends Object
    A utility class for looking up services from the OSGi registry. The methods of this class wait for the service for a given timeout (default 10 seconds) and throw a WicketRuntimeException when no matching service becomes available during this period.

    NOTE: Prefixing some method calls with our own class name is a workaround for a bug in the Oracle Java compiler, which does not occur when compiling in Eclipse.

    Author:
    Harald Wellmann
    • Constructor Detail

      • OsgiServiceLookup

        public OsgiServiceLookup()
    • Method Detail

      • getOsgiService

        public static <T> T getOsgiService​(org.osgi.framework.BundleContext bc,
                                           String className)
      • getOsgiService

        public static <T> T getOsgiService​(org.osgi.framework.BundleContext bc,
                                           Class<T> type)
      • getOsgiService

        public static <T> T getOsgiService​(org.osgi.framework.BundleContext bc,
                                           Class<T> type,
                                           Map<String,​String> props)
      • getOsgiService

        public static <T> T getOsgiService​(org.osgi.framework.BundleContext bc,
                                           Class<T> type,
                                           long timeout,
                                           Map<String,​String> props)
        Returns a service matching the given criteria.
        Type Parameters:
        T - class implemented or extended by the service
        Parameters:
        bc - bundle context for accessing the OSGi registry
        type - class implemented or extended by the service
        timeout - maximum wait period in milliseconds
        props - properties to be matched by the service
        Returns:
        matching service (not null)
        Throws:
        WicketRuntimeException
      • getOsgiService

        public static <T> T getOsgiService​(org.osgi.framework.BundleContext bc,
                                           Class<T> type,
                                           long timeout)
      • getOsgiService

        public static <T> T getOsgiService​(org.osgi.framework.BundleContext bc,
                                           String className,
                                           long timeout,
                                           Map<String,​String> props)