Class Candidates
java.lang.Object
org.apache.felix.framework.resolver.Candidates
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<BundleRevision, WrappedRevision> private final Map
<BundleRequirement, List<BundleCapability>> private final Map
<BundleCapability, Set<BundleRequirement>> private boolean
private final Set
<BundleRevision> private final Map
<BundleRevision, Object> static final int
static final int
static final int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs an empty Candidates object.private
Candidates
(Set<BundleRevision> mandatoryRevisions, Map<BundleCapability, Set<BundleRequirement>> dependentMap, Map<BundleRequirement, List<BundleCapability>> candidateMap, Map<BundleRevision, WrappedRevision> wrappedHosts, Map<BundleRevision, Object> populateResultCache, boolean fragmentsPresent) Private copy constructor used by the copy() method. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
add
(Map<BundleRequirement, List<BundleCapability>> candidates) Adds requirements and candidates in bulk.private void
add
(BundleRequirement req, List<BundleCapability> candidates) Adds a requirement and its matching candidates to the internal data structure.copy()
Creates a copy of the Candidates object.void
dump()
Gets the candidates associated with a given requirement.getResolveException
(BundleRevision revision) Returns the wrapped module associated with the given module.boolean
isPopulated
(BundleRevision revision) final void
populate
(ResolveContext rc, BundleRevision revision, int resolution) Populates candidates for the specified revision.private Map
<BundleCapability, Map<String, Map<Version, List<BundleRequirement>>>> void
populateDynamic
(ResolveContext rc, BundleRevision revision, BundleRequirement req, List<BundleCapability> candidates) private boolean
populateFragmentOndemand
(ResolveContext rc, BundleRevision revision) private void
populateRevision
(ResolveContext rc, BundleRevision revision) Populates candidates for the specified revision.void
Merges fragments into their hosts.private ResolveException
processCandidates
(ResolveContext rc, BundleRevision revision, List<BundleCapability> candidates) This method performs common processing on the given set of candidates.private void
remove
(BundleCapability c, Set<BundleRevision> unresolvedRevisions) Removes a capability from the internal data structures.private void
remove
(BundleRequirement req) Removes a requirement from the internal data structures.private void
remove
(BundleRevision br, Set<BundleRevision> unresolvedRevisions) Removes the specified module from the internal data structures, which involves removing its requirements and its capabilities.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.
-
Field Details
-
MANDATORY
public static final int MANDATORY- See Also:
-
OPTIONAL
public static final int OPTIONAL- See Also:
-
ON_DEMAND
public static final int ON_DEMAND- See Also:
-
m_mandatoryRevisions
-
m_dependentMap
-
m_candidateMap
-
m_allWrappedHosts
-
m_populateResultCache
-
m_fragmentsPresent
private boolean m_fragmentsPresent
-
-
Constructor Details
-
Candidates
private Candidates(Set<BundleRevision> mandatoryRevisions, Map<BundleCapability, Set<BundleRequirement>> dependentMap, Map<BundleRequirement, List<BundleCapability>> candidateMap, Map<BundleRevision, WrappedRevision> wrappedHosts, Map<BundleRevision, Object> populateResultCache, boolean fragmentsPresent) Private copy constructor used by the copy() method.- Parameters:
dependentMap
- the capability dependency map.candidateMap
- the requirement candidate map.wrappedHosts
- the wrapped hosts map.hostFragments
- the fragment map.
-
Candidates
public Candidates()Constructs an empty Candidates object.
-
-
Method Details
-
populate
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
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
-
getResolveException
-
add
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
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
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
Gets the candidates associated with a given requirement.- Parameters:
req
- the requirement whose candidates are desired.- Returns:
- the matching candidates or null.
-
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.- Parameters:
existingSingletons
- existing resolved singletons.- Throws:
ResolveException
- if the removal of any unselected fragments result in the root module being unable to resolve.
-
populateDependents
-
removeRevision
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
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
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()
-