// order
// For each JAR in the order:
// - Merge the annotation metadata into the fragment meta data
// (unless the fragment exists and is meta data complete)
// - Merge the fragment metadata into merged fragment meta data
WebCommonMetaData mergedFragmentMetaData = new WebCommonMetaData();
if (specMetaData == null) {
// If there is no web.xml, it has to be considered to be the latest version
specMetaData = new Web30MetaData();
specMetaData.setVersion("3.0");
}
// Augment with meta data from annotations in /WEB-INF/classes
WebMetaData classesAnnotatedMetaData = annotationsMetaData.get("");
if (classesAnnotatedMetaData != null) {
if (isComplete) {
// Discard @WebFilter, @WebListener and @WebServlet
classesAnnotatedMetaData.setFilters(null);
classesAnnotatedMetaData.setFilterMappings(null);
classesAnnotatedMetaData.setListeners(null);
classesAnnotatedMetaData.setServlets(null);
classesAnnotatedMetaData.setServletMappings(null);
}
specMetaData.augment(classesAnnotatedMetaData, null, true);
}
// Augment with meta data from fragments and annotations from the
// corresponding JAR
for (String jar : order) {
WebFragmentMetaData webFragmentMetaData = webFragments.get(jar);
if (webFragmentMetaData == null) {
webFragmentMetaData = new WebFragmentMetaData();
// Add non overriding default distributable flag
webFragmentMetaData.setDistributable(new EmptyMetaData());
}
WebMetaData jarAnnotatedMetaData = annotationsMetaData.get(jar);
if ((isComplete || webFragmentMetaData.isMetadataComplete()) && jarAnnotatedMetaData != null) {
// Discard @WebFilter, @WebListener and @WebServlet
jarAnnotatedMetaData.setFilters(null);
jarAnnotatedMetaData.setFilterMappings(null);
jarAnnotatedMetaData.setListeners(null);
jarAnnotatedMetaData.setServlets(null);
jarAnnotatedMetaData.setServletMappings(null);
}
if (jarAnnotatedMetaData != null) {
// Merge annotations corresponding to the JAR
webFragmentMetaData.augment(jarAnnotatedMetaData, null, true);
}
// Merge fragment meta data according to the conflict rules
try {
mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false);
} catch (Exception e) {
throw new DeploymentUnitProcessingException("Deployment error processing fragment for JAR: " + jar, e);
}
}
// Augment with meta data from annotations from JARs excluded from the
// order
for (String jar : jarsSet) {
WebFragmentMetaData webFragmentMetaData = new WebFragmentMetaData();
// Add non overriding default distributable flag
webFragmentMetaData.setDistributable(new EmptyMetaData());
WebMetaData jarAnnotatedMetaData = annotationsMetaData.get(jar);
if (jarAnnotatedMetaData != null) {
// Discard @WebFilter, @WebListener and @WebServlet
jarAnnotatedMetaData.setFilters(null);
jarAnnotatedMetaData.setFilterMappings(null);
jarAnnotatedMetaData.setListeners(null);
jarAnnotatedMetaData.setServlets(null);
jarAnnotatedMetaData.setServletMappings(null);
}
if (jarAnnotatedMetaData != null) {
// Merge annotations corresponding to the JAR
webFragmentMetaData.augment(jarAnnotatedMetaData, null, true);
}
// Merge fragment meta data according to the conflict rules
try {
mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false);
} catch (Exception e) {
throw new DeploymentUnitProcessingException("Deployment error processing fragment for JAR: " + jar, e);
}
}
specMetaData.augment(mergedFragmentMetaData, null, true);