org.eclipse.osgi.baseadaptor
Class BaseData

java.lang.Object
  extended by org.eclipse.osgi.baseadaptor.BaseData
All Implemented Interfaces:
BundleData, BundleReference
Direct Known Subclasses:
SystemBundleData

public class BaseData
extends 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  String fileName
           
protected  Collection<String> loadedNativeCode
           
protected  Dictionary<String,String> manifest
           
 
Fields inherited from interface org.eclipse.osgi.framework.adaptor.BundleData
TYPE_BOOTCLASSPATH_EXTENSION, TYPE_COMPOSITEBUNDLE, TYPE_EXTCLASSPATH_EXTENSION, TYPE_FRAGMENT, TYPE_FRAMEWORK_EXTENSION, TYPE_SINGLETON, TYPE_SURROGATEBUNDLE
 
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, 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.
 String findLibrary(String libname)
          This method calls each configured classloading hook ClassLoadingHook.findLibrary(BaseData, String) method until the first one returns a non-null value.
 Enumeration<URL> findLocalResources(String path)
          Finds local resources by searching the class path of this bundle data.
 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.
 BundleFile getBundleFile(Object content, boolean base)
           
 long getBundleID()
          Get the BundleData bundle ID.
 String[] getClassPath()
          Returns the Bundle-ClassPath for this BundleData as specified in the bundle manifest file.
 String getClassPathString()
           
 File getDataFile(String path)
          Return the bundle data directory.
 String getDynamicImports()
          Returns the DynamicImport-Package for this BundleData as specified in the bundle manifest file.
 URL getEntry(String path)
          Gets a URL to the bundle entry specified by path.
 Enumeration<String> getEntryPaths(String path)
          Gets all of the bundle entries that exist under the specified path.
 String getExecutionEnvironment()
          Returns the Bundle-RequiredExecutionEnvironment for this BundleData as specified in the bundle manifest file.
 File getExtractFile(String path)
          Gets called by BundleFile during BundleFile.getFile(String, boolean).
 long getLastModified()
          Get the last time this BundleData was modified.
 String getLocation()
          Get the BundleData Location.
 Dictionary<String,String> 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(String key)
          Returns the storage hook which is keyed by the specified key
 StorageHook[] getStorageHooks()
          Returns all the storage hooks associated with this BaseData
 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(String[] nativepaths)
          Installs the native code paths for this BundleData.
 boolean isDirty()
          Returns true if this bundledata is dirty
 void open()
          Open the BundleData.
 void save()
          Persistently stores all the metadata for this BundleData
 void setActivator(String activator)
          Sets the activator of this BaseData
 void setBundle(Bundle bundle)
          Sets the Bundle object for this BundleData.
 void setBundleFile(Object content, BundleFile bundleFile)
           
 void setClassPathString(String classpath)
           
 void setDirty(boolean dirty)
          Sets the dirty flag for this BaseData
 void setDynamicImports(String dynamicImports)
          Sets the dynamic imports of this BaseData
 void setExecutionEnvironment(String executionEnvironment)
          Sets the execution environment of this BaseData
 void setFileName(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(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(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
 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 Dictionary<String,String> manifest

fileName

protected String fileName

loadedNativeCode

protected Collection<String> 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,
                                           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 URL getEntry(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 Enumeration<String> getEntryPaths(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 String findLibrary(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(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 File getDataFile(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 Dictionary<String,String> 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 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(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 IOException
Description copied from interface: BundleData
Close all resources for this BundleData

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

open

public void open()
          throws 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:
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

Specified by:
getBundle in interface BundleReference
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 IOException
Description copied from interface: BundleData
Persistently stores all the metadata for this BundleData

Specified by:
save in interface BundleData
Throws:
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 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(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 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 String getClassPathString()

setClassPathString

public void setClassPathString(String classpath)

getActivator

public final 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(String activator)
Sets the activator of this BaseData

Parameters:
activator - the activator

getExecutionEnvironment

public final 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(String executionEnvironment)
Sets the execution environment of this BaseData

Parameters:
executionEnvironment - the execution environment

getDynamicImports

public final 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(String dynamicImports)
Sets the dynamic imports of this BaseData

Parameters:
dynamicImports - the dynamic imports

getAdaptor

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

Returns:
the adaptor

getBundleFile

public BundleFile getBundleFile()
                         throws 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:
IllegalArgumentException

getBundleFile

public BundleFile getBundleFile(Object content,
                                boolean base)

setBundleFile

public void setBundleFile(Object content,
                          BundleFile bundleFile)

getStorageHook

public StorageHook getStorageHook(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 File getExtractFile(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(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 String toString()
Return a string representation of the bundle that can be used in debug messages.

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

findLocalResources

public Enumeration<URL> findLocalResources(String path)
Description copied from interface: BundleData
Finds local resources by searching the class path of this bundle data.

Specified by:
findLocalResources in interface BundleData
Parameters:
path - the requested resource name.
Returns:
the requested enumeration of resource URLs or null if the resource does not exist


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.