private String formatBundleName(BundleDescription b) { String label = b.getSymbolicName(); if (label == null || label.length() == 0) label = b.toString(); else label = label + "_" + b.getVersion(); //$NON-NLS-1$ return label; } }
private String formatBundleName(BundleDescription b) { String label = b.getSymbolicName(); if (label == null || label.length() == 0) label = b.toString(); else label = label + "_" + b.getVersion(); //$NON-NLS-1$ return label; } }
private String formatBundleName(BundleDescription b) { String label = b.getSymbolicName(); if (label == null || label.length() == 0) label = b.toString(); else label = label + "_" + b.getVersion(); //$NON-NLS-1$ return label; }
public String toDebugString(State state) { StringBuilder sb = new StringBuilder("Resolved OSGi state\n"); for (BundleDescription otherBundle : state.getBundles()) { if (!otherBundle.isResolved()) { sb.append("NOT "); } sb.append("RESOLVED "); sb.append(otherBundle.toString()).append(" : ").append(otherBundle.getLocation()); sb.append('\n'); for (ResolverError error : state.getResolverErrors(otherBundle)) { sb.append('\t').append(error.toString()).append('\n'); } } return sb.toString(); }
@Override public String toString() { if (fBundleDescription != null) { try { StringBuilder buffer = new StringBuilder(); buffer.append(fBundleDescription.toString()); buffer.append(" - "); //$NON-NLS-1$ buffer.append("[fragment: ").append(isFragment()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("[host: ").append(fBundleDescription.getFragments().length > 0).append("] "); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("[system bundle: ").append(isSystemComponent()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("[source bundle: ").append(isSourceComponent()).append("] "); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("[dev bundle: ").append(fWorkspaceBinary).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ return buffer.toString(); } catch (CoreException ce) { // ignore } } else { StringBuilder buffer = new StringBuilder(); buffer.append("Un-initialized Bundle Component"); //$NON-NLS-1$ buffer.append("[location: ").append(fLocation).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append("[dev bundle: ").append(fWorkspaceBinary).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ return buffer.toString(); } return super.toString(); }
private void hackImportPackageManifestHeader(final BundleDescription bundleDescription, final List<BundleCapability> availableCapabilities, final Attributes mainAttributes) { StringBuilder hackedImportPackageSB = new StringBuilder(); ImportPackageSpecification[] allImports = bundleDescription.getImportPackages(); for (ImportPackageSpecification importPackage : allImports) { if (hackedImportPackageSB.length() > 0) { hackedImportPackageSB.append(","); } hackedImportPackageSB.append(importPackage.getName()).append(";version=\"") .append(importPackage.getVersionRange()).append("\""); boolean optional = Constants.RESOLUTION_OPTIONAL.equals(importPackage .getDirective(Constants.RESOLUTION_DIRECTIVE)); if (optional || !requirementSatisfiable(importPackage.getRequirement(), availableCapabilities)) { if (!optional) { LOGGER.info( "[HACK]: Making Import-Package optional in bundle " + bundleDescription.toString() + ": " + hackedImportPackageSB.toString()); } hackedImportPackageSB.append(";").append(Constants.RESOLUTION_DIRECTIVE).append(":=") .append("\"") .append(Constants.RESOLUTION_OPTIONAL).append("\""); } } if (hackedImportPackageSB.length() > 0) { mainAttributes.putValue(Constants.IMPORT_PACKAGE, hackedImportPackageSB.toString()); } }
public String toString() { if (state == null) return null; StringBuffer sb = new StringBuffer(); BundleDescription[] bundleDescriptions = state.getBundles(); for (int i = 0; i < bundleDescriptions.length; i++) { sb.append(bundleDescriptions[i].getBundleId() + ":"); //$NON-NLS-1$ sb.append(bundleDescriptions[i].toString() + "("); //$NON-NLS-1$ sb.append(bundleDescriptions[i].isResolved() + ")"); //$NON-NLS-1$ String[] ees = bundleDescriptions[i].getExecutionEnvironments(); for (int j = 0; j < ees.length; j++) sb.append(ees[j] + " "); //$NON-NLS-1$ sb.append("\n"); //$NON-NLS-1$ } sb.append("PlatformProperties:\n"); //$NON-NLS-1$ Dictionary[] dics = state.getPlatformProperties(); for (int i = 0; i < dics.length; i++) { for (Enumeration enumeration = dics[i].keys(); enumeration.hasMoreElements();) { String key = (String) enumeration.nextElement(); String value = (String) dics[i].get(key); sb.append(" (" + key + "," + value + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } sb.append("\n"); //$NON-NLS-1$ return sb.toString(); }
private void hackRequireBundleManifestHeader(final BundleDescription bundleDescription, final List<BundleCapability> availableCapabilities, final Attributes mainAttributes) { StringBuilder hackedRequireBundleSB = new StringBuilder(); BundleSpecification[] requiredBundles = bundleDescription.getRequiredBundles(); for (BundleSpecification requiredBundle : requiredBundles) { if (hackedRequireBundleSB.length() > 0) { hackedRequireBundleSB.append(","); } hackedRequireBundleSB.append(requiredBundle.getName() + ";bundle-version=\"" + requiredBundle.getVersionRange() + "\""); if (requiredBundle.isOptional() || !requirementSatisfiable(requiredBundle.getRequirement(), availableCapabilities)) { if (!requiredBundle.isOptional()) { LOGGER.info( "[HACK]: Making Require-Bundle optional in bundle " + bundleDescription.toString() + ": " + hackedRequireBundleSB.toString()); } hackedRequireBundleSB.append(";").append(Constants.RESOLUTION_DIRECTIVE).append(":=") .append("\"") .append(Constants.RESOLUTION_OPTIONAL).append("\""); } } if (hackedRequireBundleSB.length() > 0) { mainAttributes.putValue(Constants.REQUIRE_BUNDLE, hackedRequireBundleSB.toString()); } }
@Override public String toString() { if (state == null) return null; StringBuffer sb = new StringBuffer(); BundleDescription[] bundleDescriptions = state.getBundles(); for (int i = 0; i < bundleDescriptions.length; i++) { sb.append(bundleDescriptions[i].getBundleId() + ":"); //$NON-NLS-1$ sb.append(bundleDescriptions[i].toString() + "("); //$NON-NLS-1$ sb.append(bundleDescriptions[i].isResolved() + ")"); //$NON-NLS-1$ String[] ees = bundleDescriptions[i].getExecutionEnvironments(); for (int j = 0; j < ees.length; j++) sb.append(ees[j] + " "); //$NON-NLS-1$ sb.append("\n"); //$NON-NLS-1$ } sb.append("PlatformProperties:\n"); //$NON-NLS-1$ @SuppressWarnings("rawtypes") Dictionary[] dics = state.getPlatformProperties(); for (int i = 0; i < dics.length; i++) { // don't disable this warning because it will cause build-time warning. // see bug 423628 and 423625. for (Enumeration<String> enumeration = dics[i].keys(); enumeration.hasMoreElements();) { String key = enumeration.nextElement(); String value = (String) dics[i].get(key); sb.append(" (" + key + "," + value + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } sb.append("\n"); //$NON-NLS-1$ return sb.toString(); }
boolean basicAddBundle(BundleDescription description) { synchronized (this.monitor) { StateImpl origState = (StateImpl) description.getContainingState(); if (origState != null && origState != this) { if (origState.removalPendings.contains(description)) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_PENDING_REMOVE_STATE, description.toString())); if (origState.getBundle(description.getBundleId()) == description) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_IN_OTHER_STATE, description.toString())); } ((BundleDescriptionImpl) description).setContainingState(this); ((BundleDescriptionImpl) description).setStateBit(BundleDescriptionImpl.REMOVAL_PENDING, false); if (bundleDescriptions.add((BundleDescriptionImpl) description)) { if (description.getBundleId() > getHighestBundleId()) highestBundleId = description.getBundleId(); return true; } return false; } }
if (!optional && !requirementSatisfiable(declaredRequirement, availableCapabilities)) { LOGGER.info( "[HACK]: Making Require-Capability optional in bundle " + bundleDescription.toString() + ": " + declaredRequirement.toString()); directives = new HashMap<String, String>(directives);
boolean basicAddBundle(BundleDescription description) { synchronized (this.monitor) { StateImpl origState = (StateImpl) description.getContainingState(); if (origState != null && origState != this) { if (origState.removalPendings.contains(description)) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_PENDING_REMOVE_STATE, description.toString())); if (origState.getBundle(description.getBundleId()) == description) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_IN_OTHER_STATE, description.toString())); } ((BundleDescriptionImpl) description).setContainingState(this); ((BundleDescriptionImpl) description).setStateBit(BundleDescriptionImpl.REMOVAL_PENDING, false); if (bundleDescriptions.add((BundleDescriptionImpl) description)) { if (description.getBundleId() > getHighestBundleId()) highestBundleId = description.getBundleId(); return true; } return false; } }
boolean basicAddBundle(BundleDescription description) { synchronized (this.monitor) { StateImpl origState = (StateImpl) description.getContainingState(); if (origState != null && origState != this) { if (origState.removalPendings.contains(description)) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_PENDING_REMOVE_STATE, description.toString())); if (origState.getBundle(description.getBundleId()) == description) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_IN_OTHER_STATE, description.toString())); } ((BundleDescriptionImpl) description).setContainingState(this); ((BundleDescriptionImpl) description).setStateBit(BundleDescriptionImpl.REMOVAL_PENDING, false); if (bundleDescriptions.add((BundleDescriptionImpl) description)) { if (description.getBundleId() > getHighestBundleId()) highestBundleId = description.getBundleId(); return true; } return false; } }
boolean basicAddBundle(BundleDescription description) { synchronized (this.monitor) { StateImpl origState = (StateImpl) description.getContainingState(); if (origState != null && origState != this) { if (origState.removalPendings.contains(description)) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_PENDING_REMOVE_STATE, description.toString())); if (origState.getBundle(description.getBundleId()) == description) throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_IN_OTHER_STATE, description.toString())); } ((BundleDescriptionImpl) description).setContainingState(this); ((BundleDescriptionImpl) description).setStateBit(BundleDescriptionImpl.REMOVAL_PENDING, false); if (add(description, bundleDescriptions, false)) { if (description.getBundleId() > getHighestBundleId()) highestBundleId = description.getBundleId(); addBundleNameCacheEntry(description); return true; } return false; } }
sortedMap.put(bundle.toString(), bundle);
public void addBundle(State state, long id, File bundleLocation, Dictionary<String, String> mf, boolean override) throws BundleException { BundleDescription descriptor = factory.createBundleDescription(state, mf, getNormalizedPath(bundleLocation), id); if (override) { BundleDescription[] conflicts = state.getBundles(descriptor.getSymbolicName()); if (conflicts != null) { for (BundleDescription conflict : conflicts) { state.removeBundle(conflict); logger.warn( conflict.toString() + " has been replaced by another bundle with the same symbolic name " + descriptor.toString()); } } } state.addBundle(descriptor); }
private ResolverBundle pickOneToResolve(Collection<ResolverBundle> pickOneToResolve) { ResolverBundle selectedVersion = null; for (ResolverBundle singleton : pickOneToResolve) { if (selectedVersion == null) selectedVersion = singleton; boolean higherVersion = selectionPolicy != null ? selectionPolicy.compare(selectedVersion.getBundleDescription(), singleton.getBundleDescription()) > 0 : selectedVersion.getVersion().compareTo(singleton.getVersion()) < 0; if (higherVersion) selectedVersion = singleton; } for (ResolverBundle singleton : pickOneToResolve) { if (singleton != selectedVersion) { singleton.setResolvable(false); state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, selectedVersion.getBundleDescription().toString(), null); } } return selectedVersion; }
private ResolverBundle pickOneToResolve(Collection<ResolverBundle> pickOneToResolve) { ResolverBundle selectedVersion = null; for (ResolverBundle singleton : pickOneToResolve) { if (selectedVersion == null) selectedVersion = singleton; boolean higherVersion = selectionPolicy != null ? selectionPolicy.compare(selectedVersion.getBundleDescription(), singleton.getBundleDescription()) > 0 : selectedVersion.getVersion().compareTo(singleton.getVersion()) < 0; if (higherVersion) selectedVersion = singleton; } for (ResolverBundle singleton : pickOneToResolve) { if (singleton != selectedVersion) { singleton.setResolvable(false); state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, selectedVersion.getBundleDescription().toString(), null); } } return selectedVersion; }
private ResolverBundle pickOneToResolve(Collection<ResolverBundle> pickOneToResolve) { ResolverBundle selectedVersion = null; for (ResolverBundle singleton : pickOneToResolve) { if (selectedVersion == null) selectedVersion = singleton; boolean higherVersion = selectionPolicy != null ? selectionPolicy.compare(selectedVersion.getBundleDescription(), singleton.getBundleDescription()) > 0 : selectedVersion.getVersion().compareTo(singleton.getVersion()) < 0; if (higherVersion) selectedVersion = singleton; } for (ResolverBundle singleton : pickOneToResolve) { if (singleton != selectedVersion) { singleton.setResolvable(false); state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, selectedVersion.getBundleDescription().toString(), null); } } return selectedVersion; }
private ResolverBundle pickOneToResolve(Collection<ResolverBundle> pickOneToResolve) { ResolverBundle selectedVersion = null; for (ResolverBundle singleton : pickOneToResolve) { if (selectedVersion == null) selectedVersion = singleton; boolean higherVersion = selectionPolicy != null ? selectionPolicy.compare(selectedVersion.getBundleDescription(), singleton.getBundleDescription()) > 0 : selectedVersion.getVersion().compareTo(singleton.getVersion()) < 0; if (higherVersion) selectedVersion = singleton; } for (ResolverBundle singleton : pickOneToResolve) { if (singleton != selectedVersion) { singleton.setResolvable(false); state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, selectedVersion.getBundleDescription().toString(), null); } } return selectedVersion; }