Java Code Examples for org.osgi.framework.Constants#RESOLUTION_MANDATORY
The following examples show how to use
org.osgi.framework.Constants#RESOLUTION_MANDATORY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImportPkg.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Create an import package entry. */ ImportPkg(ExportPkg p) { this.name = p.name; this.bpkgs = p.bpkgs; this.resolution = Constants.RESOLUTION_MANDATORY; this.bundleSymbolicName = null; if (p.version == Version.emptyVersion) { this.packageRange = null; } else { this.packageRange = new VersionRange(p.version.toString()); } this.bundleRange = null; this.attributes = p.attributes; // TODO, should we import unknown directives? final Map<String,String> dirs = new HashMap<String, String>(); final Filter filter = toFilter(); if (null!=filter) { dirs.put(Constants.FILTER_DIRECTIVE, filter.toString()); } this.directives = Collections.unmodifiableMap(dirs); this.parent = null; }
Example 2
Source File: ImportPkg.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Create an import package entry from manifest parser data. * * @param name the name of the package to be imported. * @param he the parsed import package statement. * @param b back link to the bundle revision owning this import declaration. * @param dynamic Set to true if this is a dynamic import package declaration. */ ImportPkg(final String name, final HeaderEntry he, final BundlePackages b, boolean dynamic) { this.bpkgs = b; this.name = name; if (name.startsWith("java.")) { throw new IllegalArgumentException("You can not import a java.* package"); } final Map<String, String> dirs = he.getDirectives(); final String res = dirs.get(Constants.RESOLUTION_DIRECTIVE); if (dynamic) { if (res != null) { throw new IllegalArgumentException("Directives not supported for " + "Dynamic-Import, found " + Constants.RESOLUTION_DIRECTIVE + ":=" +res); } this.resolution = RESOLUTION_DYNAMIC; } else { if (res != null) { if (Constants.RESOLUTION_OPTIONAL.equals(res)) { this.resolution = Constants.RESOLUTION_OPTIONAL; } else if (Constants.RESOLUTION_MANDATORY.equals(res)) { this.resolution = Constants.RESOLUTION_MANDATORY; } else { throw new IllegalArgumentException("Directive " + Constants.RESOLUTION_DIRECTIVE + ", unexpected value: " + res); } } else { this.resolution = Constants.RESOLUTION_MANDATORY; } } this.bundleSymbolicName = (String) he.getAttributes() .remove(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE); final String versionStr = (String) he.getAttributes() .remove(Constants.VERSION_ATTRIBUTE); final String specVersionStr = (String) he.getAttributes() .remove(PACKAGE_SPECIFICATION_VERSION); if (specVersionStr != null) { this.packageRange = new VersionRange(specVersionStr); if (versionStr != null && !this.packageRange.equals(new VersionRange(versionStr))) { throw new IllegalArgumentException("Both " + Constants.VERSION_ATTRIBUTE + " and " + PACKAGE_SPECIFICATION_VERSION + " are specified, but differs"); } } else if (versionStr != null) { this.packageRange = new VersionRange(versionStr); } else { this.packageRange = null; } final String rangeStr = (String) he.getAttributes() .remove(Constants.BUNDLE_VERSION_ATTRIBUTE); if (rangeStr != null) { this.bundleRange = new VersionRange(rangeStr); } else { this.bundleRange = null; } this.attributes = Collections.unmodifiableMap(he.getAttributes()); final Filter filter = toFilter(); if (null!=filter) { dirs.put(Constants.FILTER_DIRECTIVE, filter.toString()); } this.directives = Collections.unmodifiableMap(dirs); this.parent = null; }
Example 3
Source File: RequireBundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * A require bundle requirement. * * @param requestor * The bundle packages of the fragment host that requires a bundle. * @param he * The parsed require bundle header. */ RequireBundle(final BundlePackages requestor, final HeaderEntry he) { this.requestor = requestor; this.name = he.getKey(); final Map<String,String> dirs = he.getDirectives(); final String visibility = dirs.get(Constants.VISIBILITY_DIRECTIVE); if (visibility != null) { this.visibility = visibility.intern(); if (this.visibility!=Constants.VISIBILITY_PRIVATE && this.visibility!=Constants.VISIBILITY_REEXPORT ) { throw new IllegalArgumentException ("Invalid directive : '" +Constants.VISIBILITY_DIRECTIVE +":="+this.visibility +"' in manifest header '" +Constants.REQUIRE_BUNDLE +": " +this.name +"' of bundle with id " +this.requestor.bg.bundle.getBundleId() +" ("+this.requestor.bg.symbolicName+")" +". The value must be either '" +Constants.VISIBILITY_PRIVATE +"' or '" +Constants.VISIBILITY_REEXPORT +"'."); } } else { this.visibility = Constants.VISIBILITY_PRIVATE; } final String resolution = dirs.get(Constants.RESOLUTION_DIRECTIVE); if (resolution != null) { this.resolution = resolution.intern(); if (this.resolution!=Constants.RESOLUTION_MANDATORY && this.resolution!=Constants.RESOLUTION_OPTIONAL ) { throw new IllegalArgumentException ("Invalid directive : '" +Constants.RESOLUTION_DIRECTIVE +":="+this.resolution +"' in manifest header '" +Constants.REQUIRE_BUNDLE +": " +this.name +"' of bundle with id " +this.requestor.bg.bundle.getBundleId() +" ("+this.requestor.bg.symbolicName+")" +". The value must be either '" +Constants.RESOLUTION_MANDATORY +"' or '" +Constants.RESOLUTION_OPTIONAL +"'."); } } else { this.resolution = Constants.RESOLUTION_MANDATORY; } this.attributes = he.getAttributes(); final String range = (String) attributes.remove(Constants.BUNDLE_VERSION_ATTRIBUTE); if (range != null) { this.bundleRange = new VersionRange(range); } else { this.bundleRange = null; } final Filter filter = toFilter(); if (null!=filter) { dirs.put(Constants.FILTER_DIRECTIVE, filter.toString()); } this.directives = Collections.unmodifiableMap(dirs); }
Example 4
Source File: ImportPkg.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Check if resolution is mandatory. * * @return True if okay, otherwise false. */ boolean mustBeResolved() { return resolution == Constants.RESOLUTION_MANDATORY; }