* 2.2 No, Construct the EXCLUDED_JAR_URLS, which is required by many other components,
* even the Servlet Container for dynamic ServletRegistration/FilterRegistration
*/
public static WebFragmentEntry[] absoluteOrderWebFragments(EARContext earContext, Module module, Bundle bundle, WebAppType webApp, Map<String, WebFragmentEntry> webFragmentEntryMap)
throws DeploymentException {
AbsoluteOrderingType absoluteOrdering = webApp.getAbsoluteOrderingArray()[0];
Set<String> expliciteConfiguredWebFragmentNames = new LinkedHashSet<String>();
List<WebFragmentEntry> orderedWebFragments = new LinkedList<WebFragmentEntry>();
boolean othersConfigured = absoluteOrdering.getOthersArray().length != 0;
if (othersConfigured) {
/*
* If the <others/> element appears directly within the <absolute-
ordering> element, the runtime must ensure that any web-fragments not
explicitly named in the <absolute-ordering> section are included at that
point in the processing order.
* Seems that in xmlbeans, there is no way to know the initial order of the elements
* So using native operation of Node to iterator all the sub elements of absolute-ording
*/
NodeList absoluteOrderingChildren = absoluteOrdering.getDomNode().getChildNodes();
int iOthersIndex = -1;
for (int i = 0; i < absoluteOrderingChildren.getLength(); i++) {
Node node = absoluteOrderingChildren.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equals("name")) {
String webFragmentName = node.getChildNodes().item(0).getNodeValue();
if (webFragmentEntryMap.containsKey(webFragmentName) && !expliciteConfiguredWebFragmentNames.contains(webFragmentName)) {
expliciteConfiguredWebFragmentNames.add(webFragmentName);
orderedWebFragments.add(webFragmentEntryMap.get(webFragmentName));
}
} else if (node.getNodeName().equals("others")) {
iOthersIndex = expliciteConfiguredWebFragmentNames.size();
}
}
}
//Process left named web-fragment.xml files
for (String webFragmentName : webFragmentEntryMap.keySet()) {
if (!expliciteConfiguredWebFragmentNames.contains(webFragmentName)) {
orderedWebFragments.add(iOthersIndex++, webFragmentEntryMap.get(webFragmentName));
}
}
} else {
for (JavaIdentifierType javaIdentifier : absoluteOrdering.getNameArray()) {
String webFragmentName = javaIdentifier.getStringValue();
// Only process the web-fragment.xml when it is present and it is not processed before
if (webFragmentEntryMap.containsKey(webFragmentName) && !expliciteConfiguredWebFragmentNames.contains(webFragmentName)) {
expliciteConfiguredWebFragmentNames.add(webFragmentName);
orderedWebFragments.add(webFragmentEntryMap.get(webFragmentName));