final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
// extract deployment metadata
List<AnnotationInstance> processApplicationAnnotations = null;
List<AnnotationInstance> postDeployAnnnotations = null;
List<AnnotationInstance> preUndeployAnnnotations = null;
Set<ClassInfo> servletProcessApplications = null;
if(compositeIndex != null) {
processApplicationAnnotations = compositeIndex.getAnnotations(DotName.createSimple(ProcessApplication.class.getName()));
postDeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PostDeploy.class.getName()));
preUndeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(PreUndeploy.class.getName()));
servletProcessApplications = compositeIndex.getAllKnownSubclasses(DotName.createSimple(ServletProcessApplication.class.getName()));
} else {
return null;
}
if(processApplicationAnnotations.isEmpty()) {
// no pa found, this is not a process application deployment.
return null;
} else if(processApplicationAnnotations.size() > 1) {
// found multiple PAs -> unsupported.
throw new DeploymentUnitProcessingException("Detected multiple classes annotated with @" + ProcessApplication.class.getSimpleName()
+ ". A deployment must only provide a single @" + ProcessApplication.class.getSimpleName()
+ " class.");
} else {
// found single PA
AnnotationInstance annotationInstance = processApplicationAnnotations.get(0);
ClassInfo paClassInfo = (ClassInfo) annotationInstance.target();
String paClassName = paClassInfo.name().toString();
ComponentDescription paComponent = null;
// it can either be a Servlet Process Application or a Singleton Session Bean Component or
if(servletProcessApplications.contains(paClassInfo)) {
// Servlet Process Applications can only be deployed inside Web Applications
if(warMetaData == null) {
throw new DeploymentUnitProcessingException("@ProcessApplication class is a ServletProcessApplication but deployment is not a Web Application.");
}
// check whether it's already a servlet context listener:
JBossWebMetaData mergedJBossWebMetaData = warMetaData.getMergedJBossWebMetaData();
List<ListenerMetaData> listeners = mergedJBossWebMetaData.getListeners();
if(listeners == null) {
listeners = new ArrayList<ListenerMetaData>();
mergedJBossWebMetaData.setListeners(listeners);
}