org.eclipse.osgi.baseadaptor
Class BaseData

java.lang.Object
  extended by org.eclipse.osgi.baseadaptor.BaseData
All Implemented Interfaces:
BundleData

public class BaseData
extends java.lang.Object
implements BundleData

The BundleData implementation used by the BaseAdaptor.

Since:
3.2
See Also:
BaseAdaptor, BundleData, StorageHook, ClassLoadingHook

Field Summary
protected  BundleFile bundleFile
           
protected  java.lang.String fileName
           
protected  java.util.Collection loadedNativeCode
           
protected  java.util.Dictionary manifest
           
 
Fields inherited from interface org.eclipse.osgi.framework.adaptor.BundleData
TYPE_BOOTCLASSPATH_EXTENSION, TYPE_EXTCLASSPATH_EXTENSION, TYPE_FRAGMENT, TYPE_FRAMEWORK_EXTENSION, TYPE_SINGLETON
 
Constructor Summary
BaseData(long id, BaseAdaptor adaptor)
          Constructs a new BaseData with the specified id for the specified adaptor
 
Method Summary
 void close()
          Close all resources for this BundleData
 BundleClassLoader createClassLoader(ClassLoaderDelegate delegate, BundleProtectionDomain domain, java.lang.String[] bundleclasspath)
          This method calls all the configured class loading hooks ClassLoadingHook.createClassLoader(ClassLoader, ClassLoaderDelegate, BundleProtectionDomain, BaseData, String[]) methods until on returns a non-null value.
 java.lang.String findLibrary(java.lang.String libname)
          This method calls each configured classloading hook ClassLoadingHook.findLibrary(BaseData, String) method until the first one returns a non-null value.
 java.lang.String getActivator()
          Returns the Bundle-Activator for this BundleData as specified in the bundle manifest file.
 BaseAdaptor getAdaptor()
          Returns the adaptor for this BaseData
 Bundle getBundle()
          Returns the bundle object of this BaseData
 BundleFile getBundleFile()
          Returns the BundleFile for this BaseData.
 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.lang.String getClassPathString()
           
 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.
 java.io.File getExtractFile(java.lang.String path)
          Gets called by BundleFile during BundleFile.getFile(String, boolean).
 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.
 StorageHook getStorageHook(java.lang.String key)
          Returns the storage hook which is keyed by the specified key
 StorageHook[] getStorageHooks()
          Returns all the storage hooks associated with this BaseData
 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 isDirty()
          Returns true if this bundledata is dirty
 boolean matchDNChain(java.lang.String pattern)
          This method calls each configured storage hook StorageHook.matchDNChain(String) method until one returns true.
 void open()
          Open the BundleData.
 void save()
          Persistently stores all the metadata for this BundleData
 void setActivator(java.lang.String activator)
          Sets the activator of this BaseData
 void setBundle(Bundle bundle)
          Sets the Bundle object for this BundleData.
 void setClassPathString(java.lang.String classpath)
           
 void setDirty(boolean dirty)
          Sets the dirty flag for this BaseData
 void setDynamicImports(java.lang.String dynamicImports)
          Sets the dynamic imports of this BaseData
 void setExecutionEnvironment(java.lang.String executionEnvironment)
          Sets the execution environment of this BaseData
 void setFileName(java.lang.String fileName)
          This is only used to support PDE source lookup.
 void setLastModified(long lastModified)
          Sets the last modified time stamp of this bundledata
 void setLocation(java.lang.String location)
          Sets the location of this bundledata
 void setStartLevel(int value)
          This method calls each configured storage hook StorageHook.forgetStartLevelChange(int) method.
 void setStatus(int value)
          This method calls each configured storage hook StorageHook.forgetStatusChange(int) method.
 void setStorageHooks(StorageHook[] storageHooks)
          Sets the instance storage hooks for this base data.
 void setSymbolicName(java.lang.String symbolicName)
          Sets the symbolic name of this BaseData
 void setType(int type)
          Sets the type of this BaseData
 void setVersion(Version version)
          Sets the version of this BaseData
 java.lang.String toString()
          Return a string representation of the bundle that can be used in debug messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bundleFile

protected BundleFile bundleFile

manifest

protected java.util.Dictionary manifest

fileName

protected java.lang.String fileName

loadedNativeCode

protected java.util.Collection loadedNativeCode
Constructor Detail

BaseData

public BaseData(long id,
                BaseAdaptor adaptor)
Constructs a new BaseData with the specified id for the specified adaptor

Parameters:
id - the id of the BaseData
adaptor - the adaptor of the BaseData
Method Detail

createClassLoader

public BundleClassLoader createClassLoader(ClassLoaderDelegate delegate,
                                           BundleProtectionDomain domain,
                                           java.lang.String[] bundleclasspath)
This method calls all the configured class loading hooks ClassLoadingHook.createClassLoader(ClassLoader, ClassLoaderDelegate, BundleProtectionDomain, BaseData, String[]) methods until on returns a non-null value. If none of the class loading hooks returns a non-null value then the default classloader implementation is used.

