geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1432975 - /geronimo/external/trunk/tomcat-parent-7.0.27/jasper/src/main/java/org/apache/jasper/compiler/TagPluginManager.java
Date Mon, 14 Jan 2013 16:19:22 GMT
Author: gawor
Date: Mon Jan 14 16:19:22 2013
New Revision: 1432975

URL: http://svn.apache.org/viewvc?rev=1432975&view=rev
Log:
Configurable system level tagPlugins.xml - https://issues.apache.org/bugzilla/show_bug.cgi?id=54240

Modified:
    geronimo/external/trunk/tomcat-parent-7.0.27/jasper/src/main/java/org/apache/jasper/compiler/TagPluginManager.java

Modified: geronimo/external/trunk/tomcat-parent-7.0.27/jasper/src/main/java/org/apache/jasper/compiler/TagPluginManager.java
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/tomcat-parent-7.0.27/jasper/src/main/java/org/apache/jasper/compiler/TagPluginManager.java?rev=1432975&r1=1432974&r2=1432975&view=diff
==============================================================================
--- geronimo/external/trunk/tomcat-parent-7.0.27/jasper/src/main/java/org/apache/jasper/compiler/TagPluginManager.java
(original)
+++ geronimo/external/trunk/tomcat-parent-7.0.27/jasper/src/main/java/org/apache/jasper/compiler/TagPluginManager.java
Mon Jan 14 16:19:22 2013
@@ -14,10 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.jasper.compiler;
 
+import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 
@@ -33,9 +35,10 @@ import org.apache.jasper.xmlparser.TreeN
  * Manages tag plugin optimizations.
  * @author Kin-man Chung
  */
-
 public class TagPluginManager {
 
+    private static final String META_INF_JASPER_TAG_PLUGINS_XML =
+            "META-INF/org.apache.jasper/tagPlugins.xml";
     private static final String TAG_PLUGINS_XML = "/WEB-INF/tagPlugins.xml";
     private static final String TAG_PLUGINS_ROOT_ELEM = "tag-plugins";
 
@@ -73,12 +76,62 @@ public class TagPluginManager {
         if (initialized)
             return;
 
-        InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
-        if (is == null)
-            return;
+        tagPlugins = new HashMap<String, TagPlugin>();
+
+        Enumeration<URL> urls = null;
+        try {
+            urls = ctxt.getClassLoader().getResources(
+                    META_INF_JASPER_TAG_PLUGINS_XML);
+        } catch (IOException ioe) {
+            throw new JasperException(ioe);
+        }
+
+        if (urls != null) {
+            while(urls.hasMoreElements()) {
+                URL url = urls.nextElement();
+                InputStream is = null;
+                try {
+                    is = url.openStream();
+                    loadTagPlugins(err, is);
+                } catch(IOException ioe) {
+                    throw new JasperException(ioe);
+                } finally {
+                    if (is != null) {
+                        try {
+                            is.close();
+                        } catch (IOException ioe) {
+                            throw new JasperException(ioe);
+                        }
+                    }
+                }
+            }
+        }
+
+        InputStream is = null;
+        try {
+            is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
+            if (is != null) {
+                loadTagPlugins(err, is);
+            }
+        } finally {
+            try {
+                if (is != null) {
+                    is.close();
+                }
+            } catch (IOException ioe) {
+                throw new JasperException(ioe);
+            }
+        }
+
+        initialized = true;
+    }
+
+
+    private void loadTagPlugins(ErrorDispatcher err, InputStream is)
+            throws JasperException {
 
-        TreeNode root = (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML,
-                                                             is);
+        TreeNode root =
+                (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML, is);
         if (root == null) {
             return;
         }



Mime
View raw message