Package org.apache.felix.resolver
Class Candidates
java.lang.Object
org.apache.felix.resolver.Candidates
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final Map<org.osgi.resource.Resource, WrappedResource> private final OpenHashMapListprivate final AtomicBooleanprivate final OpenHashMapSet<org.osgi.resource.Requirement, org.osgi.resource.Capability> private final OpenHashMapSet<org.osgi.resource.Capability, org.osgi.resource.Requirement> private final OpenHashMap<org.osgi.resource.Resource, Candidates.PopulateResult> private final ResolverImpl.ResolveSessionprivate final Map<org.osgi.resource.Capability, org.osgi.resource.Requirement> private static final intprivate static final intprivate static final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionCandidates(ResolverImpl.ResolveSession session) Constructs an empty Candidates object.privateCandidates(ResolverImpl.ResolveSession session, AtomicBoolean candidateSelectorsUnmodifiable, OpenHashMapSet<org.osgi.resource.Capability, org.osgi.resource.Requirement> dependentMap, OpenHashMapList candidateMap, Map<org.osgi.resource.Resource, WrappedResource> wrappedHosts, OpenHashMap<org.osgi.resource.Resource, Candidates.PopulateResult> populateResultCache, 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. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddCandidates(Map<org.osgi.resource.Requirement, List<org.osgi.resource.Capability>> candidates) Adds requirements and candidates in bulk.private voidaddCandidates(org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> candidates) Adds a requirement and its matching candidates to the internal data structure.private voidaddHost(org.osgi.resource.Resource res, Map<org.osgi.resource.Resource, org.osgi.resource.Resource> hosts) booleancanRemoveCandidate(org.osgi.resource.Requirement req) (package private) ResolutionErrorclearMultipleCardinalityCandidates(org.osgi.resource.Requirement req, Collection<org.osgi.resource.Capability> caps) copy()Creates a copy of the Candidates object.voiddump(ResolveContext rc) List<org.osgi.resource.Capability> getCandidates(org.osgi.resource.Requirement req) Gets the candidates associated with a given requirement.getDelta()Returns the delta which is the differences in the candidates from the original Candidates permutation.org.osgi.resource.CapabilitygetFirstCandidate(org.osgi.resource.Requirement req) private Map<org.osgi.resource.Capability, Map<String, Map<org.osgi.framework.Version, List<org.osgi.resource.Requirement>>>> intgetResolutionError(org.osgi.resource.Resource resource) Map<org.osgi.resource.Resource, org.osgi.resource.Resource> org.osgi.resource.ResourcegetWrappedHost(org.osgi.resource.Resource r) Returns the wrapped resource associated with the given resource.private booleanisEffective(org.osgi.resource.Requirement req) booleanisPopulated(org.osgi.resource.Resource resource) private booleanisSubstituted(org.osgi.resource.Capability substitutableCap, Map<org.osgi.resource.Capability, Integer> substituteStatuses) permutate(org.osgi.resource.Requirement req) voidpopulate(Collection<org.osgi.resource.Resource> resources) private voidprivate voidpopulateSubstitutables(org.osgi.resource.Resource resource) prepare()Merges fragments into their hosts.private ResolutionErrorprocessCandidates(LinkedList<org.osgi.resource.Resource> toPopulate, org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> candidates) private voidRemoves a capability from the internal data structures.private voidremove(org.osgi.resource.Requirement req) Removes a requirement from the internal data structures.private voidRemoves the specified module from the internal data structures, which involves removing its requirements and its capabilities.private CandidateSelectorremoveCandidate(org.osgi.resource.Requirement req, org.osgi.resource.Capability cap) voidremoveFirstCandidate(org.osgi.resource.Requirement req) private voidremoveResource(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.
-
Field Details
-
m_session
-
m_dependentMap
private final OpenHashMapSet<org.osgi.resource.Capability,org.osgi.resource.Requirement> m_dependentMap -
m_candidateMap
-
m_allWrappedHosts
-
m_populateResultCache
private final OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult> m_populateResultCache -
m_subtitutableMap
-
m_delta
-
m_candidateSelectorsUnmodifiable
-
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(ResolverImpl.ResolveSession session, AtomicBoolean candidateSelectorsUnmodifiable, OpenHashMapSet<org.osgi.resource.Capability, org.osgi.resource.Requirement> dependentMap, OpenHashMapList candidateMap, Map<org.osgi.resource.Resource, WrappedResource> wrappedHosts, OpenHashMap<org.osgi.resource.Resource, Candidates.PopulateResult> populateResultCache, 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
Constructs an empty Candidates object.
-
-
Method Details
-
getNbResources
public int getNbResources() -
getRootHosts
-
addHost
private void addHost(org.osgi.resource.Resource res, Map<org.osgi.resource.Resource, org.osgi.resource.Resource> hosts) -
getDelta
Returns the delta which is the differences in the candidates from the original Candidates permutation.- Returns:
- the delta
-
populate
-
isEffective
private boolean isEffective(org.osgi.resource.Requirement req) -
populateSubstitutables
private void populateSubstitutables() -
populateSubstitutables
private void populateSubstitutables(org.osgi.resource.Resource resource) -
checkSubstitutes
ResolutionError checkSubstitutes() -
isSubstituted
-
populateDynamic
-
processCandidates
private ResolutionError processCandidates(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
-
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
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) -
clearMultipleCardinalityCandidates
public CandidateSelector clearMultipleCardinalityCandidates(org.osgi.resource.Requirement req, Collection<org.osgi.resource.Capability> caps) -
prepare
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
-
removeResource
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.
-
removeCandidate
private CandidateSelector removeCandidate(org.osgi.resource.Requirement req, org.osgi.resource.Capability cap) -
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
-
permutate
-
canRemoveCandidate
public boolean canRemoveCandidate(org.osgi.resource.Requirement req)
-