Specified by:
createClassLoader in interface BundleData
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.
See Also:
BundleData.createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[])

getEntry

public final java.net.URL getEntry(java.lang.String path)
Description copied from interface: BundleData
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.

Specified by:
getEntry in interface BundleData
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

public final java.util.Enumeration getEntryPaths(java.lang.String path)
Description copied from interface: BundleData
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.

Specified by:
getEntryPaths in interface BundleData
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

public java.lang.String findLibrary(java.lang.String libname)
This method calls each configured classloading hook ClassLoadingHook.findLibrary(BaseData, String) method until the first one returns a non-null value.

Specified by:
findLibrary in interface 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.
See Also:
BundleData.findLibrary(String)

installNativeCode

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

Specified by:
installNativeCode in interface BundleData
Parameters:
nativepaths - The array of native code paths to install for the bundle.
Throws:
BundleException - If any error occurs during install.

getDataFile

public java.io.File getDataFile(java.lang.String path)
Description copied from interface: BundleData
Return the bundle data directory. Attempt to create the directory if it does not exist.

Specified by:
getDataFile in interface BundleData
Returns:
Bundle data directory or null if not supported.
See Also:
BundleContext.getDataFile(String)

getManifest

public java.util.Dictionary getManifest()
                                 throws BundleException
Description copied from interface: BundleData
Return the Dictionary of manifest headers for the BundleData.

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

getBundleID

public long getBundleID()
Description copied from interface: BundleData
Get the BundleData bundle ID. This will be used as the bundle ID by the framework.

Specified by:
getBundleID in interface BundleData
Returns:
The BundleData ID.

getLocation

public final java.lang.String getLocation()
Description copied from interface: BundleData
Get the BundleData Location. This will be used as the bundle location by the framework.

Specified by:
getLocation in interface BundleData
Returns:
the BundleData location.

setLocation

public final void setLocation(java.lang.String location)
Sets the location of this bundledata

Parameters:
location - the location of this bundledata

getLastModified

public final long getLastModified()
Description copied from interface: BundleData
Get the last time this BundleData was modified.

Specified by:
getLastModified in interface BundleData
Returns:
the last time this BundleData was modified

setLastModified

public final void setLastModified(long lastModified)
Sets the last modified time stamp of this bundledata

Parameters:
lastModified - the last modified time stamp of this bundledata

close

public void close()
           throws java.io.IOException
Description copied from interface: BundleData
Close all resources for this BundleData

Specified by:
close in interface BundleData
Throws:
java.io.IOException - If an error occurs closing.

open

public void open()
          throws java.io.IOException
Description copied from interface: BundleData
Open the BundleData. This method will reopen the BundleData if it has been previously closed.

Specified by:
open in interface BundleData
Throws:
java.io.IOException - If an error occurs opening.

setBundle

public final void setBundle(Bundle bundle)
Description copied from interface: BundleData
Sets the Bundle object for this BundleData.

Specified by:
setBundle in interface BundleData
Parameters:
bundle - The Bundle Object for this BundleData.

getBundle

public final Bundle getBundle()
Returns the bundle object of this BaseData

Returns:
the bundle object of this BaseData

getStartLevel

public int getStartLevel()
Description copied from interface: BundleData
Returns the start level metadata for this BundleData.

Specified by:
getStartLevel in interface BundleData
Returns:
the start level metadata for this BundleData.

getStatus

public int getStatus()
Description copied from interface: BundleData
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.

Specified by:
getStatus in interface BundleData
Returns:
the status metadata for this BundleData.

setStartLevel

public void setStartLevel(int value)
This method calls each configured storage hook StorageHook.forgetStartLevelChange(int) method. If one returns true then this bundledata is not marked dirty.

Specified by:
setStartLevel in interface BundleData
Parameters:
value - the start level metadata
See Also:
BundleData.setStartLevel(int)

setStatus

public void setStatus(int value)
This method calls each configured storage hook StorageHook.forgetStatusChange(int) method. If one returns true then this bundledata is not marked dirty.

Specified by:
setStatus in interface BundleData
Parameters:
value - the status metadata.
See Also:
BundleData.setStatus(int)

save

public void save()
          throws java.io.IOException
Description copied from interface: BundleData
Persistently stores all the metadata for this BundleData

Specified by:
save in interface BundleData
Throws:
java.io.IOException

isDirty

public boolean isDirty()
Returns true if this bundledata is dirty

Returns:
true if this bundledata is dirty

setDirty

public void setDirty(boolean dirty)
Sets the dirty flag for this BaseData

Parameters:
dirty - the dirty flag

getSymbolicName

public final java.lang.String getSymbolicName()
Description copied from interface: BundleData
Returns the Bundle-SymbolicName for this BundleData as specified in the bundle manifest file.

