@Override public String[] getUnsatisfiedConstraints(BundleInfo bInfo) { URI realLocation = bInfo.getLocation(); BundleDescription description = getBundleByLocation(realLocation); StateHelper helper = platformAdmin.getStateHelper(); VersionConstraint[] constraints = helper.getUnsatisfiedConstraints(description); String[] ret = new String[constraints.length]; for (int i = 0; i < constraints.length; i++) ret[i] = constraints[i].toString(); return ret; }
/** * Lists all packages visible from the specified bundle * @param bundle bundle to list visible packages */ @Descriptor(ConsoleMsg.CONSOLE_HELP_VISIBLE_PACKAGES_COMMAND_DESCRIPTION) public void getPackages(@Descriptor(ConsoleMsg.CONSOLE_HELP_VISIBLE_PACKAGES_COMMAND_ARGUMENTS_DESCRIPTION) Bundle bundle) { PlatformAdmin platformAdmin = activator.getPlatformAdmin(); if (platformAdmin == null) return; BundleDescription bundleDescription = platformAdmin.getState(false).getBundle(bundle.getBundleId()); ExportPackageDescription[] exports = platformAdmin.getStateHelper().getVisiblePackages(bundleDescription, StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES); for (int i = 0; i < exports.length; i++) { System.out.println(exports[i] + ": " + platformAdmin.getStateHelper().getAccessCode(bundleDescription, exports[i])); //$NON-NLS-1$ } }
/** * Resolves the root errors for the given set of errors * * @param rerrors * @param collector * @return the resolved leaf set of problem messages */ private String[] resolveRootErrors(ResolverError[] rerrors) { TreeSet<String> collector = new TreeSet<>((o1, o2) -> (o1).compareTo(o2)); ResolverError error = null; VersionConstraint[] constraints = null; BundleDescription[] bundle = new BundleDescription[1]; for (ResolverError rerror : rerrors) { error = rerror; if (error.getType() != ResolverError.MISSING_REQUIRE_BUNDLE) { collector.add(error.toString()); } bundle[0] = error.getBundle(); constraints = bundle[0].getContainingState().getStateHelper().getUnsatisfiedLeaves(bundle); if (constraints.length == 0) { collector.add(error.toString()); } for (VersionConstraint constraint : constraints) { collector.add(constraint.toString()); } } return collector.toArray(new String[collector.size()]); }
/** * Returns all of the visible dependent components from the current state * * @param components * @return the listing of visible dependent components to the given ones * @throws CoreException */ public IApiComponent[] getVisibleDependentComponents(IApiComponent[] components) throws CoreException { ArrayList<BundleDescription> bundles = getBundleDescriptions(components); BundleDescription[] descs = getState().getStateHelper().getDependentBundles(bundles.toArray(new BundleDescription[bundles.size()])); HashSet<BundleDescription> visible = new HashSet<>(); ExportPackageDescription[] packages = null; for (BundleDescription desc : descs) { packages = getState().getStateHelper().getVisiblePackages(desc); for (ExportPackageDescription package1 : packages) { if (bundles.contains(package1.getSupplier())) { visible.add(desc); } } } return getApiComponents(visible.toArray(new BundleDescription[visible.size()])); }
private void addVisiblePackagesFromState(StateHelper helper, BundleDescription desc, Map<BundleDescription, ArrayList<AccessRule>> visiblePackages) { if (desc == null) return; ExportPackageDescription[] exports = helper.getVisiblePackages(desc); for (int i = 0; i < exports.length; i++) { BundleDescription exporter = exports[i].getExporter(); if (exporter == null) continue; ArrayList<AccessRule> list = visiblePackages.get(exporter); if (list == null) list = new ArrayList<AccessRule>(); AccessRule rule = getRule(helper, desc, exports[i]); if (!list.contains(rule)) list.add(rule); visiblePackages.put(exporter, list); } }
VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(bundle); ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(bundle); for (int i = 0; i < resolverErrors.length; i++) { System.out.println(getResolutionFailureMessage(unsatisfied[i])); VersionConstraint[] unsatisfiedLeaves = platformAdmin.getStateHelper().getUnsatisfiedLeaves(new BundleDescription[] {bundle}); boolean foundLeaf = false; for (int i = 0; i < unsatisfiedLeaves.length; i++) {
private Rule getRule(StateHelper helper, BundleDescription desc, ExportPackageDescription export) { Rule rule = new Rule(); rule.discouraged = helper.getAccessCode(desc, export) == StateHelper.ACCESS_DISCOURAGED; String name = export.getName(); rule.path = (name.equals(".")) ? new Path("*") : new Path(name.replaceAll("\\.", "/") + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ return rule; }
private void sortByDependencies(AbstractBundle[] bundles, int start, int end) { if (end - start <= 1) return; List<BundleDescription> descList = new ArrayList<BundleDescription>(end - start); List<AbstractBundle> missingDescs = new ArrayList<AbstractBundle>(0); for (int i = start; i < end; i++) { BundleDescription desc = bundles[i].getBundleDescription(); if (desc != null) descList.add(desc); else missingDescs.add(bundles[i]); } if (descList.size() <= 1) return; BundleDescription[] descriptions = descList.toArray(new BundleDescription[descList.size()]); framework.adaptor.getPlatformAdmin().getStateHelper().sortBundles(descriptions); for (int i = start; i < descriptions.length + start; i++) bundles[i] = framework.bundles.getBundle(descriptions[i - start].getBundleId()); if (missingDescs.size() > 0) { Iterator<AbstractBundle> missing = missingDescs.iterator(); for (int i = start + descriptions.length; i < end && missing.hasNext(); i++) bundles[i] = missing.next(); } }
private void addVisiblePackagesFromState(StateHelper helper, BundleDescription desc, Map<BundleDescription, ArrayList<Rule>> visiblePackages) { if (desc == null) return; ExportPackageDescription[] exports = helper.getVisiblePackages(desc); for (int i = 0; i < exports.length; i++) { BundleDescription exporter = exports[i].getExporter(); if (exporter == null) continue; ArrayList<Rule> list = visiblePackages.get(exporter); if (list == null) { list = new ArrayList<>(); visiblePackages.put(exporter, list); } Rule rule = getRule(helper, desc, exports[i]); if (!list.contains(rule)) list.add(rule); } }
VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles()); continue; FrameworkLogEntry[] logChildren = null; VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description); if (unsatisfied.length > 0) {
private Rule getRule(StateHelper helper, BundleDescription desc, ExportPackageDescription export) { Rule rule = new Rule(); rule.discouraged = helper.getAccessCode(desc, export) == StateHelper.ACCESS_DISCOURAGED; String name = export.getName(); rule.path = (name.equals(".")) ? new Path("*") : new Path(name.replaceAll("\\.", "/") + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ return rule; }
private void sortByDependencies(AbstractBundle[] bundles, int start, int end) { if (end - start <= 1) return; List<BundleDescription> descList = new ArrayList<BundleDescription>(end - start); List<AbstractBundle> missingDescs = new ArrayList<AbstractBundle>(0); for (int i = start; i < end; i++) { BundleDescription desc = bundles[i].getBundleDescription(); if (desc != null) descList.add(desc); else missingDescs.add(bundles[i]); } if (descList.size() <= 1) return; BundleDescription[] descriptions = descList.toArray(new BundleDescription[descList.size()]); framework.adaptor.getPlatformAdmin().getStateHelper().sortBundles(descriptions); for (int i = start; i < descriptions.length + start; i++) bundles[i] = framework.bundles.getBundle(descriptions[i - start].getBundleId()); if (missingDescs.size() > 0) { Iterator<AbstractBundle> missing = missingDescs.iterator(); for (int i = start + descriptions.length; i < end && missing.hasNext(); i++) bundles[i] = missing.next(); } }
public void _getPackages(CommandInterpreter intp) { String nextArg = intp.nextArgument(); if (nextArg == null) return; AbstractBundle bundle = getBundleFromToken(intp, nextArg, true); ServiceReference<?> ref = context.getServiceReference("org.eclipse.osgi.service.resolver.PlatformAdmin"); //$NON-NLS-1$ if (ref == null) return; PlatformAdmin platformAdmin = (PlatformAdmin) context.getService(ref); try { ExportPackageDescription[] exports = platformAdmin.getStateHelper().getVisiblePackages(bundle.getBundleDescription(), StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES); for (int i = 0; i < exports.length; i++) { intp.println(exports[i] + ": " + platformAdmin.getStateHelper().getAccessCode(bundle.getBundleDescription(), exports[i])); //$NON-NLS-1$ } } finally { context.ungetService(ref); } }
private void addVisiblePackagesFromState(StateHelper helper, BundleDescription desc, Map visiblePackages) { if (desc == null) return; ExportPackageDescription[] exports = helper.getVisiblePackages(desc); for (int i = 0; i < exports.length; i++) { BundleDescription exporter = exports[i].getExporter(); if (exporter == null) continue; ArrayList list = (ArrayList)visiblePackages.get(exporter); if (list == null) list = new ArrayList(); Rule rule = getRule(helper, desc, exports[i]); if (!list.contains(rule)) list.add(rule); visiblePackages.put(exporter, list); } }
VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles()); continue; FrameworkLogEntry[] logChildren = null; VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description); if (unsatisfied.length > 0) {
public String[] getUnsatisfiedConstraints(BundleInfo bInfo) { URI realLocation = bInfo.getLocation(); BundleDescription description = getBundleByLocation(realLocation); StateHelper helper = platformAdmin.getStateHelper(); VersionConstraint[] constraints = helper.getUnsatisfiedConstraints(description); String[] ret = new String[constraints.length]; for (int i = 0; i < constraints.length; i++) ret[i] = constraints[i].toString(); return ret; }
private AccessRule getRule(StateHelper helper, BundleDescription desc, ExportPackageDescription export) { boolean discouraged = helper.getAccessCode(desc, export) == StateHelper.ACCESS_DISCOURAGED; String name = export.getName(); String path = (name.equals(".")) ? "*" : name.replaceAll("\\.", "/") + "/*"; return new DefaultAccessRule(path, discouraged); }
private void writeStateDeprecated(StateImpl state, DataOutputStream out) throws IOException { out.write(StateReader.STATE_CACHE_VERSION); if (writePrefix(state, out)) return; out.writeLong(state.getTimeStamp()); // write the platform property keys String[] platformPropKeys = state.getPlatformPropertyKeys(); writePlatformProp(platformPropKeys, out); Dictionary<Object, Object>[] propSet = state.getPlatformProperties(); out.writeInt(propSet.length); for (int i = 0; i < propSet.length; i++) { Dictionary<Object, Object> props = propSet[i]; out.writeInt(platformPropKeys.length); for (int j = 0; j < platformPropKeys.length; j++) writePlatformProp(props.get(platformPropKeys[j]), out); } BundleDescription[] bundles = state.getBundles(); StateHelperImpl.getInstance().sortBundles(bundles); out.writeInt(bundles.length); if (bundles.length == 0) return; for (int i = 0; i < bundles.length; i++) writeBundleDescription(bundles[i], out, false); out.writeBoolean(state.isResolved()); // save the lazy data offset out.writeInt(out.size()); for (int i = 0; i < bundles.length; i++) writeBundleDescriptionLazyData(bundles[i], out); }
public void _getPackages(CommandInterpreter intp) { String nextArg = intp.nextArgument(); if (nextArg == null) return; AbstractBundle bundle = getBundleFromToken(intp, nextArg, true); ServiceReference<?> ref = context.getServiceReference("org.eclipse.osgi.service.resolver.PlatformAdmin"); //$NON-NLS-1$ if (ref == null) return; PlatformAdmin platformAdmin = (PlatformAdmin) context.getService(ref); try { ExportPackageDescription[] exports = platformAdmin.getStateHelper().getVisiblePackages(bundle.getBundleDescription(), StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES); for (int i = 0; i < exports.length; i++) { intp.println(exports[i] + ": " + platformAdmin.getStateHelper().getAccessCode(bundle.getBundleDescription(), exports[i])); //$NON-NLS-1$ } } finally { context.ungetService(ref); } }
private void addVisiblePackagesFromState(StateHelper helper, BundleDescription desc, Map<BundleDescription, ArrayList<AccessRule>> visiblePackages) { if (desc == null) return; ExportPackageDescription[] exports = helper.getVisiblePackages(desc, StateHelper.VISIBLE_INCLUDE_EE_PACKAGES); for (int i = 0; i < exports.length; i++) { BundleDescription exporter = exports[i].getExporter(); if (exporter == null) continue; ArrayList<AccessRule> list = visiblePackages.get(exporter); if (list == null) list = new ArrayList<>(); AccessRule rule = getRule(helper, desc, exports[i]); if (!list.contains(rule)) list.add(rule); visiblePackages.put(exporter, list); } }