Class Candidates

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

class Candidates extends Object
  • Field Details

    • m_mandatoryResources

      private final Set<org.osgi.resource.Resource> m_mandatoryResources
    • m_dependentMap

      private final OpenHashMapSet<org.osgi.resource.Capability,org.osgi.resource.Requirement> m_dependentMap
    • m_candidateMap

      private final OpenHashMapList<org.osgi.resource.Requirement,org.osgi.resource.Capability> m_candidateMap
    • m_allWrappedHosts

      private final Map<org.osgi.resource.Resource,WrappedResource> m_allWrappedHosts
    • m_populateResultCache

      private final OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult> m_populateResultCache
    • m_validOnDemandResources

      private final Map<org.osgi.resource.Resource,Boolean> m_validOnDemandResources
    • m_subtitutableMap

      private final Map<org.osgi.resource.Capability,org.osgi.resource.Requirement> m_subtitutableMap
    • m_delta

      private final OpenHashMapSet<org.osgi.resource.Requirement,org.osgi.resource.Capability> m_delta
    • UNPROCESSED

      private static final int UNPROCESSED
      See Also:
    • PROCESSING

      private static final int PROCESSING
      See Also:
    • SUBSTITUTED

      private static final int SUBSTITUTED
      See Also:
    • EXPORTED

      private static final int EXPORTED
      See Also:
  • Constructor Details

    • Candidates

      private Candidates(Set<org.osgi.resource.Resource> mandatoryResources, OpenHashMapSet<org.osgi.resource.Capability,org.osgi.resource.Requirement> dependentMap, OpenHashMapList<org.osgi.resource.Requirement,org.osgi.resource.Capability> candidateMap, Map<org.osgi.resource.Resource,WrappedResource> wrappedHosts, OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult> populateResultCache, Map<org.osgi.resource.Resource,Boolean> onDemandResources, Map<org.osgi.resource.Capability,org.osgi.resource.Requirement> substitutableMap, OpenHashMapSet<org.osgi.resource.Requirement,org.osgi.resource.Capability> delta)
      Private copy constructor used by the copy() method.
    • Candidates

      public Candidates(Map<org.osgi.resource.Resource,Boolean> validOnDemandResources)
      Constructs an empty Candidates object.
  • Method Details

    • getNbResources

      public int getNbResources()
    • getHosts

      public Map<org.osgi.resource.Resource,org.osgi.resource.Resource> getHosts()
    • getDelta

      public Object getDelta()
      Returns the delta which is the differences in the candidates from the original Candidates permutation.
      Returns:
      the delta
    • addMandatoryResources

      public void addMandatoryResources(Collection<org.osgi.resource.Resource> resources)
    • populate

      public ResolutionError populate(ResolveContext rc, Collection<org.osgi.resource.Resource> resources)
    • isEffective

      private boolean isEffective(ResolveContext rc, org.osgi.resource.Requirement req)
    • isMandatory

      private boolean isMandatory(ResolveContext rc, org.osgi.resource.Requirement requirement)
    • populateSubstitutables

      private void populateSubstitutables()
    • populateSubstitutables

      private void populateSubstitutables(org.osgi.resource.Resource resource)
    • checkSubstitutes

      ResolutionError checkSubstitutes(List<Candidates> importPermutations)
    • isSubstituted

      private boolean isSubstituted(org.osgi.resource.Capability substitutableCap, Map<org.osgi.resource.Capability,Integer> substituteStatuses)
    • populateDynamic

      public ResolutionError populateDynamic(ResolveContext rc, org.osgi.resource.Resource resource, org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> candidates)
    • processCandidates

      private ResolutionError processCandidates(ResolveContext rc, LinkedList<org.osgi.resource.Resource> toPopulate, org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> candidates)
    • isPopulated

      public boolean isPopulated(org.osgi.resource.Resource resource)
    • getResolutionError

      public ResolutionError getResolutionError(org.osgi.resource.Resource resource)
    • addCandidates

      private void addCandidates(org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> 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.
    • addCandidates

      private void addCandidates(Map<org.osgi.resource.Requirement,List<org.osgi.resource.Capability>> 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 org.osgi.resource.Resource getWrappedHost(org.osgi.resource.Resource r)
      Returns the wrapped resource associated with the given resource. If the resource was not wrapped, then the resource itself is returned. This is really only needed to determine if the root resources of the resolve have been wrapped.
      Parameters:
      r - the resource whose wrapper is desired.
      Returns:
      the wrapper resource or the resource itself if it was not wrapped.
    • getCandidates

      public List<org.osgi.resource.Capability> getCandidates(org.osgi.resource.Requirement req)
      Gets the candidates associated with a given requirement.
      Parameters:
      req - the requirement whose candidates are desired.
      Returns:
      the matching candidates or null.
    • getFirstCandidate

      public org.osgi.resource.Capability getFirstCandidate(org.osgi.resource.Requirement req)
    • removeFirstCandidate

      public void removeFirstCandidate(org.osgi.resource.Requirement req)
    • clearCandidates

      public List<org.osgi.resource.Capability> clearCandidates(org.osgi.resource.Requirement req, Collection<org.osgi.resource.Capability> caps)
    • prepare

      public ResolutionError 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.
      Returns:
      ResolutionError if the removal of any unselected fragments result in the root module being unable to resolve.
    • getHostFragments

      private Map<org.osgi.resource.Capability,Map<String,Map<org.osgi.framework.Version,List<org.osgi.resource.Requirement>>>> getHostFragments()
    • removeResource

      private void removeResource(org.osgi.resource.Resource resource, ResolutionError 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:
      resource - the module to remove.
      ex - the resolution error
    • remove

      private void remove(org.osgi.resource.Resource resource, Set<org.osgi.resource.Resource> unresolvedResources)
      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:
      resource - the module to remove.
      unresolvedResources - 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.
    • remove

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

      private void remove(org.osgi.resource.Capability c, Set<org.osgi.resource.Resource> unresolvedResources)
      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.
      unresolvedResources - 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.
    • 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(ResolveContext rc)
    • permutate

      public void permutate(org.osgi.resource.Requirement req, List<Candidates> permutations)
    • canRemoveCandidate

      public boolean canRemoveCandidate(org.osgi.resource.Requirement req)
    • permutateIfNeeded

      public void permutateIfNeeded(org.osgi.resource.Requirement req, List<Candidates> permutations)