java.module
Interface ImportPolicy


public interface ImportPolicy

This interface represents the import policy of a module definition. The import policy is used to determine the list of imported module definitions in the resolving process to prepare the module instance.

Since:
1.7.0
Author:
Andreas Sterbenz, Dave Bristor, Stanley M. Ho
See Also:
ImportDependency, ImportOverridePolicy, Module, ModuleDefinition, UnsatisfiedDependencyException, VersionConstraint

Method Summary
 List<ModuleDefinition> getImports(ModuleDefinition moduleDef, Map<String,VersionConstraint> constraints, ImportPolicy defaultImportPolicy)
          Returns a list of imported module definitions for preparing this module instance.
 

Method Detail

getImports

List<ModuleDefinition> getImports(ModuleDefinition moduleDef,
                                  Map<String,VersionConstraint> constraints,
                                  ImportPolicy defaultImportPolicy)
                                  throws ModuleInitializationException
Returns a list of imported module definitions for preparing this module instance.

The list of import dependencies that is returned from the getImportDependencies() method of the ModuleDefinition object only reflects the import dependencies with the original version constraints that were specified in the module definition at build time. However, it is possible that deployers might have used the system's import override policy to narrow these version constraints at deployment time to control the actual resolution.

Implementation of the import policy may use the map of imported module names and overridden version constraints to determine if the version constraint of an imported module has been overridden. The map is passed in one of the parameters of this method.

Implementation of the import policy may use the default import policy instance for determining the list of default imported module definitions for resolving, and it is passed in one of the parameters of this method.

Implementation of the import policy should return a list of imported module definitions after it resolves the imports. The order of the imported module definitions in the list must follow the exact declared order of the corresponding imports. If an import cannot be resolved and the import dependency is mandatory (i.e. non-optional), UnsatisfiedDependencyException must be thrown. If an import cannot be resolved and the import dependency is optional, null must be used to represent the missing imported module definition in the list.

Parameters:
moduleDef - the module definition of this module instance.
constraints - an unmodifiable map of imported module names and overridden version constraints.
defaultImportPolicy - the default import policy for this module instance.
Returns:
a list of imported module definitions for preparing this module instance in the resolving process.
Throws:
UnsatisfiedDependencyException - if an import dependency cannot be satisfied.
ModuleInitializationException