if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
return; // Skip non web deployments
}
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
assert warMetaData != null;
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (module == null) {
throw new DeploymentUnitProcessingException("failed to resolve module for " + deploymentUnit);
}
final ClassLoader classLoader = module.getClassLoader();
ScisMetaData scisMetaData = deploymentUnit.getAttachment(ScisMetaData.ATTACHMENT_KEY);
if (scisMetaData == null) {
scisMetaData = new ScisMetaData();
deploymentUnit.putAttachment(ScisMetaData.ATTACHMENT_KEY, scisMetaData);
}
Set<ServletContainerInitializer> scis = scisMetaData.getScis();
if (scis == null) {
scis = new HashSet<ServletContainerInitializer>();
scisMetaData.setScis(scis);
}
Map<ServletContainerInitializer, Set<Class<?>>> handlesTypes = scisMetaData.getHandlesTypes();
if (handlesTypes == null) {
handlesTypes = new HashMap<ServletContainerInitializer, Set<Class<?>>>();
scisMetaData.setHandlesTypes(handlesTypes);
}
// Find the SCIs from shared modules
for (ModuleDependency dependency : moduleSpecification.getSystemDependencies()) {
ServiceLoader<ServletContainerInitializer> serviceLoader;
try {
Module depModule = loader.loadModule(dependency.getIdentifier());
serviceLoader = depModule.loadService(ServletContainerInitializer.class);
for (ServletContainerInitializer service : serviceLoader) {
scis.add(service);
}
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException("Error loading SCI from module: " + dependency.getIdentifier(), e);