- 41558: Don't call synced method on every request, submitted by Arvind Srinivasan.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 7 Feb 2007 22:55:21 +0000 (22:55 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 7 Feb 2007 22:55:21 +0000 (22:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@504727 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/Generator.java
java/org/apache/jasper/compiler/JspRuntimeContext.java
java/org/apache/jasper/runtime/HttpJspBase.java

index c545fcc..b32b014 100644 (file)
@@ -402,7 +402,7 @@ class Generator {
         }
         
         out.printin(VAR_EXPRESSIONFACTORY);
-        out.print(" = JspFactory.getDefaultFactory().getJspApplicationContext(");
+        out.print(" = _jspxFactory.getJspApplicationContext(");
         if (ctxt.isTagFile()) {
             out.print("config");
         } else {
@@ -477,6 +477,9 @@ class Generator {
      * preamble generation)
      */
     private void genPreambleStaticInitializers() throws JasperException {
+        out.printil("private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();");
+        out.println();
+
         // Static data for getDependants()
         out.printil("private static java.util.List _jspx_dependants;");
         out.println();
@@ -594,7 +597,6 @@ class Generator {
         out.println();
 
         // Local variable declarations
-        out.printil("JspFactory _jspxFactory = null;");
         out.printil("PageContext pageContext = null;");
 
         if (pageInfo.isSession())
@@ -624,8 +626,6 @@ class Generator {
         out.printil("try {");
         out.pushIndent();
 
-        out.printil("_jspxFactory = JspFactory.getDefaultFactory();");
-
         out.printin("response.setContentType(");
         out.print(quote(pageInfo.getContentType()));
         out.println(");");
@@ -3307,7 +3307,7 @@ class Generator {
         out.pushIndent();
 
         out
-                .printil("if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);");
+                .printil("_jspxFactory.releasePageContext(_jspx_page_context);");
 
         out.popIndent();
         out.printil("}");
index 2c5d247..b6a712d 100644 (file)
@@ -72,6 +72,26 @@ public final class JspRuntimeContext {
     static {
         JspFactoryImpl factory = new JspFactoryImpl();
         SecurityClassLoad.securityClassLoad(factory.getClass().getClassLoader());
+        if( System.getSecurityManager() != null ) {
+            String basePackage = "org.apache.jasper.";
+            try {
+                factory.getClass().getClassLoader().loadClass( basePackage +
+                                                               "runtime.JspFactoryImpl$PrivilegedGetPageContext");
+                factory.getClass().getClassLoader().loadClass( basePackage +
+                                                               "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
+                factory.getClass().getClassLoader().loadClass( basePackage +
+                                                               "runtime.JspRuntimeLibrary");
+                factory.getClass().getClassLoader().loadClass( basePackage +
+                                                               "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
+                factory.getClass().getClassLoader().loadClass( basePackage +
+                                                               "runtime.ServletResponseWrapperInclude");
+                factory.getClass().getClassLoader().loadClass( basePackage +
+                                                               "servlet.JspServletWrapper");
+            } catch (ClassNotFoundException ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+
         JspFactory.setDefaultFactory(factory);
     }
 
index ac03096..a1b6413 100644 (file)
@@ -41,34 +41,6 @@ public abstract class HttpJspBase
     
 {
     
-    static {
-        if( JspFactory.getDefaultFactory() == null ) {
-            JspFactoryImpl factory = new JspFactoryImpl();
-            if( System.getSecurityManager() != null ) {
-                String basePackage = "org.apache.jasper.";
-                try {
-                    factory.getClass().getClassLoader().loadClass( basePackage +
-                                                                   "runtime.JspFactoryImpl$PrivilegedGetPageContext");
-                    factory.getClass().getClassLoader().loadClass( basePackage +
-                                                                   "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
-                    factory.getClass().getClassLoader().loadClass( basePackage +
-                                                                   "runtime.JspRuntimeLibrary");
-                    factory.getClass().getClassLoader().loadClass( basePackage +
-                                                                   "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
-                    factory.getClass().getClassLoader().loadClass( basePackage +
-                                                                   "runtime.ServletResponseWrapperInclude");
-                    factory.getClass().getClassLoader().loadClass( basePackage +
-                                                                   "servlet.JspServletWrapper");
-                } catch (ClassNotFoundException ex) {
-                    org.apache.juli.logging.LogFactory.getLog( HttpJspBase.class )
-                        .error("Jasper JspRuntimeContext preload of class failed: " +
-                                       ex.getMessage(), ex);
-                }
-            }
-            JspFactory.setDefaultFactory(factory);
-        }
-    }
-
     protected HttpJspBase() {
     }