Java Code Examples for org.osgi.framework.Constants#RESOLUTION_DIRECTIVE
The following examples show how to use
org.osgi.framework.Constants#RESOLUTION_DIRECTIVE .
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: BundlePackages.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Parse the dynamic import attribute */ void parseDynamicImports(final String s) { for (final HeaderEntry he : Util .parseManifestHeader(Constants.DYNAMICIMPORT_PACKAGE, s, false, true, false)) { if (he.getDirectives().containsKey(Constants.RESOLUTION_DIRECTIVE)) { throw new IllegalArgumentException(Constants.DYNAMICIMPORT_PACKAGE + " entry illegal contains a " + Constants.RESOLUTION_DIRECTIVE + " directive."); } ImportPkg tmpl = null; for (String key : he.getKeys()) { if (key.equals("*")) { key = EMPTY_STRING; } else if (key.endsWith(".*")) { key = key.substring(0, key.length() - 1); } else if (key.endsWith(".")) { throw new IllegalArgumentException(Constants.DYNAMICIMPORT_PACKAGE + " entry ends with '.': " + key); } else if (key.indexOf("*") != -1) { throw new IllegalArgumentException(Constants.DYNAMICIMPORT_PACKAGE + " entry contains a '*': " + key); } if (tmpl != null) { dImportPatterns.add(new ImportPkg(tmpl, key)); } else { tmpl = new ImportPkg(key, he, this, true); dImportPatterns.add(tmpl); } } } }
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); }