Package org.apache.felix.resolver
Class Candidates
- java.lang.Object
-
- org.apache.felix.resolver.Candidates
-
class Candidates extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Candidates.DynamicImportFailed
(package private) static class
Candidates.FragmentNotSelectedError
(package private) static class
Candidates.MissingRequirementError
(package private) static class
Candidates.PopulateResult
-
Field Summary
Fields Modifier and Type Field Description private static int
EXPORTED
private java.util.Map<org.osgi.resource.Resource,WrappedResource>
m_allWrappedHosts
private OpenHashMapList<org.osgi.resource.Requirement,org.osgi.resource.Capability>
m_candidateMap
private OpenHashMapSet<org.osgi.resource.Requirement,org.osgi.resource.Capability>
m_delta
private OpenHashMapSet<org.osgi.resource.Capability,org.osgi.resource.Requirement>
m_dependentMap
private java.util.Set<org.osgi.resource.Resource>
m_mandatoryResources
private OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult>
m_populateResultCache
private java.util.Map<org.osgi.resource.Capability,org.osgi.resource.Requirement>
m_subtitutableMap
private java.util.Map<org.osgi.resource.Resource,java.lang.Boolean>
m_validOnDemandResources
private static int
PROCESSING
private static int
SUBSTITUTED
private static int
UNPROCESSED
-
Constructor Summary
Constructors Modifier Constructor Description Candidates(java.util.Map<org.osgi.resource.Resource,java.lang.Boolean> validOnDemandResources)
Constructs an empty Candidates object.private
Candidates(java.util.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, java.util.Map<org.osgi.resource.Resource,WrappedResource> wrappedHosts, OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult> populateResultCache, java.util.Map<org.osgi.resource.Resource,java.lang.Boolean> onDemandResources, java.util.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addCandidates(java.util.Map<org.osgi.resource.Requirement,java.util.List<org.osgi.resource.Capability>> candidates)
Adds requirements and candidates in bulk.private void
addCandidates(org.osgi.resource.Requirement req, java.util.List<org.osgi.resource.Capability> candidates)
Adds a requirement and its matching candidates to the internal data structure.void
addMandatoryResources(java.util.Collection<org.osgi.resource.Resource> resources)
boolean
canRemoveCandidate(org.osgi.resource.Requirement req)
(package private) ResolutionError
checkSubstitutes(java.util.List<Candidates> importPermutations)
java.util.List<org.osgi.resource.Capability>
clearCandidates(org.osgi.resource.Requirement req, java.util.Collection<org.osgi.resource.Capability> caps)
Candidates
copy()
Creates a copy of the Candidates object.void
dump(ResolveContext rc)
java.util.List<org.osgi.resource.Capability>
getCandidates(org.osgi.resource.Requirement req)
Gets the candidates associated with a given requirement.java.lang.Object
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 java.util.Map<org.osgi.resource.Capability,java.util.Map<java.lang.String,java.util.Map<org.osgi.framework.Version,java.util.List<org.osgi.resource.Requirement>>>>
getHostFragments()
java.util.Map<org.osgi.resource.Resource,org.osgi.resource.Resource>
getHosts()
int
getNbResources()
ResolutionError
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, java.util.Map<org.osgi.resource.Capability,java.lang.Integer> substituteStatuses)
void
permutate(org.osgi.resource.Requirement req, java.util.List<Candidates> permutations)
void
permutateIfNeeded(org.osgi.resource.Requirement req, java.util.List<Candidates> permutations)
ResolutionError
populate(ResolveContext rc, java.util.Collection<org.osgi.resource.Resource> resources)
ResolutionError
populateDynamic(ResolveContext rc, org.osgi.resource.Resource resource, org.osgi.resource.Requirement req, java.util.List<org.osgi.resource.Capability> candidates)
private void
populateSubstitutables()
private void
populateSubstitutables(org.osgi.resource.Resource resource)
ResolutionError
prepare(ResolveContext rc)
Merges fragments into their hosts.private ResolutionError
processCandidates(ResolveContext rc, java.util.LinkedList<org.osgi.resource.Resource> toPopulate, org.osgi.resource.Requirement req, java.util.List<org.osgi.resource.Capability> candidates)
private void
remove(org.osgi.resource.Capability c, java.util.Set<org.osgi.resource.Resource> unresolvedResources)
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
remove(org.osgi.resource.Resource resource, java.util.Set<org.osgi.resource.Resource> unresolvedResources)
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 Detail
-
m_mandatoryResources
private final java.util.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 java.util.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 java.util.Map<org.osgi.resource.Resource,java.lang.Boolean> m_validOnDemandResources
-
m_subtitutableMap
private final java.util.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:
- Constant Field Values
-
PROCESSING
private static final int PROCESSING
- See Also:
- Constant Field Values
-
SUBSTITUTED
private static final int SUBSTITUTED
- See Also:
- Constant Field Values
-
EXPORTED
private static final int EXPORTED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Candidates
private Candidates(java.util.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, java.util.Map<org.osgi.resource.Resource,WrappedResource> wrappedHosts, OpenHashMap<org.osgi.resource.Resource,Candidates.PopulateResult> populateResultCache, java.util.Map<org.osgi.resource.Resource,java.lang.Boolean> onDemandResources, java.util.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(java.util.Map<org.osgi.resource.Resource,java.lang.Boolean> validOnDemandResources)
Constructs an empty Candidates object.
-
-
Method Detail
-
getNbResources
public int getNbResources()
-
getHosts
public java.util.Map<org.osgi.resource.Resource,org.osgi.resource.Resource> getHosts()
-
getDelta
public java.lang.Object getDelta()
Returns the delta which is the differences in the candidates from the original Candidates permutation.- Returns:
- the delta
-
addMandatoryResources
public void addMandatoryResources(java.util.Collection<org.osgi.resource.Resource> resources)
-
populate
public ResolutionError populate(ResolveContext rc, java.util.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(java.util.List<Candidates> importPermutations)
-
isSubstituted
private boolean isSubstituted(org.osgi.resource.Capability substitutableCap, java.util.Map<org.osgi.resource.Capability,java.lang.Integer> substituteStatuses)
-
populateDynamic
public ResolutionError populateDynamic(ResolveContext rc, org.osgi.resource.Resource resource, org.osgi.resource.Requirement req, java.util.List<org.osgi.resource.Capability> candidates)
-
processCandidates
private ResolutionError processCandidates(ResolveContext rc, java.util.LinkedList<org.osgi.resource.Resource> toPopulate, org.osgi.resource.Requirement req, java.util.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, java.util.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(java.util.Map<org.osgi.resource.Requirement,java.util.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 java.util.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 java.util.List<org.osgi.resource.Capability> clearCandidates(org.osgi.resource.Requirement req, java.util.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 java.util.Map<org.osgi.resource.Capability,java.util.Map<java.lang.String,java.util.Map<org.osgi.framework.Version,java.util.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, java.util.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, java.util.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, java.util.List<Candidates> permutations)
-
canRemoveCandidate
public boolean canRemoveCandidate(org.osgi.resource.Requirement req)
-
permutateIfNeeded
public void permutateIfNeeded(org.osgi.resource.Requirement req, java.util.List<Candidates> permutations)
-
-