Interface BundleFileLocatorHelper
-
- All Known Implementing Classes:
DefaultFileLocatorHelper
public interface BundleFileLocatorHelper
BundleFileLocatorHelperFrom a bundle to its location on the filesystem. Assumes the bundle is not a jar.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLASS_NAME
The name of the custom implementation for this interface in a fragment.static BundleFileLocatorHelper
DEFAULT
The default instance supports felix and equinox
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Enumeration<java.net.URL>
findEntries(org.osgi.framework.Bundle bundle, java.lang.String entryPath)
Helper method equivalent to Bundle#getEntry(String entryPath) except that it searches for entries in the fragments by using the findEntries method.java.io.File
getBundleInstallLocation(org.osgi.framework.Bundle bundle)
Works with equinox, felix, nuxeo and probably more.java.io.File
getFileInBundle(org.osgi.framework.Bundle bundle, java.lang.String path)
Locate a file inside a bundle.java.net.URL
getFileURL(java.net.URL url)
Only useful for equinox: on felix we get thefile://
url already.java.net.URL
getLocalURL(java.net.URL url)
Only useful for equinox: on felix we get thefile://
orjar://
url already.java.io.File[]
locateJarsInsideBundle(org.osgi.framework.Bundle bundle)
If the bundle is a jar, returns the jar.
-
-
-
Field Detail
-
CLASS_NAME
static final java.lang.String CLASS_NAME
The name of the custom implementation for this interface in a fragment.- See Also:
- Constant Field Values
-
DEFAULT
static final BundleFileLocatorHelper DEFAULT
The default instance supports felix and equinox
-
-
Method Detail
-
getBundleInstallLocation
java.io.File getBundleInstallLocation(org.osgi.framework.Bundle bundle) throws java.lang.Exception
Works with equinox, felix, nuxeo and probably more. Not exactly in the spirit of OSGi but quite necessary to support self-contained webapps and other situations.Currently only works with bundles that are not jar.
- Parameters:
bundle
- The bundle- Returns:
- Its installation location as a file.
- Throws:
java.lang.Exception
- if unable to get the install location
-
getFileInBundle
java.io.File getFileInBundle(org.osgi.framework.Bundle bundle, java.lang.String path) throws java.lang.Exception
Locate a file inside a bundle.- Parameters:
bundle
- the bundlepath
- the path- Returns:
- file the file object
- Throws:
java.lang.Exception
- if unable to get the file
-
locateJarsInsideBundle
java.io.File[] locateJarsInsideBundle(org.osgi.framework.Bundle bundle) throws java.lang.Exception
If the bundle is a jar, returns the jar. If the bundle is a folder, look inside it and search for jars that it returns.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.
- Parameters:
bundle
- the bundle- Returns:
- The jar(s) file that is either the bundle itself, either the jars embedded inside it.
- Throws:
java.lang.Exception
- if unable to locate the jars
-
findEntries
java.util.Enumeration<java.net.URL> findEntries(org.osgi.framework.Bundle bundle, java.lang.String entryPath)
Helper method equivalent to Bundle#getEntry(String entryPath) except that it searches for entries in the fragments by using the findEntries method.- Parameters:
bundle
- the bundleentryPath
- the entry path- Returns:
- null or all the entries found for that path.
-
getLocalURL
java.net.URL getLocalURL(java.net.URL url) throws java.lang.Exception
Only useful for equinox: on felix we get thefile://
orjar://
url already. Other OSGi implementations have not been testedGet a URL to the bundle entry that uses a common protocol (i.e.
file:
jar:
orhttp:
etc.).- Parameters:
url
- the url- Returns:
- a URL to the bundle entry that uses a common protocol
- Throws:
java.lang.Exception
- if unable to get the local url
-
getFileURL
java.net.URL getFileURL(java.net.URL url) throws java.lang.Exception
Only useful for equinox: on felix we get thefile://
url already. Other OSGi implementations have not been testedGet 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.- Parameters:
url
- the url- Returns:
- a URL to the content of the bundle entry that uses the file: protocol
- Throws:
java.lang.Exception
- if unable to get the file url
-
-