Class Candidates

java.lang.Object
org.apache.felix.framework.resolver.Candidates

class Candidates extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • populate

      public final void populate(ResolveContext rc, BundleRevision revision, int resolution)
      Populates candidates for the specified revision. How a revision is resolved depends on its resolution type as follows:
      • MANDATORY - must resolve and failure to do so throws an exception.
      • OPTIONAL - attempt to resolve, but no exception is thrown if the resolve fails.
      • ON_DEMAND - only resolve on demand; this only applies to fragments and will only resolve a fragment if its host is already selected as a candidate.
      Parameters:
      revision - the revision whose candidates should be populated.
      resolution - indicates the resolution type.
      state - the resolver state used for populating the candidates.
    • populateRevision

      private void populateRevision(ResolveContext rc, BundleRevision revision)
      Populates candidates for the specified revision.
      Parameters:
      revision - the revision whose candidates should be populated.
      state - the resolver state used for populating the candidates.
    • populateFragmentOndemand

      private boolean populateFragmentOndemand(ResolveContext rc, BundleRevision revision) throws ResolveException
      Throws:
      ResolveException
    • populateDynamic

      public void populateDynamic(ResolveContext rc, BundleRevision revision, BundleRequirement req, List<BundleCapability> candidates)
    • processCandidates

      private ResolveException processCandidates(ResolveContext rc, BundleRevision revision, List<BundleCapability> candidates)
      This method performs common processing on the given set of candidates. Specifically, it removes any candidates which cannot resolve and it synthesizes candidates for any candidates coming from any attached fragments, since fragment capabilities only appear once, but technically each host represents a unique capability.
      Parameters:
      revision - the revision being resolved.
      candidates - the candidates to process.
      state - the resolver state.
      Returns:
      a resolve exception to be re-thrown, if any, or null.
    • isPopulated

      public boolean isPopulated(BundleRevision revision)
    • getResolveException

      public ResolveException getResolveException(BundleRevision revision)
    • add

      private void add(BundleRequirement req, List<BundleCapability> candidates)
      Adds a requirement and its matching candidates to the internal data structure. This method assumes it owns the data being passed in and does not make a copy. It takes the data and processes, such as calculating which requirements depend on which capabilities and recording any fragments it finds for future merging.
      Parameters:
      req - the requirement to add.
      candidates - the candidates matching the requirement.
    • add

      private void add(Map<BundleRequirement,List<BundleCapability>> candidates)
      Adds requirements and candidates in bulk. The outer map is not retained by this method, but the inner data structures are, so they should not be further modified by the caller.
      Parameters:
      candidates - the bulk requirements and candidates to add.
    • getWrappedHost

      public BundleRevision getWrappedHost(BundleRevision m)
      Returns the wrapped module associated with the given module. If the module was not wrapped, then the module itself is returned. This is really only needed to determine if the root modules of the resolve have been wrapped.
      Parameters:
      m - the module whose wrapper is desired.
      Returns:
      the wrapper module or the module itself if it was not wrapped.
    • getCandidates

      public List<BundleCapability> getCandidates(BundleRequirement req)
      Gets the candidates associated with a given requirement.
      Parameters:
      req - the requirement whose candidates are desired.
      Returns:
      the matching candidates or null.
    • prepare

      public void prepare(ResolveContext rc)
      Merges fragments into their hosts. It does this by wrapping all host modules and attaching their selected fragments, removing all unselected fragment modules, and replacing all occurrences of the original fragments in the internal data structures with the wrapped host modules instead. Thus, fragment capabilities and requirements are merged into the appropriate host and the candidates for the fragment now become candidates for the host. Likewise, any module depending on a fragment now depend on the host. Note that this process is sort of like multiplication, since one fragment that can attach to two hosts effectively gets multiplied across the two hosts. So, any modules being satisfied by the fragment will end up having the two hosts as potential candidates, rather than the single fragment.
      Parameters:
      existingSingletons - existing resolved singletons.
      Throws:
      ResolveException - if the removal of any unselected fragments result in the root module being unable to resolve.
    • populateDependents

      private Map<BundleCapability,Map<String,Map<Version,List<BundleRequirement>>>> populateDependents()
    • removeRevision

      private void removeRevision(BundleRevision revision, ResolveException ex)
      Removes a module from the internal data structures if it wasn't selected as a fragment or a singleton. This process may cause other modules to become unresolved if they depended on the module's capabilities and there is no other candidate.
      Parameters:
      revision - the module to remove.
      Throws:
      ResolveException - if removing the module caused the resolve to fail.
    • remove

      private void remove(BundleRevision br, Set<BundleRevision> unresolvedRevisions) throws ResolveException
      Removes the specified module from the internal data structures, which involves removing its requirements and its capabilities. This may cause other modules to become unresolved as a result.
      Parameters:
      br - the module to remove.
      unresolvedRevisions - a list to containing any additional modules that that became unresolved as a result of removing this module and will also need to be removed.
      Throws:
      ResolveException - if removing the module caused the resolve to fail.
    • remove

      private void remove(BundleRequirement req)
      Removes a requirement from the internal data structures.
      Parameters:
      req - the requirement to remove.
    • remove

      private void remove(BundleCapability c, Set<BundleRevision> unresolvedRevisions) throws ResolveException
      Removes a capability from the internal data structures. This may cause other modules to become unresolved as a result.
      Parameters:
      c - the capability to remove.
      unresolvedRevisions - a list to containing any additional modules that that became unresolved as a result of removing this module and will also need to be removed.
      Throws:
      ResolveException - if removing the module caused the resolve to fail.
    • copy

      public Candidates copy()
      Creates a copy of the Candidates object. This is used for creating permutations when package space conflicts are discovered.
      Returns:
      copy of this Candidates object.
    • dump

      public void dump()