org.eclipse.osgi.framework.adaptor
Interface BundleData

All Known Implementing Classes:
BaseData

public interface BundleData

The BundleData represents a single bundle that is persistently stored by a FrameworkAdaptor. A BundleData creates the ClassLoader for a bundle, finds native libraries installed in the FrameworkAdaptor for the bundle, creates data files for the bundle, used to access bundle entries, manifest information, and getting and saving metadata.

Clients may implement this interface.

Since:
3.1

Field Summary
static int TYPE_BOOTCLASSPATH_EXTENSION
          The BundleData is for a bootclasspath extension bundle
static int TYPE_FRAGMENT
          The BundleData is for a fragment bundle
static int TYPE_FRAMEWORK_EXTENSION
          The BundleData is for a framework extension bundle
static int TYPE_SINGLETON
          The BundleData is for a singleton bundle
 
Method Summary
 void close()
          Close all resources for this BundleData
 BundleClassLoader createClassLoader(ClassLoaderDelegate delegate, BundleProtectionDomain domain, java.lang.String[] bundleclasspath)
          Creates the ClassLoader for the BundleData.
 java.lang.String findLibrary(java.lang.String libname)
          Returns the absolute path name of a native library.
 java.lang.String getActivator()
          Returns the Bundle-Activator for this BundleData as specified in the bundle manifest file.
 long getBundleID()
          Get the BundleData bundle ID.
 java.lang.String[] getClassPath()
          Returns the Bundle-ClassPath for this BundleData as specified in the bundle manifest file.
 java.io.File getDataFile(java.lang.String path)
          Return the bundle data directory.
 java.lang.String getDynamicImports()
          Returns the DynamicImport-Package for this BundleData as specified in the bundle manifest file.
 java.net.URL getEntry(java.lang.String path)
          Gets a URL to the bundle entry specified by path.
 java.util.Enumeration getEntryPaths(java.lang.String path)
          Gets all of the bundle entries that exist under the specified path.
 java.lang.String getExecutionEnvironment()
          Returns the Bundle-RequiredExecutionEnvironment for this BundleData as specified in the bundle manifest file.
 long getLastModified()
          Get the last time this BundleData was modified.
 java.lang.String getLocation()
          Get the BundleData Location.
 java.util.Dictionary getManifest()
          Return the Dictionary of manifest headers for the BundleData.
 int getStartLevel()
          Returns the start level metadata for this BundleData.
 int getStatus()
          Returns the status metadata for this BundleData.
 java.lang.String getSymbolicName()
          Returns the Bundle-SymbolicName for this BundleData as specified in the bundle manifest file.
 int getType()
          Returns the type of bundle this BundleData is for.
 Version getVersion()
          Returns the Bundle-Version for this BundleData as specified in the bundle manifest file.
 void installNativeCode(java.lang.String[] nativepaths)
          Installs the native code paths for this BundleData.
 boolean matchDNChain(java.lang.String pattern)
          Matches the distinguished name chains of a bundle's signers against a pattern of a distinguished name chain.
 void open()
          Open the BundleData.
 void save()
          Persistently stores all the metadata for this BundleData
 void setBundle(Bundle bundle)
          Sets the Bundle object for this BundleData.
 void setStartLevel(int value)
          Sets the start level metatdata for this BundleData.
 void setStatus(int value)
          Sets the status metadata for this BundleData.
 

Field Detail

TYPE_FRAGMENT

static final int TYPE_FRAGMENT
The BundleData is for a fragment bundle

See Also:
Constant Field Values

TYPE_FRAMEWORK_EXTENSION

static final int TYPE_FRAMEWORK_EXTENSION
The BundleData is for a framework extension bundle

See Also:
Constant Field Values

TYPE_BOOTCLASSPATH_EXTENSION

static final int TYPE_BOOTCLASSPATH_EXTENSION
The BundleData is for a bootclasspath extension bundle

See Also:
Constant Field Values

TYPE_SINGLETON

static final int TYPE_SINGLETON
The BundleData is for a singleton bundle

See Also:
Constant Field Values
Method Detail

createClassLoader

BundleClassLoader createClassLoader(ClassLoaderDelegate delegate,
                                    BundleProtectionDomain domain,
                                    java.lang.String[] bundleclasspath)
Creates the ClassLoader for the BundleData. The ClassLoader created must use the ClassLoaderDelegate to delegate class, resource and library loading. The delegate is responsible for finding any resource or classes imported by the bundle through an imported package or a required bundle.

The ProtectionDomain domain must be used by the Classloader when defining a class.

Parameters:
delegate - The ClassLoaderDelegate to delegate to.
domain - The BundleProtectionDomain to use when defining a class.
bundleclasspath - An array of bundle classpaths to use to create this classloader. This is specified by the Bundle-ClassPath manifest entry.
Returns:
The new ClassLoader for the BundleData.

getEntry

java.net.URL getEntry(java.lang.String path)
Gets a URL to the bundle entry specified by path. This method must not use the BundleClassLoader to find the bundle entry since the ClassLoader will delegate to find the resource.

Parameters:
path - The bundle entry path.
Returns:
A URL used to access the entry or null if the entry does not exist.
See Also:
Bundle.getEntry(String)

getEntryPaths

java.util.Enumeration getEntryPaths(java.lang.String path)
Gets all of the bundle entries that exist under the specified path. For example:

getEntryPaths("/META-INF")

This will return all entries from the /META-INF directory of the bundle.

Parameters:
path - The path to a directory in the bundle.
Returns:
An Enumeration of the entry paths or null if the specified path does not exist.
See Also:
Bundle.getEntryPaths(String path)

findLibrary

