geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r940027 - /geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java
Date Sat, 01 May 2010 14:06:09 GMT
Author: xuhaihong
Date: Sat May  1 14:06:09 2010
New Revision: 940027

URL: http://svn.apache.org/viewvc?rev=940027&view=rev
Log:
ORDERED_LIBS should be null if no absolute or relative ordering has been specified

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java?rev=940027&r1=940026&r2=940027&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/MergeHelper.java
Sat May  1 14:06:09 2010
@@ -190,7 +190,9 @@ public class MergeHelper {
                 }
             }
         }
-        return orderedWebFragments.toArray(new WebFragmentEntry[0]);
+        WebFragmentEntry[] webFragmentEntries = orderedWebFragments.toArray(new WebFragmentEntry[0]);
+        saveOrderedLibAttribute(earContext, webFragmentEntries);
+        return webFragmentEntries;
     }
 
     @SuppressWarnings("unchecked")
@@ -381,16 +383,6 @@ public class MergeHelper {
             }
         }
         WebFragmentEntry[] webFragmentEntries = sortWebFragments(earContext, module, bundle,
webApp, jarUrlWebFragmentDocumentMap);
-        //Save ORDERED_LIBS Attribute
-        List<String> orderedLibs = new ArrayList<String>();
-        for (WebFragmentEntry webFragmentEntry : webFragmentEntries) {
-            String jarURL = webFragmentEntry.getJarURL();
-            int iBeginIndex = jarURL.indexOf("WEB-INF/");
-            if (iBeginIndex > 0) {
-                orderedLibs.add(jarURL.substring(iBeginIndex + 8));
-            }
-        }
-        earContext.getGeneralData().put(AbstractWebModuleBuilder.ORDERED_LIBS, orderedLibs);
         //
         MergeContext mergeContext = new MergeContext();
         mergeContext.setEarContext(earContext);
@@ -433,8 +425,17 @@ public class MergeHelper {
             throws DeploymentException {
         Map<String, WebFragmentOrderEntry> webFragmentOrderEntryMap = new LinkedHashMap<String,
WebFragmentOrderEntry>();
         //Step 1 : Create WebFragmentOrderEntry for sorting web fragments easily
+        boolean relativeSortRequired = false;
         for (String webFragmentName : webFragmentEntryMap.keySet()) {
-            webFragmentOrderEntryMap.put(webFragmentName, WebFragmentOrderEntry.create(webFragmentEntryMap.get(webFragmentName)));
+            WebFragmentEntry webFragmentEntry = webFragmentEntryMap.get(webFragmentName);
+            if (!relativeSortRequired) {
+                relativeSortRequired = webFragmentEntry.getWebFragment().getOrderingArray().length
> 0;
+            }
+            webFragmentOrderEntryMap.put(webFragmentName, WebFragmentOrderEntry.create(webFragmentEntry));
+        }
+        //If none of the web-fragment.xml defines the order element, the order of jar files
are unknown
+        if (!relativeSortRequired) {
+            return webFragmentOrderEntryMap.values().toArray(new WebFragmentEntry[0]);
         }
         //Step 2 : Initialize the list by before/after others configurations, also, convert
the before configurations to corresponding after configurations
         //TODO Is the reference like A before others and B before A allowed ?
@@ -468,6 +469,7 @@ public class MergeHelper {
         for (WebFragmentOrderEntry webFragmentOrderEntry : webFragmentOrderEntryList) {
             webFragmentTypes[iIndex++] = webFragmentOrderEntry.webFragmentEntry;
         }
+        saveOrderedLibAttribute(earContext, webFragmentTypes);
         return webFragmentTypes;
     }
 
@@ -574,6 +576,19 @@ public class MergeHelper {
         }
     }
 
+    private static void saveOrderedLibAttribute(EARContext earContext, WebFragmentEntry[]
webFragmentEntries) {
+        //Save ORDERED_LIBS Attribute
+        List<String> orderedLibs = new ArrayList<String>();
+        for (WebFragmentEntry webFragmentEntry : webFragmentEntries) {
+            String jarURL = webFragmentEntry.getJarURL();
+            int iBeginIndex = jarURL.indexOf("WEB-INF/");
+            if (iBeginIndex > 0) {
+                orderedLibs.add(jarURL.substring(iBeginIndex + 8));
+            }
+        }
+        earContext.getGeneralData().put(AbstractWebModuleBuilder.ORDERED_LIBS, orderedLibs);
+    }
+
     private static class WebFragmentOrderEntry {
 
         public boolean afterDefined;



Mime
View raw message