Specified by:
getSymbolicName in interface BundleData
Returns:
the Bundle-SymbolicName for this BundleData.

setSymbolicName

public final void setSymbolicName(java.lang.String symbolicName)
Sets the symbolic name of this BaseData

Parameters:
symbolicName - the symbolic name

getVersion

public final Version getVersion()
Description copied from interface: BundleData
Returns the Bundle-Version for this BundleData as specified in the bundle manifest file.

Specified by:
getVersion in interface BundleData
Returns:
the Bundle-Version for this BundleData.

setVersion

public final void setVersion(Version version)
Sets the version of this BaseData

Parameters:
version - the version

getType

public final int getType()
Description copied from interface: BundleData
Returns the type of bundle this BundleData is for.

Specified by:
getType in interface BundleData
Returns:
returns the type of bundle this BundleData is for

setType

public final void setType(int type)
Sets the type of this BaseData

Parameters:
type - the type

getClassPath

public final java.lang.String[] getClassPath()
                                      throws BundleException
Description copied from interface: BundleData
Returns the Bundle-ClassPath for this BundleData as specified in the bundle manifest file.

Specified by:
getClassPath in interface BundleData
Returns:
the classpath for this BundleData.
Throws:
BundleException

getClassPathString

public java.lang.String getClassPathString()

setClassPathString

public void setClassPathString(java.lang.String classpath)

getActivator

public final java.lang.String getActivator()
Description copied from interface: BundleData
Returns the Bundle-Activator for this BundleData as specified in the bundle manifest file.

Specified by:
getActivator in interface BundleData
Returns:
the Bundle-Activator for this BundleData.

setActivator

public final void setActivator(java.lang.String activator)
Sets the activator of this BaseData

Parameters:
activator - the activator

getExecutionEnvironment

public final java.lang.String getExecutionEnvironment()
Description copied from interface: BundleData
Returns the Bundle-RequiredExecutionEnvironment for this BundleData as specified in the bundle manifest file.

Specified by:
getExecutionEnvironment in interface BundleData
Returns:
the Bundle-RequiredExecutionEnvironment for this BundleData.

setExecutionEnvironment

public void setExecutionEnvironment(java.lang.String executionEnvironment)
Sets the execution environment of this BaseData

Parameters:
executionEnvironment - the execution environment

getDynamicImports

public final java.lang.String getDynamicImports()
Description copied from interface: BundleData
Returns the DynamicImport-Package for this BundleData as specified in the bundle manifest file.

Specified by:
getDynamicImports in interface BundleData
Returns:
the DynamicImport-Packaget for this BundleData.

setDynamicImports

public void setDynamicImports(java.lang.String dynamicImports)
Sets the dynamic imports of this BaseData

Parameters:
dynamicImports - the dynamic imports

matchDNChain

public final boolean matchDNChain(java.lang.String pattern)
This method calls each configured storage hook StorageHook.matchDNChain(String) method until one returns true. If no configured storage hook returns true then false is returned.

Specified by:
matchDNChain in interface BundleData
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.
See Also:
BundleData.matchDNChain(String)

getAdaptor

public final BaseAdaptor getAdaptor()
Returns the adaptor for this BaseData

Returns:
the adaptor

getBundleFile

public BundleFile getBundleFile()
                         throws java.lang.IllegalArgumentException
Returns the BundleFile for this BaseData. The first time this method is called the configured storage BaseAdaptor.createBundleFile(Object, BaseData) method is called.

Returns:
the BundleFile
Throws:
java.lang.IllegalArgumentException

getStorageHook

public StorageHook getStorageHook(java.lang.String key)
Returns the storage hook which is keyed by the specified key

Parameters:
key - the key of the storage hook to get
Returns:
the storage hook which is keyed by the specified key

setStorageHooks

public void setStorageHooks(StorageHook[] storageHooks)
Sets the instance storage hooks for this base data. This is method may only be called once for the lifetime of the base data. Once set, the list of storage hooks remains constant.

Parameters:
storageHooks - the storage hook to add

getStorageHooks

public StorageHook[] getStorageHooks()
Returns all the storage hooks associated with this BaseData

Returns:
all the storage hooks associated with this BaseData

getExtractFile

public java.io.File getExtractFile(java.lang.String path)
Gets called by BundleFile during BundleFile.getFile(String, boolean). This method will allocate a File object where content of the specified path may be stored for the current generation of the base data. The returned File object may not exist if the content has not previously be stored.

Parameters:
path - the path to the content to extract from the base data
Returns:
a file object where content of the specified path may be stored.

setFileName

public void setFileName(java.lang.String fileName)
This is only used to support PDE source lookup. The field named "fileName" must be set for PDE to access the absolute path string.

Parameters:
fileName - an absolute path string to the base bundle file.

toString

public java.lang.String toString()
Return a string representation of the bundle that can be used in debug messages.

Overrides:
toString in class java.lang.Object
Returns:
String representation of the bundle