Author: markt
Date: Tue Feb 12 14:54:52 2013
New Revision: 1445192

URL: http://svn.apache.org/r1445192
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54239
Enable applications to use a custom EL interpreter.
Based on a patch by Sheldon Shao.

Added:
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELInterpreter.java
      - copied unchanged from r1445190, 
tomcat/trunk/java/org/apache/jasper/compiler/ELInterpreter.java
    
tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/ELInterpreterFactory.java
      - copied unchanged from r1445190, 
tomcat/trunk/java/org/apache/jasper/compiler/ELInterpreterFactory.java
    
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java
      - copied unchanged from r1445190, 
tomcat/trunk/test/org/apache/jasper/compiler/TestELInterpreterFactory.java
Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Generator.java
    
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties
    
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_es.properties
    
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_fr.properties
    
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_ja.properties
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1445190

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Generator.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Generator.java?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Generator.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Generator.java Tue Feb 
12 14:54:52 2013
@@ -125,6 +125,8 @@ class Generator {
     
     private final DateFormat timestampFormat;
 
+    private final ELInterpreter elInterpreter;
+
     /**
      * @param s
      *            the input string
@@ -831,8 +833,8 @@ class Generator {
                 }
                 return v;
             } else if (attr.isELInterpreterInput()) {
-                v = JspUtil.interpreterCall(this.isTagFile, v, expectedType,
-                        attr.getEL().getMapName(), false);
+                v = elInterpreter.interpreterCall(ctxt, this.isTagFile, v,
+                        expectedType, attr.getEL().getMapName(), false);
                 if (encode) {
                     return 
"org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("
                             + v + ", request.getCharacterEncoding())";
@@ -917,9 +919,10 @@ class Generator {
             n.setBeginJavaLine(out.getJavaLine());
             if (!pageInfo.isELIgnored() && (n.getEL() != null)) {
                 out.printil("out.write("
-                        + JspUtil.interpreterCall(this.isTagFile, n.getType() +
-                                "{" + n.getText() + "}", String.class,
-                                n.getEL().getMapName(), false) + ");");
+                        + elInterpreter.interpreterCall(ctxt, this.isTagFile,
+                                n.getType() + "{" + n.getText() + "}",
+                                String.class, n.getEL().getMapName(), false) +
+                        ");");
             } else {
                 out.printil("out.write("
                         + quote(n.getType() + "{" + n.getText() + "}") + ");");
@@ -2977,8 +2980,8 @@ class Generator {
                     // run attrValue through the expression interpreter
                     String mapName = (attr.getEL() != null) ? attr.getEL()
                             .getMapName() : null;
-                    attrValue = JspUtil.interpreterCall(this.isTagFile, 
attrValue,
-                            c[0], mapName, false);
+                    attrValue = elInterpreter.interpreterCall(ctxt,
+                            this.isTagFile, attrValue, c[0], mapName, false);
                 }
             } else {
                 attrValue = convertString(c[0], attrValue, localName,
@@ -3416,7 +3419,7 @@ class Generator {
     /**
      * Constructor.
      */
-    Generator(ServletWriter out, Compiler compiler) {
+    Generator(ServletWriter out, Compiler compiler) throws JasperException {
         this.out = out;
         methodsBuffered = new ArrayList<GenBuffer>();
         charArrayBuffer = null;
@@ -3425,6 +3428,16 @@ class Generator {
         fragmentHelperClass = new FragmentHelperClass("Helper");
         pageInfo = compiler.getPageInfo();
 
+        ELInterpreter elInterpreter = null;
+        try {
+            elInterpreter = ELInterpreterFactory.getELInterpreter(
+                    compiler.getCompilationContext().getServletContext());
+        } catch (Exception e) {
+            err.jspError("jsp.error.el_interpreter_class.instantiation",
+                    e.getMessage());
+        }
+        this.elInterpreter = elInterpreter;
+
         /*
          * Temporary hack. If a JSP page uses the "extends" attribute of the
          * page directive, the _jspInit() method of the generated servlet class

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties 
(original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties 
Tue Feb 12 14:54:52 2013
@@ -492,3 +492,6 @@ xmlParser.skipBomFail=Failed to skip BOM
 
 jsp.tldCache.noTldInJar=No TLD files were found in [{0}]. Consider adding the 
JAR to the tomcat.util.scan.DefaultJarScanner.jarsToSkip or 
org.apache.catalina.startup.TldConfig.jarsToSkip property in 
CATALINA_BASE/conf/catalina.properties file.
 jsp.tldCache.noTldSummary=At least one JAR was scanned for TLDs yet contained 
no TLDs. Enable debug logging for this logger for a complete list of JARs that 
were scanned but no TLDs were found in them. Skipping unneeded JARs during 
scanning can improve startup time and JSP compilation time.
+
+#ELInterpreter
+jsp.error.el_interpreter_class.instantiation=Failed to load or instantiate 
ELInterpreter class [{0}]
\ No newline at end of file

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_es.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_es.properties?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_es.properties
 (original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_es.properties
 Tue Feb 12 14:54:52 2013
@@ -480,3 +480,6 @@ jsp.message.jsp_unload_check = Revisando
 xmlParser.skipBomFail = No pude saltar BOM al analizar flujo de entrada XML 
 jsp.tldCache.noTldInJar = No se han hallado ficheros TLD en [{0}]. Considera 
a\u00F1adir el JAR a la propiedad tomcat.util.scan.DefaultJarScanner.jarsToSkip 
en el fichero  CATALINA_BASE/conf/catalina.propeperties.
 jsp.tldCache.noTldSummary = Al menos un JAR, que se ha explorado buscando 
TLDs, a\u00FAn no conten\u00EDa TLDs. Activar historial de depuraci\u00F3n para 
este historiador para una completa lista de los JARs que fueron explorados y de 
los que nos se hall\u00F3 TLDs. Saltarse JARs no necesarios durante la 
exploraci\u00F3n puede dar lugar a una mejora de tiempo significativa en el 
arranque y compilaci\u00F3n de JSP .
+
+#ELInterpreter
+jsp.error.el_interpreter_class.instantiation=No se puede cargar la clase 
ELInterpreter llamada [{0}]
\ No newline at end of file

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_fr.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_fr.properties?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_fr.properties
 (original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_fr.properties
 Tue Feb 12 14:54:52 2013
@@ -314,3 +314,6 @@ jsp.error.attributes.not.allowed = {0} n
 #jsp.error.jspoutput.nonemptybody=
 #jsp.error.jspoutput.invalidUse=
 #jsp.error.invalid.bean=
+
+#ELInterpreter
+jsp.error.el_interpreter_class.instantiation=Impossible de charger ou 
d''instancier la classe ELInterpreter [{0}]
\ No newline at end of file

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_ja.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_ja.properties?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_ja.properties
 (original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/resources/LocalStrings_ja.properties
 Tue Feb 12 14:54:52 2013
@@ -415,3 +415,5 @@ jsp.error.unbalanced.endtag=\u7d42\u4e86
 jsp.error.invalid.bean=useBean\u306e\u30af\u30e9\u30b9\u5c5e\u6027 {0} 
\u306e\u5024\u304c\u7121\u52b9\u3067\u3059
 
jsp.error.prefix.use_before_dcl=\u3053\u306e\u30bf\u30b0\u6307\u793a\u5b50\u3067\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u30d7\u30ea\u30d5\u30a3\u30c3\u30af\u30b9
 {0} \u306f\u3001\u3059\u3067\u306b\u30d5\u30a1\u30a4\u30eb {1} \u306e {2} 
\u884c\u76ee\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059
 
+#ELInterpreter
+jsp.error.el_interpreter_class.instantiation=ELInterpreter 
class\u306e\u30ed\u30fc\u30c9\u53c8\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u306b\u5931\u6557\u3057\u307e\u3057\u305f
 [{0}]
\ No newline at end of file

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Feb 12 14:54:52 2013
@@ -76,6 +76,15 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <add>
+        <bug>54239</bug>: Enable web applications to provide their own
+        Expression Language interpreter to enable them to optimise processing 
of
+        expressions. Based on a patch by Sheldon Shao. (markt)
+      </add>
+    </changelog>
+  </subsection>
   <subsection name="Web applications">
     <changelog>
       <add>

Modified: tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml?rev=1445192&r1=1445191&r2=1445192&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml Tue Feb 12 14:54:52 2013
@@ -380,6 +380,28 @@ depending on the application.</li>
 </p>
 </section>
 
+<section name="Optimisation">
+<p>
+There are a number of extension points provided within Jasper that enable the
+user to optimise the behaviour for their environment.
+</p>
+
+<p>
+The first of these extension points is the tag plug-in mechanism. This allows
+alternative implementations of tag handlers to be provided for a web 
application
+to use. Tag plug-ins are registered via a <code>tagPlugins.xml</code> file
+located under <code>WEB-INF</code>. A sample plug-in for the JSTL is included
+with Jasper. 
+</p>
+
+<p>
+The second extension point is the Expression Language interpreter. Alternative
+interpreters may be configured through the <code>ServletContext</code>. See the
+<code>ELInterpreterFactory</code> javadoc for details of how to configure an
+alternative EL interpreter. 
+</p>
+</section> 
+
 </body>
 
 </document>



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

Reply via email to