public class ProviderLocator
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
destroy()
Cleanup resources on bundle shutdown.
|
static java.lang.Object |
getService(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
Get a single service instance that matches an interface
definition.
|
static java.lang.Class<?> |
getServiceClass(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
Locate a service class that matches an interface
definition.
|
static java.util.List<java.lang.Class<?>> |
getServiceClasses(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
Get a list of service class implementations that match
an interface name.
|
static java.util.List<java.lang.Object> |
getServices(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
Get a list of services that match a given interface
name.
|
static void |
init(org.osgi.framework.BundleContext c)
initialize the tracker statics for this bundle
|
static java.lang.Class<?> |
loadClass(java.lang.String className)
Utility class for locating a class with OSGi registry
support.
|
static java.lang.Class<?> |
loadClass(java.lang.String className,
java.lang.Class<?> contextClass)
Utility class for locating a class with OSGi registry
support.
|
static java.lang.Class<?> |
loadClass(java.lang.String className,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
Standardized utility method for performing class lookups
with support for OSGi registry lookups.
|
static java.lang.Class<?> |
locate(java.lang.String providerId)
Locate a class by its provider id indicator.
|
static java.util.List<java.lang.Class<?>> |
locateAll(java.lang.String providerId)
Locate all class files that match a given factory id.
|
static java.lang.String |
lookupByJREPropertyFile(java.lang.String path,
java.lang.String property)
Perform a service class discovery by looking for a
property in a target properties file located in the
java.home directory.
|
public static void init(org.osgi.framework.BundleContext c)
c - The starup BundleContext.public static void destroy()
public static java.lang.Class<?> locate(java.lang.String providerId)
providerId - The provider id (generally, a fully qualified class name).public static java.util.List<java.lang.Class<?>> locateAll(java.lang.String providerId)
providerId - The target provider identifier.public static java.lang.Class<?> loadClass(java.lang.String className)
throws java.lang.ClassNotFoundException
className - The name of the target class.java.lang.ClassNotFoundException - Thrown if the class cannot be located.public static java.lang.Class<?> loadClass(java.lang.String className,
java.lang.Class<?> contextClass)
throws java.lang.ClassNotFoundException
className - The name of the target class.java.lang.ClassNotFoundException - Thrown if the class cannot be located.public static java.lang.Class<?> loadClass(java.lang.String className,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
throws java.lang.ClassNotFoundException
className - The name of the target class.loader - An optional class loader.java.lang.ClassNotFoundException - Thrown if the class cannot be loaded.public static java.lang.Object getService(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
throws java.lang.Exception
iface - The name of the required interface.contextClass - The class requesting the lookup (used for class resolution).loader - A class loader to use for searching for service definitions
and loading classes.java.lang.Exception - Thrown for any classloading or exceptions thrown
trying to instantiate a service instance.public static java.lang.Class<?> getServiceClass(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
throws java.lang.ClassNotFoundException
iface - The name of the required interface.contextClass - The class requesting the lookup (used for class resolution).loader - A class loader to use for searching for service definitions
and loading classes.java.lang.Exception - Thrown for any classloading exceptions thrown
trying to load the class.java.lang.ClassNotFoundExceptionpublic static java.util.List<java.lang.Object> getServices(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
throws java.lang.Exception
iface - The name of the required interface.contextClass - The class requesting the lookup (used for class resolution).loader - A class loader to use for searching for service definitions
and loading classes.java.lang.Exception - Thrown for any classloading or exceptions thrown
trying to instantiate a service instance.public static java.util.List<java.lang.Class<?>> getServiceClasses(java.lang.String iface,
java.lang.Class<?> contextClass,
java.lang.ClassLoader loader)
throws java.lang.Exception
iface - The name of the required interface.contextClass - The class requesting the lookup (used for class resolution).loader - A class loader to use for searching for service definitions
and loading classes.java.lang.Exception - Thrown for any classloading exceptions thrown
trying to load a provider class.public static java.lang.String lookupByJREPropertyFile(java.lang.String path,
java.lang.String property)
throws java.io.IOException
path - The relative path to the desired properties file.property - The name of the required property.java.io.IOException