Author: markt
Date: Thu Sep 19 13:07:02 2013
New Revision: 1524727

URL: http://svn.apache.org/r1524727
Log:
Always load container SCIs first

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java?rev=1524727&r1=1524726&r2=1524727&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java Thu 
Sep 19 13:07:02 2013
@@ -75,7 +75,9 @@ public class WebappServiceLoader<T> {
     public List<T> load(Class<T> serviceType) throws IOException {
         String configFile = SERVICES + serviceType.getName();
 
-        LinkedHashSet<String> servicesFound = new LinkedHashSet<>();
+        LinkedHashSet<String> applicationServicesFound = new LinkedHashSet<>();
+        LinkedHashSet<String> containerServicesFound = new LinkedHashSet<>();
+
         ClassLoader loader = context.getClassLoader();
 
         // if the ServletContext has ORDERED_LIBS, then use that to specify the
@@ -100,7 +102,7 @@ public class WebappServiceLoader<T> {
                     url = new URL("jar:" + base + "!/" + configFile);
                 }
                 try {
-                    parseConfigFile(servicesFound, url);
+                    parseConfigFile(applicationServicesFound, url);
                 } catch (FileNotFoundException e) {
                     // no provider file found, this is OK
                 }
@@ -117,14 +119,18 @@ public class WebappServiceLoader<T> {
             resources = loader.getResources(configFile);
         }
         while (resources.hasMoreElements()) {
-            parseConfigFile(servicesFound, resources.nextElement());
+            parseConfigFile(containerServicesFound, resources.nextElement());
         }
 
+        // Add the application services after the container services to ensure
+        // that the container services are loaded first
+        containerServicesFound.addAll(applicationServicesFound);
+
         // load the discovered services
-        if (servicesFound.isEmpty()) {
+        if (containerServicesFound.isEmpty()) {
             return Collections.emptyList();
         }
-        return loadServices(serviceType, servicesFound);
+        return loadServices(serviceType, containerServicesFound);
     }
 
     void parseConfigFile(LinkedHashSet<String> servicesFound, URL url)



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to