Interface ResolutionReport
@ProviderType
@NoImplement
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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceA resolution report listener gets called an the end of resolve process in order to receive a resolution report. -
Method Summary
Modifier and TypeMethodDescriptionReturns all resolution report entries associated with this report.intintReturns the resolution exception associated with the resolve process ornullif there is no resolution exception.getResolutionReportMessage(Resource resource) Returns a resolution report message for the given resource.intintint
-
Method Details
-
getEntries
Map<Resource,List<ResolutionReport.Entry>> 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 ornullif 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
nullif there is no resolution exception.
-
getResolutionReportMessage
Returns a resolution report message for the given resource. The resource must be included as anentryfor 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.
-
getTotalPermutations
int getTotalPermutations()- Returns:
- the number of permutations created to solve the problem or -1 if unknown
- Since:
- 3.20
-
getProcessedPermutations
int getProcessedPermutations()- Returns:
- the number of processed permutations -1 if unknown
- Since:
- 3.20
-
getUsesPermutations
int getUsesPermutations()- Returns:
- the number of permutations cause by a use-constraint violation -1 if unknown
- Since:
- 3.20
-
getSubstitutionPermutations
int getSubstitutionPermutations()- Returns:
- the number of permutations cause by a package substitution or -1 if unknown
- Since:
- 3.20
-
getImportPermutations
int getImportPermutations()- Returns:
- the number of permutations cause by a different package provider selected or -1 if unknown
- Since:
- 3.20
-