Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.osgi.framework.internal.core
Class BundleNativeCode  view BundleNativeCode download BundleNativeCode.java

java.lang.Object
  extended byorg.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.


Nested Class Summary
(package private) static class BundleNativeCode.Attribute
          Extension of Vector for attributes.
 
Field Summary
private static AliasMapper aliasMapper
          The AliasMapper used to alias OS Names.
private  AbstractBundle bundle
          The Framework for this BundleNativeCode
private  java.lang.String filterString
          The filter attribute for this Native Code entry
private  BundleNativeCode.Attribute language
          The language attribute for this Native Code entry
private  BundleNativeCode.Attribute nativepaths
          The Native Code paths for the Native Code entry
private  BundleNativeCode.Attribute osname
          The osname attribute for this Native Code entry
private  BundleNativeCode.Attribute osversion
          The osversion attribute for this Native Code entry
private  BundleNativeCode.Attribute processor
          The processor attribute for this Native Code entry
 
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.
 org.eclipse.osgi.service.resolver.Version matchOSVersion(org.eclipse.osgi.service.resolver.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.
private  void setAttribute(org.eclipse.osgi.util.ManifestElement element, java.lang.String attribute)
           
 java.lang.String toString()
          Override toString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nativepaths

private BundleNativeCode.Attribute nativepaths
The Native Code paths for the Native Code entry


processor

private BundleNativeCode.Attribute processor
The processor attribute for this Native Code entry


osname

private BundleNativeCode.Attribute osname
The osname attribute for this Native Code entry


language

private BundleNativeCode.Attribute language
The language attribute for this Native Code entry


osversion

private BundleNativeCode.Attribute osversion
The osversion attribute for this Native Code entry


filterString

private java.lang.String filterString
The filter attribute for this Native Code entry


bundle

private AbstractBundle bundle
The Framework for this BundleNativeCode


aliasMapper

private static AliasMapper aliasMapper
The AliasMapper used to alias OS Names.

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

setAttribute

private void setAttribute(org.eclipse.osgi.util.ManifestElement element,
                          java.lang.String attribute)

getPaths

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


addPath

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


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.


toString

public java.lang.String toString()
Override toString. Return a String representation of this 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.


matchOSVersion

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


matchLanguage

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


matchFilter

public boolean matchFilter()