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 int
private final Map
<org.osgi.resource.Resource, WrappedResource> private final OpenHashMapList
<org.osgi.resource.Requirement, org.osgi.resource.Capability> private final OpenHashMapSet
<org.osgi.resource.Requirement, org.osgi.resource.Capability> private final OpenHashMapSet
<org.osgi.resource.Capability, org.osgi.resource.Requirement> private final Set
<org.osgi.resource.Resource> private final OpenHashMap
<org.osgi.resource.Resource, Candidates.PopulateResult> private final Map
<org.osgi.resource.Capability, org.osgi.resource.Requirement> private static final int
private static final int
private static final int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCandidates
(Map<org.osgi.resource.Resource, Boolean> validOnDemandResources) Constructs an empty Candidates object.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. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addCandidates
(Map<org.osgi.resource.Requirement, List<org.osgi.resource.Capability>> candidates) Adds requirements and candidates in bulk.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.void
addMandatoryResources
(Collection<org.osgi.resource.Resource> resources) boolean
canRemoveCandidate
(org.osgi.resource.Requirement req) (package private) ResolutionError
checkSubstitutes
(List<Candidates> importPermutations) List
<org.osgi.resource.Capability> clearCandidates
(org.osgi.resource.Requirement req, Collection<org.osgi.resource.Capability> caps) copy()
Creates a copy of the Candidates object.void
dump
(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.Capability
getFirstCandidate
(org.osgi.resource.Requirement req) private Map
<org.osgi.resource.Capability, Map<String, Map<org.osgi.framework.Version, List<org.osgi.resource.Requirement>>>> Map
<org.osgi.resource.Resource, org.osgi.resource.Resource> getHosts()
int
getResolutionError
(org.osgi.resource.Resource resource) org.osgi.resource.Resource
getWrappedHost
(org.osgi.resource.Resource r) Returns the wrapped resource associated with the given resource.private boolean
isEffective
(ResolveContext rc, org.osgi.resource.Requirement req) private boolean
isMandatory
(ResolveContext rc, org.osgi.resource.Requirement requirement) boolean
isPopulated
(org.osgi.resource.Resource resource) private boolean
isSubstituted
(org.osgi.resource.Capability substitutableCap, Map<org.osgi.resource.Capability, Integer> substituteStatuses) void
permutate
(org.osgi.resource.Requirement req, List<Candidates> permutations) void
permutateIfNeeded
(org.osgi.resource.Requirement req, List<Candidates> permutations) populate
(ResolveContext rc, Collection<org.osgi.resource.Resource> resources) populateDynamic
(ResolveContext rc, org.osgi.resource.Resource resource, org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> candidates) private void
private void
populateSubstitutables
(org.osgi.resource.Resource resource) Merges fragments into their hosts.private ResolutionError
processCandidates
(ResolveContext rc, LinkedList<org.osgi.resource.Resource> toPopulate, org.osgi.resource.Requirement req, List<org.osgi.resource.Capability> candidates) private void
Removes a capability from the internal data structures.private void
remove
(org.osgi.resource.Requirement req) Removes a requirement from the internal data structures.private void
Removes the specified module from the internal data structures, which involves removing its requirements and its capabilities.void
removeFirstCandidate
(org.osgi.resource.Requirement req) 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.
-
Field Details
-
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
-
m_populateResultCache
private final OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult> m_populateResultCache -
m_validOnDemandResources
-
m_subtitutableMap
-
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
Constructs an empty Candidates object.
-
-
Method Details
-
getNbResources
public int getNbResources() -
getHosts
-
getDelta
Returns the delta which is the differences in the candidates from the original Candidates permutation.- Returns:
- the delta
-
addMandatoryResources
-
populate
public ResolutionError populate(ResolveContext rc, Collection<org.osgi.resource.Resource> resources) -
isEffective
-
isMandatory
-
populateSubstitutables
private void populateSubstitutables() -
populateSubstitutables
private void populateSubstitutables(org.osgi.resource.Resource resource) -
checkSubstitutes
-
isSubstituted
-
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
-
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) -
clearCandidates
public List<org.osgi.resource.Capability> clearCandidates(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.
-
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) -
permutateIfNeeded
-