private static final Logger logger = Logger.getLogger(WarClassloadingDependencyProcessor.class);
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
//we always make the JSF api available
final String jsfVersion = JsfVersionMarker.getVersion(topLevelDeployment);
if(jsfVersion.equals(JsfVersionMarker.JSF_1_2)) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSF_1_2_API, false, false, false));
} else {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSF_API, false, false, false));
}
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
return; // Skip non web deployments
}
// Add module dependencies on Java EE apis
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAVAX_EE_API, false, false, false));
// Add modules for JSF
if(jsfVersion.equals(JsfVersionMarker.JSF_1_2)) {
ModuleDependency jsf = new ModuleDependency(moduleLoader, JSF_1_2_IMPL, false, false, false);
jsf.addImportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(jsf);
} else {
if(!jsfVersion.equals(JsfVersionMarker.JSF_2_0)) {
logger.warn("Ukown JSF version " + jsfVersion + " " + JsfVersionMarker.JSF_2_0 + " will be used instead");
}
ModuleDependency jsf = new ModuleDependency(moduleLoader, JSF_IMPL, false, false, false);
jsf.addImportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(jsf);
}
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, BEAN_VALIDATION, false, false, true));
// FIXME we need to revise the exports of the web module, so that we
// don't export our internals
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JBOSS_WEB, false, false, true));
}