Author: remy.maucherat(a)jboss.com
Date: 2009-02-25 08:04:57 -0500 (Wed, 25 Feb 2009)
New Revision: 940
Modified:
trunk/java/org/apache/jasper/Constants.java
trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
trunk/java/org/apache/jasper/servlet/JspServlet.java
Log:
- Fix portions of the code which seemed obviously at odds with the concept of providing
(most of the) TLD data from JBoss metadata.
- Right now, it seems replacing the options with a JBoss class which would use the caching
mechanism and provide a new TagLibraryInfo
implementation is the right way. If a TLD is not found, it will use the old Jasper
mechanism.
Modified: trunk/java/org/apache/jasper/Constants.java
===================================================================
--- trunk/java/org/apache/jasper/Constants.java 2009-02-23 13:56:28 UTC (rev 939)
+++ trunk/java/org/apache/jasper/Constants.java 2009-02-25 13:04:57 UTC (rev 940)
@@ -58,6 +58,12 @@
};
/**
+ * ServletContext attribute for the JSP Servlet options.
+ */
+ public static final String SERVLET_OPTIONS =
+ System.getProperty("org.apache.jasper.Constants.SERVLET_OPTIONS",
"org.apache.catalina.jsp_options");
+
+ /**
* ServletContext attribute for classpath. This is tomcat specific.
* Other servlet engines may choose to support this attribute if they
* want to have this JSP engine running on them.
Modified: trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 2009-02-23 13:56:28 UTC
(rev 939)
+++ trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 2009-02-25 13:04:57 UTC
(rev 940)
@@ -1251,29 +1251,33 @@
isPlainUri = true;
}
- String[] location = ctxt.getTldLocation(uri);
- if (location != null || !isPlainUri) {
- if (ctxt.getOptions().isCaching()) {
- result = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri);
- }
- if (result == null) {
- /*
- * If the uri value is a plain uri, a translation error must
- * not be generated if the uri is not found in the taglib map.
- * Instead, any actions in the namespace defined by the uri
- * value must be treated as uninterpreted.
- */
- result =
- new TagLibraryInfoImpl(
- ctxt,
- parserController,
- pageInfo,
- prefix,
- uri,
- location,
- err);
- if (ctxt.getOptions().isCaching()) {
- ctxt.getOptions().getCache().put(uri, result);
+ if (ctxt.getOptions().isCaching()) {
+ result = (TagLibraryInfo) ctxt.getOptions().getCache().get(uri);
+ }
+ if (result == null) {
+ // Fallback to Jasper's legacy scanning if nothing was provided
+ // by the options' TLD cache
+ String[] location = ctxt.getTldLocation(uri);
+ if (location != null || !isPlainUri) {
+ if (result == null) {
+ /*
+ * If the uri value is a plain uri, a translation error must
+ * not be generated if the uri is not found in the taglib map.
+ * Instead, any actions in the namespace defined by the uri
+ * value must be treated as uninterpreted.
+ */
+ result =
+ new TagLibraryInfoImpl(
+ ctxt,
+ parserController,
+ pageInfo,
+ prefix,
+ uri,
+ location,
+ err);
+ if (ctxt.getOptions().isCaching()) {
+ ctxt.getOptions().getCache().put(uri, result);
+ }
}
}
}
Modified: trunk/java/org/apache/jasper/servlet/JspServlet.java
===================================================================
--- trunk/java/org/apache/jasper/servlet/JspServlet.java 2009-02-23 13:56:28 UTC (rev
939)
+++ trunk/java/org/apache/jasper/servlet/JspServlet.java 2009-02-25 13:04:57 UTC (rev
940)
@@ -19,7 +19,6 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
-import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -73,29 +72,34 @@
this.config = config;
this.context = config.getServletContext();
- // Initialize the JSP Runtime Context
- // Check for a custom Options implementation
- String engineOptionsName =
- config.getInitParameter("engineOptionsClass");
- if (engineOptionsName != null) {
- // Instantiate the indicated Options implementation
- try {
- ClassLoader loader = Thread.currentThread()
- .getContextClassLoader();
- Class engineOptionsClass = loader.loadClass(engineOptionsName);
- Class[] ctorSig = { ServletConfig.class, ServletContext.class };
- Constructor ctor = engineOptionsClass.getConstructor(ctorSig);
- Object[] args = { config, context };
- options = (Options) ctor.newInstance(args);
- } catch (Throwable e) {
- // Need to localize this.
- log.warn("Failed to load engineOptionsClass", e);
+ Object optionsObject = context.getAttribute(Constants.SERVLET_OPTIONS);
+ if (optionsObject != null && (optionsObject instanceof Options)) {
+ options = (Options) optionsObject;
+ } else {
+ // Initialize the JSP Runtime Context
+ // Check for a custom Options implementation
+ String engineOptionsName =
+ config.getInitParameter("engineOptionsClass");
+ if (engineOptionsName != null) {
+ // Instantiate the indicated Options implementation
+ try {
+ ClassLoader loader = Thread.currentThread()
+ .getContextClassLoader();
+ Class engineOptionsClass = loader.loadClass(engineOptionsName);
+ Class[] ctorSig = { ServletConfig.class, ServletContext.class };
+ Constructor ctor = engineOptionsClass.getConstructor(ctorSig);
+ Object[] args = { config, context };
+ options = (Options) ctor.newInstance(args);
+ } catch (Throwable e) {
+ // Need to localize this.
+ log.warn("Failed to load engineOptionsClass", e);
+ // Use the default Options implementation
+ options = new EmbeddedServletOptions(config, context);
+ }
+ } else {
// Use the default Options implementation
options = new EmbeddedServletOptions(config, context);
}
- } else {
- // Use the default Options implementation
- options = new EmbeddedServletOptions(config, context);
}
rctxt = new JspRuntimeContext(context, options);
Show replies by date