This method is called by the framework each time a resolve process begins to obtain a {@link ResolverHook resolver hook} instance. This resolverhook instance will be used for the duration of the resolve process. At the end of the resolve process the method {@link ResolverHook#end()} mustbe called by the framework and the framework must not hold any references of the resolver hook instance.
The triggers represent the collection of bundles which triggered the resolve process. This collection may be empty if the triggers cannot be determined by the framework. In most cases the triggers can easily be determined. Calling certain methods on {@link Bundle bundle} when abundle is in the {@link Bundle#INSTALLED INSTALLED} state will cause theframework to begin a resolve process in order to resolve the bundle. The following methods will start a resolve process in this case:
- {@link Bundle#start() start}
- {@link Bundle#loadClass(String) loadClass}
- {@link Bundle#findEntries(String,String,boolean) findEntries}
- {@link Bundle#getResource(String) getResource}
- {@link Bundle#getResources(String) getResources}
In such cases the collection will contain the single bundle which the framework is trying to resolve. Other cases will cause multiple bundles to be included in the trigger bundles collection. When {@link FrameworkWiring#resolveBundles(Collection) resolveBundles} iscalled the collection of triggers must include all the current bundle revisions for bundles passed to resolveBundles which are in the {@link Bundle#INSTALLED INSTALLED} state.
When {@link FrameworkWiring#refreshBundles(Collection,org.osgi.framework.FrameworkListener)}is called the collection of triggers is determined with the following steps:
- If the collection of bundles passed is null then {@link FrameworkWiring#getRemovalPendingBundles()} is called to get theinitial collection of bundles.
- The equivalent of calling {@link FrameworkWiring#getDependencyClosure(Collection)} is called withthe initial collection of bundles to get the dependency closure collection of the bundles being refreshed.
- Remove any non-active bundles from the dependency closure collection.
- For each bundle remaining in the dependency closure collection get the current bundle revision and add it to the collection of triggers.
As described above, a resolve process is typically initiated as a result of calling API that causes the framework to attempt to resolve one or more bundles. The framework is free to start a resolve process at any time for reasons other than calls to framework API. For example, a resolve process may be used by the framework for diagnostic purposes and result in no bundles actually becoming resolved at the end of the process. Resolver hook implementations must be prepared for resolve processes that are initiated for other reasons besides calls to framework API.
@param triggers an unmodifiable collection of bundles which triggered theresolve process. This collection may be empty if the collection of trigger bundles cannot be determined.
@return a resolver hook instance to be used for the duration of theresolve process. A {@code null} value may be returned whichindicates this resolver hook factory abstains from the resolve process.