Search in sources :

Example 1 with ResolverError

use of org.eclipse.osgi.service.resolver.ResolverError in project tycho by eclipse.

the class Activator method getRelevantErrors.

private static void getRelevantErrors(State state, Set<ResolverError> errors, BundleDescription bundle) {
    ResolverError[] bundleErrors = state.getResolverErrors(bundle);
    for (int j = 0; j < bundleErrors.length; j++) {
        ResolverError error = bundleErrors[j];
        errors.add(error);
        VersionConstraint constraint = error.getUnsatisfiedConstraint();
        if (constraint instanceof BundleSpecification || constraint instanceof HostSpecification) {
            BundleDescription[] requiredBundles = state.getBundles(constraint.getName());
            for (int i = 0; i < requiredBundles.length; i++) {
                getRelevantErrors(state, errors, requiredBundles[i]);
            }
        }
    }
}
Also used : VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint) HostSpecification(org.eclipse.osgi.service.resolver.HostSpecification) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ResolverError(org.eclipse.osgi.service.resolver.ResolverError) BundleSpecification(org.eclipse.osgi.service.resolver.BundleSpecification) VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint)

Example 2 with ResolverError

use of org.eclipse.osgi.service.resolver.ResolverError in project tycho by eclipse.

the class EquinoxResolver method assertResolved.

public void assertResolved(State state, BundleDescription desc) throws BundleException {
    if (!desc.isResolved()) {
        if (logger.isDebugEnabled()) {
            logger.debug("Equinox resolver state:\n" + toDebugString(state));
        }
        StringBuffer msg = new StringBuffer();
        msg.append("Bundle ").append(desc.getSymbolicName()).append(" cannot be resolved\n");
        msg.append("Resolution errors:\n");
        ResolverError[] errors = getResolverErrors(state, desc);
        for (int i = 0; i < errors.length; i++) {
            ResolverError error = errors[i];
            msg.append("   Bundle ").append(error.getBundle().getSymbolicName()).append(" - ").append(error.toString()).append("\n");
        }
        throw new BundleException(msg.toString());
    }
}
Also used : ResolverError(org.eclipse.osgi.service.resolver.ResolverError) BundleException(org.osgi.framework.BundleException) VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint)

Example 3 with ResolverError

use of org.eclipse.osgi.service.resolver.ResolverError in project tycho by eclipse.

the class EquinoxResolver method toDebugString.

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();
}
Also used : BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ResolverError(org.eclipse.osgi.service.resolver.ResolverError)

Example 4 with ResolverError

use of org.eclipse.osgi.service.resolver.ResolverError in project tycho by eclipse.

the class EquinoxResolver method getRelevantErrors.

private void getRelevantErrors(State state, Set<ResolverError> errors, BundleDescription bundle) {
    ResolverError[] bundleErrors = state.getResolverErrors(bundle);
    for (int j = 0; j < bundleErrors.length; j++) {
        ResolverError error = bundleErrors[j];
        errors.add(error);
        VersionConstraint constraint = error.getUnsatisfiedConstraint();
        if (constraint instanceof BundleSpecification || constraint instanceof HostSpecification) {
            BundleDescription[] requiredBundles = state.getBundles(constraint.getName());
            for (int i = 0; i < requiredBundles.length; i++) {
                // do not handle that bundle (again). See bug 442594.
                if (bundle.equals(requiredBundles[i])) {
                    continue;
                }
                getRelevantErrors(state, errors, requiredBundles[i]);
            }
        }
    }
}
Also used : VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint) HostSpecification(org.eclipse.osgi.service.resolver.HostSpecification) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ResolverError(org.eclipse.osgi.service.resolver.ResolverError) BundleSpecification(org.eclipse.osgi.service.resolver.BundleSpecification) VersionConstraint(org.eclipse.osgi.service.resolver.VersionConstraint)

Example 5 with ResolverError

use of org.eclipse.osgi.service.resolver.ResolverError in project tycho by eclipse.

the class Activator method getResolutionErrors.

public static Set<ResolverError> getResolutionErrors(Bundle bundle) {
    Set<ResolverError> errors = new LinkedHashSet<ResolverError>();
    try {
        if (platformAdmin == null) {
            System.err.println("Could not compute diagnostic information for the test bundle resolution problems - PlatformAdmin service is not available");
            return errors;
        }
        State state = platformAdmin.getState(false);
        if (state == null) {
            System.err.println("Resolver state is null");
            return errors;
        }
        BundleDescription description = state.getBundle(bundle.getBundleId());
        if (description == null) {
            System.err.println("Could not determine BundleDescription for " + bundle.toString());
        }
        getRelevantErrors(state, errors, description);
    } catch (RuntimeException e) {
        System.err.println("Error while computing diagnostic information for the test bundle resolution problems");
        e.printStackTrace();
    }
    return errors;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ResolverError(org.eclipse.osgi.service.resolver.ResolverError)

Aggregations

ResolverError (org.eclipse.osgi.service.resolver.ResolverError)5 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)4 VersionConstraint (org.eclipse.osgi.service.resolver.VersionConstraint)3 BundleSpecification (org.eclipse.osgi.service.resolver.BundleSpecification)2 HostSpecification (org.eclipse.osgi.service.resolver.HostSpecification)2 LinkedHashSet (java.util.LinkedHashSet)1 State (org.eclipse.osgi.service.resolver.State)1 BundleException (org.osgi.framework.BundleException)1