Interface ResolutionReport


public interface ResolutionReport
A resolution report is associated with a single resolve process. Entries contained in a resolution report will contain entries for all resources that were attempted to be resolved in a single resolve process. Resolution reports are gathered by a special type of ResolverHook which implements the report ResolutionReport.Listener interface. The following example demonstrates how to gather a resolution report for a list of bundles
 
 public static ResolutionReport getResolutionReport(Bundle[] bundles, BundleContext context) {
        DiagReportListener reportListener = new DiagReportListener(bundles);
        ServiceRegistration<ResolverHookFactory> hookReg = context.registerService(ResolverHookFactory.class,
                        reportListener, null);
        try {
                Bundle systemBundle = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
                FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
                frameworkWiring.resolveBundles(Arrays.asList(bundles));
                return reportListener.getReport();
        } finally {
                hookReg.unregister();
        }
 }
 
 private static class DiagReportListener implements ResolverHookFactory {
        private final Collection<BundleRevision> targetTriggers = new ArrayList<BundleRevision>();
        volatile ResolutionReport report = null;
 
        public DiagReportListener(Bundle[] bundles) {
                for (Bundle bundle : bundles) {
                        BundleRevision revision = bundle.adapt(BundleRevision.class);
                        if (revision != null && revision.getWiring() == null) {
                                targetTriggers.add(revision);
                        }
                }
 
        }
 
        class DiagResolverHook implements ResolverHook, ResolutionReport.Listener {
 
                public void handleResolutionReport(ResolutionReport report) {
                        DiagReportListener.this.report = report;
                }
 
                public void filterResolvable(Collection<BundleRevision> candidates) {
                }
 
                public void filterSingletonCollisions(BundleCapability singleton,
                                Collection<BundleCapability> collisionCandidates) {
                }
 
                public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
                }
 
                public void end() {
                }
 
        }
 
        public ResolverHook begin(Collection<BundleRevision> triggers) {
                if (triggers.containsAll(targetTriggers)) {
                        // this is the triggers we are looking for
                        return new DiagResolverHook();
                }
                // did not find the expected triggers do not participate
                // in the resolve process to gather the report
                return null;
        }
 
        ResolutionReport getReport() {
                return report;
        }
 }
 
Since:
3.10
  • Method Details

    • getEntries

      Returns all resolution report entries associated with this report. The key is the unresolved resource and the value is a list of report entries that caused the associated resource to not be able to resolve.
      Returns:
      all resolution report entries associated with this report.
    • getResolutionException

      ResolutionException getResolutionException()
      Returns the resolution exception associated with the resolve process or null if there is no resolution exception. For some resolve operations a resolution exception may not be thrown even if the resolve process could not resolve some resources. For example, if the resources are optional resources to resolve.
      Returns:
      the resolution exception or null if there is no resolution exception.
    • getResolutionReportMessage

      String getResolutionReportMessage(Resource resource)
      Returns a resolution report message for the given resource. The resource must be included as an entry for this resolution report. This is a convenience method intended to help display messaged for resolution errors.
      Parameters:
      resource - the resource to get the resolution report message for.
      Returns:
      a resolution report message.