org.knopflerfish.framework
Interface BundleArchive


public interface BundleArchive

Interface for managing bundle data.


Method Summary
 void close()
          Close archive and all its open files.
 java.util.Vector componentExists(java.lang.String component, boolean onlyFirst)
          Check if named entry exists in the bundle's classpath.
 java.util.Enumeration findResourcesPath(java.lang.String path)
          Returns an Enumeration of all the paths (String objects) to entries within the bundle whose longest sub-path matches the supplied path argument.
 java.lang.String getAttribute(java.lang.String key)
          Get an attribute from the manifest of a bundle.
 long getBundleId()
          Get bundle identifier for this bundle archive.
 java.lang.String getBundleLocation()
          Get bundle location for this bundle archive.
 java.security.cert.Certificate[] getCertificates()
          Get certificates associated with with bundle archive.
 byte[] getClassBytes(java.lang.Integer sub, java.lang.String component)
          Get a byte array containg the contents of named file from a bundle archive.
 java.util.List getFailedClassPathEntries()
          Get a list with all classpath entries we failed to locate.
 java.io.InputStream getInputStream(java.lang.String component, int ix)
          Get an specific InputStream to named entry inside a bundle.
 java.lang.String getJarLocation()
           
 long getLastModified()
           
 java.util.Hashtable getLocalizationEntries(java.lang.String localeFile)
          Gets all localization entries from this bundle.
 java.lang.String getNativeLibrary(java.lang.String libName)
          Extract native library from JAR.
 int getStartLevel()
          Get stored bundle start level.
 boolean getStartOnLaunchFlag()
          Get state of start-on-launch flag.
 HeaderDictionary getUnlocalizedAttributes()
           
 void invalidateCertificates()
          Invalidate certificates associated with with bundle archive.
 boolean isPersistent()
           
 void purge()
          Remove bundle archive from persistent storage.
 void setLastModified(long timemillisecs)
           
 void setPersistent(boolean b)
           
 void setStartLevel(int level)
          Set stored bundle start level.
 void setStartOnLaunchFlag(boolean value)
          Set state of start-on-launch flag.
 

Method Detail

getAttribute

java.lang.String getAttribute(java.lang.String key)
Get an attribute from the manifest of a bundle. Not localized

Parameters:
key - Name of attribute to get.
Returns:
A string with result or null if the entry doesn't exists.

getLocalizationEntries

java.util.Hashtable getLocalizationEntries(java.lang.String localeFile)
Gets all localization entries from this bundle. Will typically read the file OSGI-INF/bundle_<locale>.properties.

Parameters:
localeFile - Filename within archive for localization properties.
Returns:
null or a mapping of the entries.

getUnlocalizedAttributes

HeaderDictionary getUnlocalizedAttributes()

getBundleId

long getBundleId()
Get bundle identifier for this bundle archive.

Returns:
Bundle identifier.

getBundleLocation

java.lang.String getBundleLocation()
Get bundle location for this bundle archive.

Returns:
Bundle location.

getStartLevel

int getStartLevel()
Get stored bundle start level.


setStartLevel

void setStartLevel(int level)
                   throws java.io.IOException
Set stored bundle start level.

Throws:
java.io.IOException

setPersistent

void setPersistent(boolean b)
                   throws java.io.IOException
Throws:
java.io.IOException

isPersistent

boolean isPersistent()

getLastModified

long getLastModified()

setLastModified

void setLastModified(long timemillisecs)
                     throws java.io.IOException
Throws:
java.io.IOException

getClassBytes

byte[] getClassBytes(java.lang.Integer sub,
                     java.lang.String component)
                     throws java.io.IOException
Get a byte array containg the contents of named file from a bundle archive.

Parameters:
Integer - From which sub archive to get.
component - File to get.
Returns:
Byte array with contents of file or null if file doesn't exist.
Throws:
java.io.IOException - if failed to read jar entry.

componentExists

java.util.Vector componentExists(java.lang.String component,
                                 boolean onlyFirst)
Check if named entry exists in the bundle's classpath. Leading '/' is stripped.

Parameters:
component - Entry to get reference to.
onlyFirst - End search when we find first entry if this is true.
Returns:
Vector of classpath entry numbers, or null if it doesn't exist.

getInputStream

java.io.InputStream getInputStream(java.lang.String component,
                                   int ix)
Get an specific InputStream to named entry inside a bundle. Leading '/' is stripped.

Parameters:
component - Entry to get reference to.
ix - index of sub archives. A postive number is the classpath entry index. -1 means look in the main bundle.
Returns:
InputStream to entry or null if it doesn't exist.

getNativeLibrary

java.lang.String getNativeLibrary(java.lang.String libName)
Extract native library from JAR.

Parameters:
libName - Name of Jar file to get.
Returns:
A string with path to native library.

getStartOnLaunchFlag

boolean getStartOnLaunchFlag()
Get state of start-on-launch flag.

Returns:
Boolean value for start on launch flag.

setStartOnLaunchFlag

void setStartOnLaunchFlag(boolean value)
                          throws java.io.IOException
Set state of start-on-launch flag.

Parameters:
value - Boolean value for start on launch flag.
Throws:
java.io.IOException

purge

void purge()
Remove bundle archive from persistent storage.


close

void close()
Close archive and all its open files.


getFailedClassPathEntries

java.util.List getFailedClassPathEntries()
Get a list with all classpath entries we failed to locate.

Returns:
A List with all failed classpath entries, null if no failures.

findResourcesPath

java.util.Enumeration findResourcesPath(java.lang.String path)
Returns an Enumeration of all the paths (String objects) to entries within the bundle whose longest sub-path matches the supplied path argument.

Parameters:
name -
Returns:

getJarLocation

java.lang.String getJarLocation()
Returns:
the location of the cached bundle.

getCertificates

java.security.cert.Certificate[] getCertificates()
Get certificates associated with with bundle archive.

Returns:
All certificates or null if bundle is unsigned.

invalidateCertificates

void invalidateCertificates()
Invalidate certificates associated with with bundle archive.