java.lang.String findLibrary(java.lang.String libname)
Returns the absolute path name of a native library. The BundleData ClassLoader invokes this method to locate the native libraries that belong to classes loaded from this BundleData. Returns null if the library does not exist in this BundleData.

Parameters:
libname - The name of the library to find the absolute path to.
Returns:
The absolute path name of the native library or null if the library does not exist.

installNativeCode

void installNativeCode(java.lang.String[] nativepaths)
                       throws BundleException
Installs the native code paths for this BundleData. Each element of nativepaths must be installed for lookup when findLibrary is called.

Parameters:
nativepaths - The array of native code paths to install for the bundle.
Throws:
BundleException - If any error occurs during install.

getDataFile

java.io.File getDataFile(java.lang.String path)
Return the bundle data directory. Attempt to create the directory if it does not exist.

Returns:
Bundle data directory or null if not supported.
See Also:
BundleContext.getDataFile(String)

getManifest

java.util.Dictionary getManifest()
                                 throws BundleException
Return the Dictionary of manifest headers for the BundleData.

Returns:
Dictionary that contains the Manifest headers for the BundleData.
Throws:
BundleException - if an error occurred while reading the bundle manifest data.

getBundleID

long getBundleID()
Get the BundleData bundle ID. This will be used as the bundle ID by the framework.

Returns:
The BundleData ID.

getLocation

java.lang.String getLocation()
Get the BundleData Location. This will be used as the bundle location by the framework.

Returns:
the BundleData location.

getLastModified

long getLastModified()
Get the last time this BundleData was modified.

Returns:
the last time this BundleData was modified

close

void close()
           throws java.io.IOException
Close all resources for this BundleData

Throws:
java.io.IOException - If an error occurs closing.

open

void open()
          throws java.io.IOException
Open the BundleData. This method will reopen the BundleData if it has been previously closed.

Throws:
java.io.IOException - If an error occurs opening.

setBundle

void setBundle(Bundle bundle)
Sets the Bundle object for this BundleData.

Parameters:
bundle - The Bundle Object for this BundleData.

getStartLevel

int getStartLevel()
Returns the start level metadata for this BundleData.

Returns:
the start level metadata for this BundleData.

getStatus

int getStatus()
Returns the status metadata for this BundleData. A value of 1 indicates that this bundle is started persistently. A value of 0 indicates that this bundle is not started persistently.

Returns:
the status metadata for this BundleData.

setStartLevel

void setStartLevel(int value)
Sets the start level metatdata for this BundleData. Metadata must be stored persistently when BundleData.save() is called.

Parameters:
value - the start level metadata

setStatus

void setStatus(int value)
Sets the status metadata for this BundleData. Metadata must be stored persistently when BundleData.save() is called.

Parameters:
value - the status metadata.

save

void save()
          throws java.io.IOException
Persistently stores all the metadata for this BundleData

Throws:
java.io.IOException

getSymbolicName

java.lang.String getSymbolicName()
Returns the Bundle-SymbolicName for this BundleData as specified in the bundle manifest file.

Returns:
the Bundle-SymbolicName for this BundleData.

getVersion

Version getVersion()
Returns the Bundle-Version for this BundleData as specified in the bundle manifest file.

Returns:
the Bundle-Version for this BundleData.

getType

int getType()
Returns the type of bundle this BundleData is for.

Returns:
returns the type of bundle this BundleData is for

getClassPath

java.lang.String[] getClassPath()
                                throws BundleException
Returns the Bundle-ClassPath for this BundleData as specified in the bundle manifest file.

Returns:
the classpath for this BundleData.
Throws:
BundleException

getActivator

java.lang.String getActivator()
Returns the Bundle-Activator for this BundleData as specified in the bundle manifest file.

Returns:
the Bundle-Activator for this BundleData.

getExecutionEnvironment

java.lang.String getExecutionEnvironment()
Returns the Bundle-RequiredExecutionEnvironment for this BundleData as specified in the bundle manifest file.

Returns:
the Bundle-RequiredExecutionEnvironment for this BundleData.

getDynamicImports

java.lang.String getDynamicImports()
Returns the DynamicImport-Package for this BundleData as specified in the bundle manifest file.

Returns:
the DynamicImport-Packaget for this BundleData.

matchDNChain

boolean matchDNChain(java.lang.String pattern)
Matches the distinguished name chains of a bundle's signers against a pattern of a distinguished name chain.

Parameters:
pattern - the pattern of distinguished name (DN) chains to match against the dnChain. Wildcards "*" can be used in three cases:
  1. As a DN. In this case, the DN will consist of just the "*". It will match zero or more DNs. For example, "cn=me,c=US;*;cn=you" will match "cn=me,c=US";cn=you" and "cn=me,c=US;cn=her,c=CA;cn=you".
  2. As a DN prefix. In this case, the DN must start with "*,". The wild card will match zero or more RDNs at the start of a DN. For example, "*,cn=me,c=US;cn=you" will match "cn=me,c=US";cn=you" and "ou=my org unit,o=my org,cn=me,c=US;cn=you"
  3. As a value. In this case the value of a name value pair in an RDN will be a "*". The wildcard will match any value for the given name. For example, "cn=*,c=US;cn=you" will match "cn=me,c=US";cn=you" and "cn=her,c=US;cn=you", but it will not match "ou=my org unit,c=US;cn=you". If the wildcard does not occur by itself in the value, it will not be used as a wildcard. In other words, "cn=m*,c=US;cn=you" represents the common name of "m*" not any common name starting with "m".
Returns:
true if a dnChain matches the pattern. A value of false is returned if bundle signing is not supported.
Throws:
java.lang.IllegalArgumentException