コード例 #1
0
  public void testTest_006() {
    State state = buildEmptyState();
    StateObjectFactory sof = platformAdmin.getFactory();

    bundle_1 = create_bundle_1(sof);
    bundle_2 = create_bundle_2(sof);
    bundle_3 = create_bundle_3(sof);
    bundle_4 = create_bundle_4(sof);
    bundle_5 = create_bundle_5(sof);
    bundle_6 = create_bundle_6(sof);
    // ***************************************************
    // stage a
    // expect to pass =true
    // ***************************************************
    addBundlesToState_a(state);
    // ***************************************************
    try {
      state.resolve();
    } catch (Throwable t) {
      fail("unexpected exception class=" + t.getClass().getName() + " message=" + t.getMessage());
      return;
    }
    checkBundlesResolved_a();
    checkWiring_a();
  } // end of method
コード例 #2
0
 /**
  * @param state
  * @param bundle
  * @return
  */
 private static DisabledInfo createDisabledInfo(State state, long bundleId) {
   BundleDescription desc = state.getBundle(bundleId);
   DisabledInfo info =
       new DisabledInfo(
           "org.eclipse.pde.ui", //$NON-NLS-1$
           "Disabled via PDE",
           desc); //$NON-NLS-1$
   return info;
 }
コード例 #3
0
  /**
   * Returns a {@link Set} of bundle ids for the dependents of the given objects from the given
   * {@link State}. The set additionally only includes the given set of implicit dependencies.
   *
   * @param selected selected the group of objects to compute dependencies for. Any items in this
   *     array that are not {@link IPluginModelBase}s are ignored.
   * @param implicit the array of additional implicit dependencies to add to the {@link Set}
   * @param state the {@link State} to compute the dependencies in
   * @param removeSelf if the id of one of the bundles were are computing dependencies for should be
   *     included in the result {@link Set} or not
   * @param includeOptional if optional bundle ids should be included
   * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from
   *     the dependency resolution
   * @return a set of bundle IDs
   */
  private static Set<String> getDependencies(
      Object[] selected,
      String[] implicit,
      State state,
      boolean removeSelf,
      boolean includeOptional,
      Set<String> excludeFragments) {
    Set<String> set = new TreeSet<>();
    for (int i = 0; i < selected.length; i++) {
      if (!(selected[i] instanceof IPluginModelBase)) continue;
      IPluginModelBase model = (IPluginModelBase) selected[i];
      addBundleAndDependencies(
          model.getBundleDescription(), set, includeOptional, excludeFragments);
      IPluginExtension[] extensions = model.getPluginBase().getExtensions();
      for (int j = 0; j < extensions.length; j++) {
        String point = extensions[j].getPoint();
        if (point != null) {
          int dot = point.lastIndexOf('.');
          if (dot != -1) {
            String id = point.substring(0, dot);
            addBundleAndDependencies(
                state.getBundle(id, null), set, includeOptional, excludeFragments);
          }
        }
      }
    }

    for (int i = 0; i < implicit.length; i++) {
      addBundleAndDependencies(
          state.getBundle(implicit[i], null), set, includeOptional, excludeFragments);
    }

    if (removeSelf) {
      for (int i = 0; i < selected.length; i++) {
        if (!(selected[i] instanceof IPluginModelBase)) {
          continue;
        }
        IPluginModelBase model = (IPluginModelBase) selected[i];
        set.remove(model.getPluginBase().getId());
      }
    }
    return set;
  }
コード例 #4
0
 private BundleDescription[] getPluginModels() {
   ArrayList list = new ArrayList();
   State state = TargetPlatformHelper.getState();
   IProductPlugin[] plugins = product.getPlugins();
   for (int i = 0; i < plugins.length; i++) {
     BundleDescription bundle = null;
     String v = plugins[i].getVersion();
     if (v != null && v.length() > 0) {
       bundle = state.getBundle(plugins[i].getId(), Version.parseVersion(v));
     }
     // if there's no version, just grab a bundle like before
     if (bundle == null) {
       bundle = state.getBundle(plugins[i].getId(), null);
     }
     if (bundle != null) {
       list.add(bundle);
     }
   }
   Object[] bundleArray = list.toArray(new BundleDescription[list.size()]);
   return (BundleDescription[]) bundleArray;
 }
