}
}
private static void logUnresolvedBundles(Bundle[] bundles) {
State state = adaptor.getState();
FrameworkLog logService = adaptor.getFrameworkLog();
StateHelper stateHelper = adaptor.getPlatformAdmin().getStateHelper();
// first lets look for missing leaf constraints (bug 114120)
VersionConstraint[] leafConstraints = stateHelper.getUnsatisfiedLeaves(state.getBundles());
// hash the missing leaf constraints by the declaring bundles
Map missing = new HashMap();
for (int i = 0; i < leafConstraints.length; i++) {
// only include non-optional and non-dynamic constraint leafs
if (leafConstraints[i] instanceof BundleSpecification && ((BundleSpecification) leafConstraints[i]).isOptional())
continue;
if (leafConstraints[i] instanceof ImportPackageSpecification) {
if (ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
continue;
if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(((ImportPackageSpecification) leafConstraints[i]).getDirective(Constants.RESOLUTION_DIRECTIVE)))
continue;
}
BundleDescription bundle = leafConstraints[i].getBundle();
ArrayList constraints = (ArrayList) missing.get(bundle);
if (constraints == null) {
constraints = new ArrayList();
missing.put(bundle, constraints);
}
constraints.add(leafConstraints[i]);
}
// found some bundles with missing leaf constraints; log them first
if (missing.size() > 0) {
FrameworkLogEntry[] rootChildren = new FrameworkLogEntry[missing.size()];
int rootIndex = 0;
for (Iterator iter = missing.keySet().iterator(); iter.hasNext(); rootIndex++) {
BundleDescription description = (BundleDescription) iter.next();
String symbolicName = description.getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : description.getSymbolicName();
String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, description.getLocation());
ArrayList constraints = (ArrayList) missing.get(description);
FrameworkLogEntry[] logChildren = new FrameworkLogEntry[constraints.size()];
for (int i = 0; i < logChildren.length; i++)
logChildren[i] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage((VersionConstraint) constraints.get(i)), 0, null, null);
rootChildren[rootIndex] = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren);
}
logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED, 0, null, rootChildren));
}
// There may be some bundles unresolved for other reasons, causing the system to be unresolved
// log all unresolved constraints now
ArrayList allChildren = new ArrayList();
for (int i = 0; i < bundles.length; i++)
if (bundles[i].getState() == Bundle.INSTALLED) {
String symbolicName = bundles[i].getSymbolicName() == null ? FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME : bundles[i].getSymbolicName();
String generalMessage = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i]);
BundleDescription description = state.getBundle(bundles[i].getBundleId());
// for some reason, the state does not know about that bundle
if (description == null)
continue;
FrameworkLogEntry[] logChildren = null;
VersionConstraint[] unsatisfied = stateHelper.getUnsatisfiedConstraints(description);
if (unsatisfied.length > 0) {
// the bundle wasn't resolved due to some of its constraints were unsatisfiable
logChildren = new FrameworkLogEntry[unsatisfied.length];
for (int j = 0; j < unsatisfied.length; j++)
logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage(unsatisfied[j]), 0, null, null);
} else {
ResolverError[] resolverErrors = state.getResolverErrors(description);
if (resolverErrors.length > 0) {
logChildren = new FrameworkLogEntry[resolverErrors.length];
for (int j = 0; j < resolverErrors.length; j++)
logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, resolverErrors[j].toString(), 0, null, null);
}
}
allChildren.add(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren));
}
if (allChildren.size() > 0)
logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ALL_NOT_RESOLVED, 0, null, (FrameworkLogEntry[]) allChildren.toArray(new FrameworkLogEntry[allChildren.size()])));
}