Interface ResolverHook
Framework Resolver Hook Factory service.
 
 
 A Resolver Hook instance is called by the framework during a resolve process.
 A resolver hook may influence the outcome of a resolve process by removing
 entries from shrinkable collections that are passed to the hook during a
 resolve process. A shrinkable collection is a Collection that
 supports all remove operations. Any other attempts to modify a shrinkable
 collection will result in an UnsupportedOperationException being
 thrown.
 
 
The following steps outline the way a framework uses the resolver hooks during a resolve process.
- Collect a snapshot of registered resolver hook factories that will be called during the current resolve process. Any hook factories registered after the snapshot is taken must not be called during the current resolve process. A resolver hook factory contained in the snapshot may become unregistered during the resolve process. The framework should handle this and stop calling the resolver hook instance provided by the unregistered hook factory and the current resolve process must fail. If possible, an exception must be thrown to the caller of the API which triggered the resolve process. In cases where the the caller is not available a framework event of type error should be fired.
 - For each registered hook factory call the
 
ResolverHookFactory.begin(Collection)method to inform the hooks about a resolve process beginning and to obtain a Resolver Hook instance that will be used for the duration of the resolve process. - Determine the collection of unresolved bundle revisions that may be
 considered for resolution during the current resolution process and place
 each of the bundle revisions in a shrinkable collection 
Resolvable. For each resolver hook call thefilterResolvable(Collection)method with the shrinkable collectionResolvable. - The shrinkable collection 
Resolvablenow contains all the unresolved bundle revisions that may end up as resolved at the end of the current resolve process. Any other bundle revisions that got removed from the shrinkable collectionResolvablemust not end up as resolved at the end of the current resolve process. - For each bundle revision 
Bleft in the shrinkable collectionResolvableand any bundle revisionBwhich is currently resolved that represents a singleton bundle do the following:- Determine the collection of available capabilities that have a namespace
 of 
osgi.identity, are singletons, and have the same symbolic name as the singleton bundle revisionBand place each of the matching capabilities into a shrinkable collectionCollisions. - Remove the 
osgi.identitycapability provided by bundle revisionBfrom shrinkable collectionCollisions. A singleton bundle cannot collide with itself. - For each resolver hook call the
 
filterSingletonCollisions(BundleCapability, Collection)with theosgi.identitycapability provided by bundle revisionBand the shrinkable collectionCollisions - The shrinkable collection 
Collisionsnow contains all singletonosgi.identitycapabilities that can influence the ability of bundle revisionBto resolve. - If the bundle revision 
Bis already resolved then any resolvable bundle revision contained in the collectionCollisionsis not allowed to resolve. 
 - Determine the collection of available capabilities that have a namespace
 of 
 - During a resolve process a framework is free to attempt to resolve any or
 all bundles contained in shrinkable collection 
Resolvable. For each bundle revisionBleft in the shrinkable collectionResolvablewhich the framework attempts to resolve the following steps must be followed:- For each requirement 
Rspecified by bundle revisionBdetermine the collection of capabilities that satisfy (or match) the requirement and place each matching capability into a shrinkable collectionCandidates. A capability is considered to match a particular requirement if its attributes satisfy a specified requirement and the requirer bundle has permission to access the capability. - For each resolver hook call the
 
filterMatches(BundleRequirement, Collection)with the requirementRand the shrinkable collectionCandidates. - The shrinkable collection 
Candidatesnow contains all the capabilities that may be used to satisfy the requirementR. Any other capabilities that got removed from the shrinkable collectionCandidatesmust not be used to satisfy requirementR. 
 - For each requirement 
 - For each resolver hook call the 
end()method to inform the hooks about a resolve process ending. 
 Resolver hooks are low level. Implementations of the resolver hook must be
 careful not to create an unresolvable state which is very hard for a
 developer or a provisioner to diagnose. Resolver hooks also must not be
 allowed to start another synchronous resolve process (e.g. by calling
 Bundle.start() or FrameworkWiring.resolveBundles(Collection)
 ). The framework must detect this and throw an IllegalStateException.
- Author:
 - $Id: 7b2a0a5dbec7b0e999112ae324d050fcf190fa5d $
 - See Also:
 
- 
Method Summary
Modifier and TypeMethodDescriptionvoidend()This method is called once at the end of the resolve process.voidfilterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) Filter matches hook method.voidfilterResolvable(Collection<BundleRevision> candidates) Filter resolvable candidates hook method.voidfilterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) Filter singleton collisions hook method. 
- 
Method Details
- 
filterResolvable
Filter resolvable candidates hook method. This method may be called multiple times during a single resolve process. This method can filter the collection of candidates by removing potential candidates. Removing a candidate will prevent the candidate from resolving during the current resolve process.- Parameters:
 candidates- the collection of resolvable candidates available during a resolve process.
 - 
filterSingletonCollisions
void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) Filter singleton collisions hook method. This method is called during the resolve process for the specified singleton. The specified singleton represents a singleton capability and the specified collection represent a collection of singleton capabilities which are considered collision candidates. The singleton capability and the collection of collision candidates must all use the same namespace.Currently only capabilities with the namespace of
osgi.wiring.bundleandosgi.identitycan be singletons. The collision candidates will all have the same namespace, be singletons, and have the same symbolic name as the specified singleton capability.In the future, capabilities in other namespaces may support the singleton concept. Hook implementations should be prepared to receive calls to this method for capabilities in namespaces other than
osgi.wiring.bundleorosgi.identity.This method can filter the list of collision candidates by removing potential collisions. Removing a collision candidate will allow the specified singleton to resolve regardless of the resolution state of the removed collision candidate.
- Parameters:
 singleton- the singleton involved in a resolve processcollisionCandidates- a collection of singleton collision candidates
 - 
filterMatches
Filter matches hook method. This method is called during the resolve process for the specified requirement. The collection of candidates match the specified requirement. This method can filter the collection of matching candidates by removing candidates from the collection. Removing a candidate will prevent the resolve process from choosing the removed candidate to satisfy the requirement.All of the candidates will have the same namespace and will match the specified requirement.
If the Java Runtime Environment supports permissions then the collection of candidates will only contain candidates for which the requirer has permission to access.
- Parameters:
 requirement- the requirement to filter candidates forcandidates- a collection of candidates that match the requirement
 - 
end
void end()This method is called once at the end of the resolve process. After the end method is called the resolve process has ended. The framework must not hold onto this resolver hook instance after end has been called. 
 -