コード例 #5
0
  /**
   * Build the table of plug-in dependencies. Iterate over all the plug-ins in the plug-in registry
   * and the cycle through the list of pre-requisites and create the parent/child relationships in
   * the nodes.
   */
  private Map getDependencyGraph() {
    if (dependencyGraph != null) return dependencyGraph;
    // Build up the dependency graph (see PluginDependencyGraphNode) so
    // we have the information readily available for any plug-in.
    State state = Platform.getPlatformAdmin().getState(false);
    BundleDescription[] plugins = state.getBundles();
    dependencyGraph = new HashMap();
    for (int i = 0; i < plugins.length; i++) {
      BundleDescription descriptor = plugins[i];
      PluginDependencyGraphNode node =
          (PluginDependencyGraphNode) dependencyGraph.get(new Long(descriptor.getBundleId()));
      if (node == null) {
        node = new PluginDependencyGraphNode(descriptor);
        dependencyGraph.put(new Long(descriptor.getBundleId()), node);
      }

      // Cycle through the prerequisites
      BundleSpecification[] requires = descriptor.getRequiredBundles();
      for (int j = 0; j < requires.length; j++) {
        BundleDescription childDesc = (BundleDescription) requires[j].getSupplier();
        // if the child doesn't exist then move to the next child
        if (childDesc == null) continue;

        // if the child entry is not in the table yet then add it
        PluginDependencyGraphNode childNode =
            (PluginDependencyGraphNode) dependencyGraph.get(new Long(childDesc.getBundleId()));
        if (childNode == null) {
          childNode = new PluginDependencyGraphNode(childDesc);
          dependencyGraph.put(new Long(childDesc.getBundleId()), childNode);
        }

        // Add the child to this node's children and set this node as an ancestor
        // of the child node
        node.addChild(childNode);
        childNode.addAncestor(node);
      }
    }
    return dependencyGraph;
  }
コード例 #6
0
 public void addBundlesToState_a(State state) {
   boolean added = false;
   added = state.addBundle(bundle_1);
   assertTrue("failed to add bundle ", added);
   added = state.addBundle(bundle_2);
   assertTrue("failed to add bundle ", added);
   added = state.addBundle(bundle_3);
   assertTrue("failed to add bundle ", added);
   added = state.addBundle(bundle_4);
   assertTrue("failed to add bundle ", added);
   added = state.addBundle(bundle_5);
   assertTrue("failed to add bundle ", added);
   added = state.addBundle(bundle_6);
   assertTrue("failed to add bundle ", added);
 } // end method
コード例 #7
0
ファイル: EclimPlugin.java プロジェクト: repos-vim/eclim
  /**
   * Diagnose loading of the bundle with the supplied name (ex. org.eclim.core).
   *
   * <p>Gleaned from org.eclipse.core.runtime.internal.adaptor.EclipseCommandProvider
   *
   * @param bundleName The bundle name to diagnose the loading of.
   * @return The diagnoses.
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  public String diagnose(String bundleName) {
    StringWriter out = new StringWriter();
    PrintWriter writer = new PrintWriter(out);

    BundleContext context = getDefault().getBundle().getBundleContext();
    ServiceReference platformAdminRef = context.getServiceReference(PlatformAdmin.class.getName());
    PlatformAdmin platformAdmin = (PlatformAdmin) context.getService(platformAdminRef);
    State state = platformAdmin.getState(false);

    BundleDescription bundle = null;
    BundleDescription[] allBundles = state.getBundles(bundleName);
    if (allBundles.length == 0) {
      writer.println(
          NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, bundleName));
    } else {
      bundle = allBundles[0];

      VersionConstraint[] unsatisfied =
          platformAdmin.getStateHelper().getUnsatisfiedConstraints(bundle);
      ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(bundle);

      for (int i = 0; i < resolverErrors.length; i++) {
        if ((resolverErrors[i].getType()
                & (ResolverError.MISSING_FRAGMENT_HOST
                    | ResolverError.MISSING_GENERIC_CAPABILITY
                    | ResolverError.MISSING_IMPORT_PACKAGE
                    | ResolverError.MISSING_REQUIRE_BUNDLE))
            != 0) {
          continue;
        }
        writer.print("  ");
        writer.println(resolverErrors[i].toString());
      }

      if (unsatisfied.length == 0 && resolverErrors.length == 0) {
        writer.print("  ");
        writer.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_CONSTRAINTS);
      }
      if (unsatisfied.length > 0) {
        writer.print("  ");
        writer.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_DIRECT_CONSTRAINTS);
      }
      for (int i = 0; i < unsatisfied.length; i++) {
        writer.print("    ");
        writer.println(MessageHelper.getResolutionFailureMessage(unsatisfied[i]));
      }

      VersionConstraint[] unsatisfiedLeaves =
          platformAdmin.getStateHelper().getUnsatisfiedLeaves(new BundleDescription[] {bundle});
      boolean foundLeaf = false;
      for (int i = 0; i < unsatisfiedLeaves.length; i++) {
        if (unsatisfiedLeaves[i].getBundle() == bundle) {
          continue;
        }
        if (!foundLeaf) {
          foundLeaf = true;
          writer.print("  ");
          writer.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_LEAF_CONSTRAINTS);
        }
        writer.print("    ");
        writer.println(
            unsatisfiedLeaves[i].getBundle().getLocation()
                + " ["
                + unsatisfiedLeaves[i].getBundle().getBundleId()
                + "]");
        writer.print("      ");
        writer.println(MessageHelper.getResolutionFailureMessage(unsatisfiedLeaves[i]));
      }
    }
    return out.toString();
  }