org.eclipse.jetty.osgi.boot.utils.internal
Class DefaultFileLocatorHelper

java.lang.Object
  extended by org.eclipse.jetty.osgi.boot.utils.internal.DefaultFileLocatorHelper
All Implemented Interfaces:
BundleFileLocatorHelper

public class DefaultFileLocatorHelper
extends Object
implements BundleFileLocatorHelper

From a bundle to its location on the filesystem. Assumes the bundle is not a jar.

Author:
hmalphettes

Field Summary
 
Fields inherited from interface org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper
CLASS_NAME, DEFAULT
 
Constructor Summary
DefaultFileLocatorHelper()
           
 
Method Summary
 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.
static URL getFileURL(URL url)
          Only useful for equinox: on felix we get the file:// url already.
static 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileLocatorHelper

public DefaultFileLocatorHelper()
Method Detail

getBundleInstallLocation

public File getBundleInstallLocation(org.osgi.framework.Bundle bundle)
                              throws 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.

Specified by:
getBundleInstallLocation in interface BundleFileLocatorHelper
Parameters:
bundle - The bundle
Returns:
Its installation location as a file.
Throws:
Exception

getFileInBundle

public File getFileInBundle(org.osgi.framework.Bundle bundle,
                            String path)
                     throws Exception
Locate a file inside a bundle.

Specified by:
getFileInBundle in interface BundleFileLocatorHelper
Parameters:
bundle -
path -
Returns:
file object
Throws:
Exception

findEntries

public 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.

Specified by:
findEntries in interface BundleFileLocatorHelper
Parameters:
bundle -
entryPath -
Returns:
null or all the entries found for that path.

locateJarsInsideBundle

public File[] locateJarsInsideBundle(org.osgi.framework.Bundle bundle)
                              throws 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.

Specified by:
locateJarsInsideBundle in interface BundleFileLocatorHelper
Parameters:
bundle -
Returns:
The jar(s) file that is either the bundle itself, either the jars embedded inside it.
Throws:
Exception

getLocalURL

public static URL getLocalURL(URL url)
Only useful for equinox: on felix we get the file:// or jar:// url already. Other OSGi implementations have not been tested

Get a URL to the bundle entry that uses a common protocol (i.e. file: jar: or http: etc.).

Returns:
a URL to the bundle entry that uses a common protocol

getFileURL

public static URL getFileURL(URL url)
Only useful for equinox: on felix we get the file:// url already. Other OSGi implementations have not been tested

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.

Returns:
a URL to the content of the bundle entry that uses the file: protocol



Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.