- Use the ignore annotation flag.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 9 May 2006 14:05:23 +0000 (14:05 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 9 May 2006 14:05:23 +0000 (14:05 +0000)
- It needs recompilation in case the value is changed. It could do without, but would need
  additional code in the generated servlets (a field, read a servlet context param), so
  it would generally be (even) more intrusive :(

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@405437 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/EmbeddedServletOptions.java
java/org/apache/jasper/JspC.java
java/org/apache/jasper/Options.java
java/org/apache/jasper/compiler/Generator.java
java/org/apache/jasper/runtime/TagHandlerPool.java

index 1ddf066..8059b33 100644 (file)
@@ -174,6 +174,11 @@ public final class EmbeddedServletOptions implements Options {
      */\r
     private boolean xpoweredBy;\r
     \r
+    /**\r
+     * Should annotations be ignored?\r
+     */\r
+    private boolean ignoreAnnotations = false;\r
+    \r
     public String getProperty(String name ) {\r
         return settings.getProperty( name );\r
     }\r
@@ -245,6 +250,13 @@ public final class EmbeddedServletOptions implements Options {
     }\r
     \r
     /**\r
+     * Should annotations on tags be ignored?\r
+     */\r
+    public boolean getIgnoreAnnotations() {\r
+        return ignoreAnnotations;\r
+    }\r
+\r
+    /**\r
      * Is the generation of SMAP info for JSR45 debuggin suppressed?\r
      */\r
     public boolean isSmapSuppressed() {\r
@@ -384,6 +396,11 @@ public final class EmbeddedServletOptions implements Options {
         String validating=config.getInitParameter( "validating");\r
         if( "false".equals( validating )) ParserUtils.validating=false;\r
         \r
+        String annotations = config.getInitParameter("org.apache.jasper.IGNORE_ANNOTATIONS");\r
+        if ("true".equals(annotations)) {\r
+            ignoreAnnotations = true;\r
+        }\r
+\r
         String keepgen = config.getInitParameter("keepgenerated");\r
         if (keepgen != null) {\r
             if (keepgen.equalsIgnoreCase("true")) {\r
index a073e32..cede8b4 100644 (file)
@@ -159,6 +159,7 @@ public class JspC implements Options {
     private boolean smapSuppressed = true;\r
     private boolean smapDumped = false;\r
     private boolean caching = true;\r
+    private boolean ignoreAnnotations = false;\r
     private Map cache = new HashMap();\r
 \r
     private String compiler = null;\r
@@ -590,6 +591,20 @@ public class JspC implements Options {
         compilerSourceVM = vm;\r
     }\r
 \r
+    /**\r
+     * Should annotations on tags be ignored?\r
+     */\r
+    public boolean getIgnoreAnnotations() {\r
+        return ignoreAnnotations;\r
+    }\r
+\r
+    /**\r
+     * Should annotations on tags be ignored?\r
+     */\r
+    public void setIgnoreAnnotations(boolean ignoreAnnotations) {\r
+        this.ignoreAnnotations = ignoreAnnotations;\r
+    }\r
+\r
     public TldLocationsCache getTldLocationsCache() {\r
         return tldLocationsCache;\r
     }\r
index 9eef4d6..56e48dc 100644 (file)
@@ -92,6 +92,11 @@ public interface Options {
     public boolean getTrimSpaces();\r
 \r
     /**\r
+     * Should annotations on tags be ignored?\r
+     */\r
+    public boolean getIgnoreAnnotations();\r
+\r
+    /**\r
      * Class ID for use in the plugin tag when the browser is IE. \r
      */\r
     public String getIeClassId();\r
index 744b9d9..dfd6a52 100644 (file)
@@ -2143,9 +2143,11 @@ class Generator {
                 out.print("new ");\r
                 out.print(tagHandlerClassName);\r
                 out.println("();");\r
-                out.printin("org.apache.jasper.runtime.AnnotationProcessor.postConstruct(");\r
-                out.print(tagHandlerVar);\r
-                out.println(");");\r
+                if (!ctxt.getOptions().getIgnoreAnnotations()) {\r
+                    out.printin("org.apache.jasper.runtime.AnnotationProcessor.postConstruct(");\r
+                    out.print(tagHandlerVar);\r
+                    out.println(");");\r
+                }\r
             }\r
 \r
             // includes setting the context\r
@@ -2291,19 +2293,21 @@ class Generator {
                 } else {\r
                     out.printin(tagHandlerVar);\r
                     out.println(".release();");\r
-                    out.printil("try {");\r
-                    out.pushIndent();\r
-                    out.printin("org.apache.jasper.runtime.AnnotationProcessor.preDestroy(");\r
-                    out.print(tagHandlerVar);\r
-                    out.println(");");\r
-                    out.popIndent();\r
-                    out.printil("} catch (Exception e) {");\r
-                    out.pushIndent();\r
-                    out.printin("log(\"Error processing preDestroy on tag instance of \" +");\r
-                    out.print(tagHandlerVar);\r
-                    out.println(".getClass().getName());");\r
-                    out.popIndent();\r
-                    out.printil("}");\r
+                    if (!ctxt.getOptions().getIgnoreAnnotations()) {\r
+                        out.printil("try {");\r
+                        out.pushIndent();\r
+                        out.printin("org.apache.jasper.runtime.AnnotationProcessor.preDestroy(");\r
+                        out.print(tagHandlerVar);\r
+                        out.println(");");\r
+                        out.popIndent();\r
+                        out.printil("} catch (Exception e) {");\r
+                        out.pushIndent();\r
+                        out.printin("log(\"Error processing preDestroy on tag instance of \" +");\r
+                        out.print(tagHandlerVar);\r
+                        out.println(".getClass().getName());");\r
+                        out.popIndent();\r
+                        out.printil("}");\r
+                    }\r
                 }\r
             }\r
             if (isTagFile || isFragment) {\r
@@ -2346,19 +2350,21 @@ class Generator {
             } else {\r
                 out.printin(tagHandlerVar);\r
                 out.println(".release();");\r
-                out.printil("try {");\r
-                out.pushIndent();\r
-                out.printin("org.apache.jasper.runtime.AnnotationProcessor.preDestroy(");\r
-                out.print(tagHandlerVar);\r
-                out.println(");");\r
-                out.popIndent();\r
-                out.printil("} catch (Exception e) {");\r
-                out.pushIndent();\r
-                out.printin("log(\"Error processing preDestroy on tag instance of \" +");\r
-                out.print(tagHandlerVar);\r
-                out.println(".getClass().getName());");\r
-                out.popIndent();\r
-                out.printil("}");\r
+                if (!ctxt.getOptions().getIgnoreAnnotations()) {\r
+                    out.printil("try {");\r
+                    out.pushIndent();\r
+                    out.printin("org.apache.jasper.runtime.AnnotationProcessor.preDestroy(");\r
+                    out.print(tagHandlerVar);\r
+                    out.println(");");\r
+                    out.popIndent();\r
+                    out.printil("} catch (Exception e) {");\r
+                    out.pushIndent();\r
+                    out.printin("log(\"Error processing preDestroy on tag instance of \" +");\r
+                    out.print(tagHandlerVar);\r
+                    out.println(".getClass().getName());");\r
+                    out.popIndent();\r
+                    out.printil("}");\r
+                }\r
             }\r
 \r
             if (n.implementsTryCatchFinally()) {\r
@@ -2399,9 +2405,11 @@ class Generator {
             out.println("();");\r
 \r
             // Resource injection\r
-            out.printin("org.apache.jasper.runtime.AnnotationProcessor.postConstruct(");\r
-            out.print(tagHandlerVar);\r
-            out.println(");");\r
+            if (!ctxt.getOptions().getIgnoreAnnotations()) {\r
+                out.printin("org.apache.jasper.runtime.AnnotationProcessor.postConstruct(");\r
+                out.print(tagHandlerVar);\r
+                out.println(");");\r
+            }\r
             \r
             generateSetters(n, tagHandlerVar, handlerInfo, true);\r
 \r
@@ -2447,9 +2455,11 @@ class Generator {
             syncScriptingVars(n, VariableInfo.AT_END);\r
 \r
             // Resource injection\r
-            out.printin("org.apache.jasper.runtime.AnnotationProcessor.preDestroy(");\r
-            out.print(tagHandlerVar);\r
-            out.println(");");\r
+            if (!ctxt.getOptions().getIgnoreAnnotations()) {\r
+                out.printin("org.apache.jasper.runtime.AnnotationProcessor.preDestroy(");\r
+                out.print(tagHandlerVar);\r
+                out.println(");");\r
+            }\r
 \r
             n.setEndJavaLine(out.getJavaLine());\r
         }\r
index 5574ccf..8e2d341 100644 (file)
@@ -40,6 +40,7 @@ public class TagHandlerPool {
     \r
     // index of next available tag handler\r
     private int current;\r
+    private boolean ignoreAnnotations = false;\r
 \r
     public static TagHandlerPool getTagHandlerPool( ServletConfig config) {\r
         TagHandlerPool result=null;\r
@@ -75,6 +76,10 @@ public class TagHandlerPool {
         }\r
         this.handlers = new Tag[maxSize];\r
         this.current = -1;\r
+        String annotations = getOption(config, "org.apache.jasper.IGNORE_ANNOTATIONS", null);\r
+        if ("true".equals(annotations)) {\r
+            ignoreAnnotations = true;\r
+        }\r
     }\r
 \r
     /**\r
@@ -119,7 +124,9 @@ public class TagHandlerPool {
         // wait for us to construct a tag for this thread.\r
         try {\r
             Tag instance = (Tag) handlerClass.newInstance();\r
-            AnnotationProcessor.postConstruct(instance);\r
+            if (!ignoreAnnotations) {\r
+                AnnotationProcessor.postConstruct(instance);\r
+            }\r
             return instance;\r
         } catch (Exception e) {\r
             throw new JspException(e.getMessage(), e);\r
@@ -142,11 +149,13 @@ public class TagHandlerPool {
         }\r
         // There is no need for other threads to wait for us to release\r
         handler.release();\r
-        try {\r
-            AnnotationProcessor.preDestroy(handler);\r
-        } catch (Exception e) {\r
-            log.warn("Error processing preDestroy on tag instance of " \r
-                    + handler.getClass().getName(), e);\r
+        if (!ignoreAnnotations) {\r
+            try {\r
+                AnnotationProcessor.preDestroy(handler);\r
+            } catch (Exception e) {\r
+                log.warn("Error processing preDestroy on tag instance of " \r
+                        + handler.getClass().getName(), e);\r
+            }\r
         }\r
     }\r
 \r
@@ -157,11 +166,13 @@ public class TagHandlerPool {
     public synchronized void release() {\r
         for (int i = current; i >= 0; i--) {\r
             handlers[i].release();\r
-            try {\r
-                AnnotationProcessor.preDestroy(handlers[i]);\r
-            } catch (Exception e) {\r
-                log.warn("Error processing preDestroy on tag instance of " \r
-                        + handlers[i].getClass().getName(), e);\r
+            if (!ignoreAnnotations) {\r
+                try {\r
+                    AnnotationProcessor.preDestroy(handlers[i]);\r
+                } catch (Exception e) {\r
+                    log.warn("Error processing preDestroy on tag instance of " \r
+                            + handlers[i].getClass().getName(), e);\r
+                }\r
             }\r
         }\r
     }\r