Package org.wicketstuff.osgi.util
Class OsgiServiceLookup
- java.lang.Object
-
- org.wicketstuff.osgi.util.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 aWicketRuntimeException
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
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_TIMEOUT
-
Constructor Summary
Constructors Constructor Description OsgiServiceLookup()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
getOsgiService(org.osgi.framework.BundleContext bc, Class<T> type)
static <T> T
getOsgiService(org.osgi.framework.BundleContext bc, Class<T> type, long timeout)
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.static <T> T
getOsgiService(org.osgi.framework.BundleContext bc, Class<T> type, Map<String,String> props)
static <T> T
getOsgiService(org.osgi.framework.BundleContext bc, String className)
static <T> T
getOsgiService(org.osgi.framework.BundleContext bc, String className, long timeout, Map<String,String> props)
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
-
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 registrytype
- class implemented or extended by the servicetimeout
- maximum wait period in millisecondsprops
- 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)
-
-