public class DefaultFileLocatorHelper extends Object implements BundleFileLocatorHelper
From a bundle to its location on the filesystem. Assumes the bundle is not a jar.
CLASS_NAME, DEFAULT| Constructor and Description |
|---|
DefaultFileLocatorHelper() |
| Modifier and Type | Method and Description |
|---|---|
Enumeration<URL> |
findEntries(org.osgi.framework.Bundle bundle,
String entryPath)
Helper method equivalent to Bundle#getEntry(String entryPath) except that
it searches for entries in the fragments by using the Bundle#findEntries
method.
|
File |
getBundleInstallLocation(org.osgi.framework.Bundle bundle)
Works with equinox, felix, nuxeo and probably more.
|
File |
getFileInBundle(org.osgi.framework.Bundle bundle,
String path)
Locate a file inside a bundle.
|
URL |
getFileURL(URL url)
Only useful for equinox: on felix we get the file:// url already.
|
URL |
getLocalURL(URL url)
Only useful for equinox: on felix we get the file:// or jar:// url
already.
|
File[] |
locateJarsInsideBundle(org.osgi.framework.Bundle bundle)
If the bundle is a jar, returns the jar.
|
static boolean |
match(String name,
String... names) |
public File getBundleInstallLocation(org.osgi.framework.Bundle bundle) throws Exception
getBundleInstallLocation in interface BundleFileLocatorHelperbundle - The bundleException - if unable to get the bundle install locationpublic File getFileInBundle(org.osgi.framework.Bundle bundle, String path) throws Exception
getFileInBundle in interface BundleFileLocatorHelperbundle - the bundlepath - the pathException - if unable to get the file in the bundlepublic Enumeration<URL> findEntries(org.osgi.framework.Bundle bundle, String entryPath)
findEntries in interface BundleFileLocatorHelperbundle - the bundleentryPath - the entry pathpublic File[] locateJarsInsideBundle(org.osgi.framework.Bundle bundle) throws Exception
Good enough for our purpose (TldLocationsCache when it scans for tld files inside jars alone. In fact we only support the second situation for development purpose where the bundle was imported in pde and the classes kept in a jar.
locateJarsInsideBundle in interface BundleFileLocatorHelperbundle - the bundleException - if unable to locate the jarspublic URL getLocalURL(URL url) throws Exception
Get a URL to the bundle entry that uses a common protocol (i.e. file: jar: or http: etc.).
getLocalURL in interface BundleFileLocatorHelperurl - the urlException - if unable to get the local urlpublic URL getFileURL(URL url) throws Exception
Get a URL to the content of the bundle entry that uses the file: protocol. The content of the bundle entry may be downloaded or extracted to the local file system in order to create a file: URL.
getFileURL in interface BundleFileLocatorHelperurl - the urlException - if unable to get the file urlCopyright © 1995–2017 Webtide. All rights reserved.