|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object livespace.osgi.OsgiUtil
public final class OsgiUtil
OSGi utilty methods.
Method Summary | |
---|---|
static ClassLoader |
classLoaderFor(org.osgi.framework.Bundle bundle)
Determine the class loader for a bundle. |
static void |
copyBundleResourceToFile(org.osgi.framework.Bundle bundle,
String resource,
File file)
Copies a bundle resource to a specified file on the file system. |
static org.osgi.framework.Bundle |
findBundle(org.osgi.framework.BundleContext bundleContext,
String bundleName)
Return a bundle with a given name, or throw an exception if none found. |
static String |
getHostCategory()
Get the host's assigned category or "unknown" if not set. |
static String |
getHostName()
Get the local Livespace host's name. |
static String |
getIPAddress()
Get the local Livespace host's IP address. |
static String |
getShortHostName()
|
static ClassLoader |
installBundleClassLoader(Class<?> bundleClass)
Install the OSGi bundle class loader as the current thread's context class loader. |
static ClassLoader |
installBundleClassLoader(ClassLoader classLoader)
Install the OSGi bundle class loader as the current thread's context class loader. |
static InputStream |
openUrl(URL url)
Open an input stream on a URL. |
static org.osgi.framework.Bundle |
peekBundle(org.osgi.framework.BundleContext bundleContext,
String bundleName)
Return a bundle with a given name, or null if none found. |
static void |
restoreClassLoader(ClassLoader origLoader)
Reverse the effect of installBundleClassLoader(Class) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ClassLoader installBundleClassLoader(Class<?> bundleClass)
bundleClass
- A class that was loaded as part of the bundle.
restoreClassLoader(ClassLoader)
after calling
client code.restoreClassLoader(ClassLoader)
public static ClassLoader installBundleClassLoader(ClassLoader classLoader)
classLoader
- The class loader for classes in the bundle.
restoreClassLoader(ClassLoader)
after calling
client code.restoreClassLoader(ClassLoader)
public static void restoreClassLoader(ClassLoader origLoader)
installBundleClassLoader(Class)
.
origLoader
- The class loader returned by installBundleClassLoader.installBundleClassLoader(Class)
public static org.osgi.framework.Bundle peekBundle(org.osgi.framework.BundleContext bundleContext, String bundleName)
bundleContext
- Any valid bundle context.bundleName
- The bundle name.findBundle(BundleContext, String)
public static org.osgi.framework.Bundle findBundle(org.osgi.framework.BundleContext bundleContext, String bundleName) throws IllegalArgumentException
bundleContext
- Any valid bundle context.bundleName
- The bundle name.
IllegalArgumentException
- if no matching bundle found.peekBundle(BundleContext, String)
public static String getHostName() throws IOException, UnknownHostException
IOException
- if no host name or IP can be found for the
host. This could only really happen if the host is not
on a network: clients should use livespace.host.name in this
case.
UnknownHostException
public static String getIPAddress() throws IOException
IOException
- if no host IP can be found for the
host. This could only really happen if the host is not
on a network: clients should use livespace.host.ip in this
case.public static String getShortHostName() throws IOException, UnknownHostException
IOException
UnknownHostException
public static String getHostCategory()
public static InputStream openUrl(URL url) throws IOException
IOException
public static ClassLoader classLoaderFor(org.osgi.framework.Bundle bundle)
public static void copyBundleResourceToFile(org.osgi.framework.Bundle bundle, String resource, File file) throws FileNotFoundException, IOException
bundle
- the bundle that contains the resource to copyresource
- the name of the resource within the bundle that is to be
copiedfile
- the target file which the bundle resource should be copied to
FileNotFoundException
- If the target file is not found
IOException
- If there is a problem writing to the file or reading
the resource from the bundle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |