Modules contains a lot of the Qi4j infrastructure, which are the enforcers of these wise modularization principles.
Modules are a concept implemented with a chained set up artifacts;
Standard domain-oriented application seldom (almost never) need to deal with these artifacts. Instead, the Composites of the domain will reside in Modules, and the runtime will ensure that the visibility rules are followed, according to the assembly declarations performed at start-up.
It is not possible to modify the Modules, their resolution nor binding in any way after the application starts. This might be changed in the future, to allow upgrading of Modules, adding new Modules as plug-ins on the fly, and similar dynamic features.
private void validateLayer()
{
ModuleResolution resolution = module.getModuleResolution();
LayerModel layer = resolution.getLayerModel();
if( ! layer.getName().toLowerCase().contains( "domain" ) )
{
String mess =
"MySubSystem must be in a Layer with \"domain\" in the name."
throw new InvalidLayerException( mess );
}
}
}
For even more intricate tooling and highly specialized subsystems, there are additional ModuleInstance and ModuleContext available as well. It is beyond this scope to discuss their use.