public class BundleUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FILE_SCHEMA |
static String |
REFERENCE_FILE_SCHEMA |
static String |
REFERENCE_SCHEME |
Constructor and Description |
---|
BundleUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canStart(org.osgi.framework.Bundle bundle)
If the bundle fulfills the conditions below, it could be started
a.
|
static boolean |
canStop(org.osgi.framework.Bundle bundle)
If the bundle fulfills the conditions below, it could be stopped
a.
|
static boolean |
canUninstall(org.osgi.framework.Bundle bundle)
If the bundle fulfills the conditions below, it could be un-installed
a.
|
static org.osgi.framework.Bundle |
getBundle(ClassLoader classLoader,
boolean unwrap)
Returns bundle (if any) associated with the classloader.
|
static org.osgi.framework.Bundle |
getContextBundle(boolean unwrap)
Returns bundle (if any) associated with current thread's context classloader.
|
static URL |
getEntry(org.osgi.framework.Bundle bundle,
String name)
1, If the bundle was installed with reference directory mode
return the file URL directly.
|
static Enumeration<String> |
getEntryPaths(org.osgi.framework.Bundle bundle,
String name)
Works like
Bundle.getEntryPaths(String) but also returns paths
in attached fragment bundles. |
static URL |
getNestedEntry(org.osgi.framework.Bundle bundle,
String jarEntryName,
String subEntryName) |
static LinkedHashSet<org.osgi.framework.Bundle> |
getWiredBundles(org.osgi.framework.Bundle bundle) |
static LinkedHashSet<org.osgi.framework.Bundle> |
getWiredBundles(org.osgi.service.packageadmin.PackageAdmin packageAdmin,
org.osgi.framework.Bundle bundle) |
static boolean |
isFragment(org.osgi.framework.Bundle bundle) |
static boolean |
isResolved(org.osgi.framework.Bundle bundle)
Based on the constant field values, if it is bigger than the RESOLVED status value, the bundle has been resolved by the framework
|
static void |
resolve(org.osgi.framework.Bundle bundle)
resolve method will try to load the Object.class, the behavior triggers a resolved request to the OSGI framework.
|
static File |
toFile(org.osgi.framework.Bundle bundle) |
static File |
toFile(String url)
Translate the reference:file:// style URL to the underlying file instance
|
static File |
toFile(URL url) |
static String |
toReferenceFileLocation(File file) |
static org.osgi.framework.Bundle |
unwrapBundle(org.osgi.framework.Bundle bundle)
If the given bundle is a
DelegatingBundle this function will return the main
application bundle backing the DelegatingBundle . |
public static final String REFERENCE_SCHEME
public static final String FILE_SCHEMA
public static final String REFERENCE_FILE_SCHEMA
public static boolean isResolved(org.osgi.framework.Bundle bundle)
bundle
- public static void resolve(org.osgi.framework.Bundle bundle)
bundle
- public static boolean canStart(org.osgi.framework.Bundle bundle)
bundle
- public static boolean canStop(org.osgi.framework.Bundle bundle)
bundle
- public static boolean canUninstall(org.osgi.framework.Bundle bundle)
bundle
- public static boolean isFragment(org.osgi.framework.Bundle bundle)
public static org.osgi.framework.Bundle getContextBundle(boolean unwrap)
public static org.osgi.framework.Bundle getBundle(ClassLoader classLoader, boolean unwrap)
classLoader
- unwrap
- if true and if the bundle associated with the context classloader is a
DelegatingBundle
, this function will return the main application bundle
backing the DelegatingBundle
. Otherwise, the bundle associated with
the context classloader is returned as is. See BundleClassLoader.getBundle(boolean)
for more information.public static org.osgi.framework.Bundle unwrapBundle(org.osgi.framework.Bundle bundle)
DelegatingBundle
this function will return the main
application bundle backing the DelegatingBundle
. Otherwise, the bundle
passed in is returned as is.public static Enumeration<String> getEntryPaths(org.osgi.framework.Bundle bundle, String name)
Bundle.getEntryPaths(String)
but also returns paths
in attached fragment bundles.bundle
- name
- public static URL getEntry(org.osgi.framework.Bundle bundle, String name) throws MalformedURLException
Bundle.getEntry(String)
In addition to the searching abaove, it also checks attached fragment bundles for the given entry.bundle
- name
- MalformedURLException
public static URL getNestedEntry(org.osgi.framework.Bundle bundle, String jarEntryName, String subEntryName) throws MalformedURLException
MalformedURLException
public static File toFile(org.osgi.framework.Bundle bundle)
public static File toFile(String url)
url
- public static String toReferenceFileLocation(File file) throws IOException
IOException
public static LinkedHashSet<org.osgi.framework.Bundle> getWiredBundles(org.osgi.framework.Bundle bundle)
public static LinkedHashSet<org.osgi.framework.Bundle> getWiredBundles(org.osgi.service.packageadmin.PackageAdmin packageAdmin, org.osgi.framework.Bundle bundle)
Copyright © 2005–2021. All rights reserved.