org.eclipse.osgi.framework.internal.core
Class BundleNativeCode

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.BundleNativeCode

public class BundleNativeCode
extends java.lang.Object

This class represents a description of native code. Native Code dependencies The Bundle-NativeCode header allows a bundle to carry the native code it needs, and make use of it when it is installed. The bundle must have RuntimePermission in order to run native code in the Framework. The value of the header must conform to the following syntax: Bundle-NativeCode: nativecode-clause ( , nativecode-clause)* nativecode-clause: nativepaths ( ; env-parameter )* nativepaths: nativepath ( ; nativepath )* env-parameter: ( processordef | osnamedef | osversiondef | languagedef ) processordef: processor= token osnamedef: osname= token osversiondef: osversion= token languagedef: language= token For example: Bundle-NativeCode: http.dll ; osname=Win95; processor=x86; language=en, libhttp.so; osname=Solaris; processor=sparc The Bundle-NativeCode header allows a bundle programmer to specify an environment, and to declare what native code libraries it carries for that specific environment. The environment is characterized by the following properties:

These properties should follow the conventions and values defined in the "Open Software Description" specification. The Framework uses the following algorithm to find the "best" matching native code clause:
  1. Pick the clauses with a matching processor and operating system with the one the Framework runs on. If no clause matches both the required processor and operating system, the bundle installation/activation fails. If only one clause matches, it can be used, otherwise, remaining steps are executed.
  2. Pick the clauses that best match the operating system version. If they match each other exactly, that clause is considered the best match. If there is only one clause with an exact match, it can be used. If there are more than one clause that matches the property, these clauses will be picked to perform the next step. Operating system versions are taken to be backward compatible. If there is no exact match in the clauses, clauses with operating system versions lower than the value specified in org.osgi.framework.osversion will be picked. If there is only one clause which has a compatible operating system version, it can be used. Otherwise, all clauses with compatible operating system versions will go through the next step. If no clause has a matching or compatible operating system version, pick the clause that does not have operating system version specified. If that is not possible, the bundle installation fails.
  3. Pick the clause that best matches the language. If more than one clause remains at that point, then the Framework is free to pick amongst them randomly. If no clauses have the exact match with the value of the property, pick the clause that does not have language specified. If that is not possible, the bundle installation fails.


Constructor Summary
protected BundleNativeCode(org.eclipse.osgi.util.ManifestElement element, AbstractBundle bundle)
          Constructor for BundleNativeCode.
 
Method Summary
protected  void addAttribute(java.lang.String key, java.lang.String value)
          addAttribute is used to add the specification-version string to the package description.
protected  void addPath(java.lang.String nativepath)
          addPath is used to add a new element to the list of native files.
 java.lang.String[] getPaths()
          Returns the native code paths.
 boolean matchFilter()
           
 int matchLanguage(java.lang.String language)
          Return the match value for the given language.
 Version matchOSVersion(Version version)
          Return the higest matching value for the given os version that is less than or equal to the given os version.
 int matchProcessorOSNameFilter(java.lang.String processor, java.lang.String osname)
          Return the match value for the given processor and os name.
 java.lang.String toString()
          Override toString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BundleNativeCode

protected BundleNativeCode(org.eclipse.osgi.util.ManifestElement element,
                           AbstractBundle bundle)
Constructor for BundleNativeCode. It reads bundle native code data from the manifest file.

Method Detail

getPaths

public java.lang.String[] getPaths()
Returns the native code paths.

Returns:
Vector of String code paths.

addPath

protected void addPath(java.lang.String nativepath)
addPath is used to add a new element to the list of native files.

Parameters:
nativepath - new native file

addAttribute

protected void addAttribute(java.lang.String key,
                            java.lang.String value)
addAttribute is used to add the specification-version string to the package description. It is the only key supported at this time.

Parameters:
key - attribute key name
value - attribute value name

toString

public java.lang.String toString()
Override toString. Return a String representation of this object

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

matchProcessorOSNameFilter

public int matchProcessorOSNameFilter(java.lang.String processor,
                                      java.lang.String osname)
Return the match value for the given processor and os name. A higher value indicates a better match.

Parameters:
processor - processor name to match against.
osname - os name to match against.
Returns:
match value

matchOSVersion

public Version matchOSVersion(Version version)
Return the higest matching value for the given os version that is less than or equal to the given os version.

Parameters:
version - os version to match against.
Returns:
version or null if no match.

matchLanguage

public int matchLanguage(java.lang.String language)
Return the match value for the given language. A higher value indicates a better match.

Parameters:
language - language name to match against.
Returns:
match value

matchFilter

public boolean matchFilter()