JBossWeb SVN: r1697 - in trunk/java/org/apache/jasper: runtime and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-04-07 11:55:10 -0400 (Thu, 07 Apr 2011)
New Revision: 1697
Modified:
trunk/java/org/apache/jasper/Constants.java
trunk/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java
trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
Log:
- I don't understand why reuse calls predestroy (get does not call post construct if the tag is not instantiated). Drop that.
- Use the thread local pool by default, but lower the size (only nesting will actually require more than one).
- Use the instance manager by default.
Modified: trunk/java/org/apache/jasper/Constants.java
===================================================================
--- trunk/java/org/apache/jasper/Constants.java 2011-04-06 22:20:35 UTC (rev 1696)
+++ trunk/java/org/apache/jasper/Constants.java 2011-04-07 15:55:10 UTC (rev 1697)
@@ -94,7 +94,7 @@
/**
* Default tag handler pool size.
*/
- public static final int MAX_POOL_SIZE = Integer.parseInt(System.getProperty("org.apache.jasper.Constants.MAX_POOL_SIZE", "16"));
+ public static final int MAX_POOL_SIZE = Integer.parseInt(System.getProperty("org.apache.jasper.Constants.MAX_POOL_SIZE", "4"));
/**
* The query parameter that causes the JSP engine to just
@@ -143,7 +143,7 @@
(System.getSecurityManager() != null);
public static final boolean USE_INSTANCE_MANAGER_FOR_TAGS =
- Boolean.valueOf(System.getProperty("org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS", "false")).booleanValue();
+ Boolean.valueOf(System.getProperty("org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS", "true")).booleanValue();
public static final boolean INJECT_TAGS =
Boolean.valueOf(System.getProperty("org.apache.jasper.Constants.INJECT_TAGS", "false")).booleanValue();
Modified: trunk/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java
===================================================================
--- trunk/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java 2011-04-06 22:20:35 UTC (rev 1696)
+++ trunk/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java 2011-04-07 15:55:10 UTC (rev 1697)
@@ -37,9 +37,9 @@
private int maxSize;
// For cleanup
- private Vector perThreadDataVector;
+ private Vector<PerThreadData> perThreadDataVector;
- private ThreadLocal perThread;
+ private ThreadLocal<PerThreadData> perThread;
private static class PerThreadData {
Tag handlers[];
@@ -51,7 +51,7 @@
*/
public PerThreadTagHandlerPool() {
super();
- perThreadDataVector = new Vector();
+ perThreadDataVector = new Vector<PerThreadData>();
}
protected void init(ServletConfig config) {
@@ -64,8 +64,8 @@
}
}
- perThread = new ThreadLocal() {
- protected Object initialValue() {
+ perThread = new ThreadLocal<PerThreadData>() {
+ protected PerThreadData initialValue() {
PerThreadData ptd = new PerThreadData();
ptd.handlers = new Tag[maxSize];
ptd.current = -1;
@@ -90,12 +90,20 @@
if(ptd.current >=0 ) {
return ptd.handlers[ptd.current--];
} else {
- try {
- return (Tag) handlerClass.newInstance();
- } catch (Exception e) {
- throw new JspException(e.getMessage(), e);
- }
- }
+ try {
+ if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
+ return (Tag) instanceManager.newInstance(handlerClass);
+ } else {
+ Tag instance = (Tag) handlerClass.newInstance();
+ if (Constants.INJECT_TAGS) {
+ instanceManager.newInstance(instance);
+ }
+ return instance;
+ }
+ } catch (Exception e) {
+ throw new JspException(e.getMessage(), e);
+ }
+ }
}
/**
@@ -107,8 +115,8 @@
*/
public void reuse(Tag handler) {
PerThreadData ptd=(PerThreadData)perThread.get();
- if (ptd.current < (ptd.handlers.length - 1)) {
- ptd.handlers[++ptd.current] = handler;
+ if (ptd.current < (ptd.handlers.length - 1)) {
+ ptd.handlers[++ptd.current] = handler;
} else {
handler.release();
}
@@ -118,14 +126,22 @@
* Calls the release() method of all tag handlers in this tag handler pool.
*/
public void release() {
- Enumeration enumeration = perThreadDataVector.elements();
+ Enumeration<PerThreadData> enumeration = perThreadDataVector.elements();
while (enumeration.hasMoreElements()) {
- PerThreadData ptd = (PerThreadData)enumeration.nextElement();
+ PerThreadData ptd = enumeration.nextElement();
if (ptd.handlers != null) {
for (int i=ptd.current; i>=0; i--) {
if (ptd.handlers[i] != null) {
ptd.handlers[i].release();
- }
+ if (Constants.INJECT_TAGS || Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
+ try {
+ instanceManager.destroyInstance(ptd.handlers[i]);
+ } catch (Exception e) {
+ log.warn("Error processing preDestroy on tag instance of "
+ + ptd.handlers[i].getClass().getName(), e);
+ }
+ }
+ }
}
}
}
Modified: trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
===================================================================
--- trunk/java/org/apache/jasper/runtime/TagHandlerPool.java 2011-04-06 22:20:35 UTC (rev 1696)
+++ trunk/java/org/apache/jasper/runtime/TagHandlerPool.java 2011-04-07 15:55:10 UTC (rev 1697)
@@ -37,7 +37,7 @@
public static final String OPTION_TAGPOOL="tagpoolClassName";
public static final String OPTION_MAXSIZE="tagpoolMaxSize";
- private Logger log = Logger.getLogger(TagHandlerPool.class);
+ protected Logger log = Logger.getLogger(TagHandlerPool.class);
// index of next available tag handler
private int current;
@@ -52,11 +52,10 @@
Class c=Class.forName( tpClassName );
result=(TagHandlerPool)c.newInstance();
} catch (Exception e) {
- e.printStackTrace();
- result=null;
+ result = null;
}
}
- if( result==null ) result=new TagHandlerPool();
+ if( result==null ) result=new PerThreadTagHandlerPool();
result.init(config);
return result;
@@ -151,14 +150,6 @@
}
// There is no need for other threads to wait for us to release
handler.release();
- if (Constants.INJECT_TAGS || Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
- try {
- instanceManager.destroyInstance(handler);
- } catch (Exception e) {
- log.warn("Error processing preDestroy on tag instance of "
- + handler.getClass().getName(), e);
- }
- }
}
/**
13 years, 8 months
JBossWeb SVN: r1696 - in trunk/java/org/apache/jasper: runtime and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-04-06 18:20:35 -0400 (Wed, 06 Apr 2011)
New Revision: 1696
Modified:
trunk/java/org/apache/jasper/compiler/Generator.java
trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
Log:
- Improve instance manager use with tags.
- Since the tag class is already loaded, use it rather than reloading it all the time.
- If the instance manager is enabled for tags, use it for destroy without having to also set the inject tags flag.
Modified: trunk/java/org/apache/jasper/compiler/Generator.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Generator.java 2011-04-06 16:22:52 UTC (rev 1695)
+++ trunk/java/org/apache/jasper/compiler/Generator.java 2011-04-06 22:20:35 UTC (rev 1696)
@@ -2312,9 +2312,9 @@
out.print(tagHandlerClassName);
out.print(")");
out.print(VAR_INSTANCEMANAGER);
- out.print(".newInstance(\"");
+ out.print(".newInstance(");
out.print(tagHandlerClassName);
- out.println("\", this.getClass().getClassLoader());");
+ out.println(".class);");
} else {
out.printin(tagHandlerClassName);
out.print(" ");
@@ -2324,23 +2324,23 @@
out.print(tagHandlerClassName);
out.println("());");
if (Constants.INJECT_TAGS) {
+ out.printin(VAR_INSTANCEMANAGER);
+ out.print(".newInstance(");
+ out.print(tagHandlerVar);
+ out.println(");");
+ }
+ }
+ }
+
+ private void writeDestroyInstance(String tagHandlerVar) {
+ if (Constants.INJECT_TAGS || Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
out.printin(VAR_INSTANCEMANAGER);
- out.print(".newInstance(");
+ out.print(".destroyInstance(");
out.print(tagHandlerVar);
out.println(");");
}
}
- }
- private void writeDestroyInstance(String tagHandlerVar) {
- if (Constants.INJECT_TAGS) {
- out.printin(VAR_INSTANCEMANAGER);
- out.print(".destroyInstance(");
- out.print(tagHandlerVar);
- out.println(");");
- }
- }
-
private void generateCustomEnd(Node.CustomTag n, String tagHandlerVar,
String tagEvalVar, String tagPushBodyCountVar) {
Modified: trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
===================================================================
--- trunk/java/org/apache/jasper/runtime/TagHandlerPool.java 2011-04-06 16:22:52 UTC (rev 1695)
+++ trunk/java/org/apache/jasper/runtime/TagHandlerPool.java 2011-04-06 22:20:35 UTC (rev 1696)
@@ -122,7 +122,7 @@
// wait for us to construct a tag for this thread.
try {
if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
- return (Tag) instanceManager.newInstance(handlerClass.getName(), handlerClass.getClassLoader());
+ return (Tag) instanceManager.newInstance(handlerClass);
} else {
Tag instance = (Tag) handlerClass.newInstance();
if (Constants.INJECT_TAGS) {
@@ -151,7 +151,7 @@
}
// There is no need for other threads to wait for us to release
handler.release();
- if (Constants.INJECT_TAGS) {
+ if (Constants.INJECT_TAGS || Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
try {
instanceManager.destroyInstance(handler);
} catch (Exception e) {
@@ -168,7 +168,7 @@
public synchronized void release() {
for (int i = current; i >= 0; i--) {
handlers[i].release();
- if (Constants.INJECT_TAGS) {
+ if (Constants.INJECT_TAGS || Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
try {
instanceManager.destroyInstance(handlers[i]);
} catch (Exception e) {
13 years, 8 months
JBossWeb SVN: r1695 - in trunk/java/org/apache/jasper: compiler and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-04-06 12:22:52 -0400 (Wed, 06 Apr 2011)
New Revision: 1695
Removed:
trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
trunk/java/org/apache/jasper/xmlparser/TreeNode.java
Modified:
trunk/java/org/apache/jasper/Constants.java
trunk/java/org/apache/jasper/EmbeddedServletOptions.java
trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java
trunk/java/org/apache/jasper/compiler/TagPluginManager.java
Log:
- Switch to using STAX for the remaining Jasper XML parsing.
Modified: trunk/java/org/apache/jasper/Constants.java
===================================================================
--- trunk/java/org/apache/jasper/Constants.java 2011-04-06 10:54:24 UTC (rev 1694)
+++ trunk/java/org/apache/jasper/Constants.java 2011-04-06 16:22:52 UTC (rev 1695)
@@ -94,7 +94,7 @@
/**
* Default tag handler pool size.
*/
- public static final int MAX_POOL_SIZE = 5;
+ public static final int MAX_POOL_SIZE = Integer.parseInt(System.getProperty("org.apache.jasper.Constants.MAX_POOL_SIZE", "16"));
/**
* The query parameter that causes the JSP engine to just
@@ -121,56 +121,7 @@
*/
public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
- // Must be kept in sync with org/apache/catalina/Globals.java
- public static final String ALT_DD_ATTR =
- System.getProperty("org.apache.jasper.Constants.ALT_DD_ATTR", "org.apache.catalina.deploy.alt_dd");
-
/**
- * Public Id and the Resource path (of the cached copy)
- * of the DTDs for tag library descriptors.
- */
- public static final String TAGLIB_DTD_PUBLIC_ID_11 =
- "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
- public static final String TAGLIB_DTD_RESOURCE_PATH_11 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
- public static final String TAGLIB_DTD_PUBLIC_ID_12 =
- "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
- public static final String TAGLIB_DTD_RESOURCE_PATH_12 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
-
- /**
- * Public Id and the Resource path (of the cached copy)
- * of the DTDs for web application deployment descriptors
- */
- public static final String WEBAPP_DTD_PUBLIC_ID_22 =
- "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
- public static final String WEBAPP_DTD_RESOURCE_PATH_22 =
- "/javax/servlet/resources/web-app_2_2.dtd";
- public static final String WEBAPP_DTD_PUBLIC_ID_23 =
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
- public static final String WEBAPP_DTD_RESOURCE_PATH_23 =
- "/javax/servlet/resources/web-app_2_3.dtd";
-
- /**
- * List of the Public IDs that we cache, and their
- * associated location. This is used by
- * an EntityResolver to return the location of the
- * cached copy of a DTD.
- */
- public static final String[] CACHED_DTD_PUBLIC_IDS = {
- TAGLIB_DTD_PUBLIC_ID_11,
- TAGLIB_DTD_PUBLIC_ID_12,
- WEBAPP_DTD_PUBLIC_ID_22,
- WEBAPP_DTD_PUBLIC_ID_23,
- };
- public static final String[] CACHED_DTD_RESOURCE_PATHS = {
- TAGLIB_DTD_RESOURCE_PATH_11,
- TAGLIB_DTD_RESOURCE_PATH_12,
- WEBAPP_DTD_RESOURCE_PATH_22,
- WEBAPP_DTD_RESOURCE_PATH_23,
- };
-
- /**
* Default URLs to download the pluging for Netscape and IE.
*/
public static final String NS_PLUGIN_URL =
Modified: trunk/java/org/apache/jasper/EmbeddedServletOptions.java
===================================================================
--- trunk/java/org/apache/jasper/EmbeddedServletOptions.java 2011-04-06 10:54:24 UTC (rev 1694)
+++ trunk/java/org/apache/jasper/EmbeddedServletOptions.java 2011-04-06 16:22:52 UTC (rev 1695)
@@ -28,7 +28,6 @@
import org.apache.jasper.compiler.JspConfig;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.compiler.TagPluginManager;
-import org.apache.jasper.xmlparser.ParserUtils;
import org.jboss.logging.Logger;
/**
@@ -407,10 +406,6 @@
setProperty( k, v);
}
- // quick hack
- String validating=config.getInitParameter( "validating");
- if( "false".equals( validating )) ParserUtils.validating=false;
-
String keepgen = config.getInitParameter("keepgenerated");
if (keepgen != null) {
if (keepgen.equalsIgnoreCase("true")) {
Modified: trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java 2011-04-06 10:54:24 UTC (rev 1694)
+++ trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java 2011-04-06 16:22:52 UTC (rev 1695)
@@ -28,11 +28,13 @@
import javax.servlet.jsp.tagext.TagFileInfo;
import javax.servlet.jsp.tagext.TagInfo;
import javax.servlet.jsp.tagext.TagLibraryInfo;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.apache.jasper.JasperException;
import org.apache.jasper.JspCompilationContext;
-import org.apache.jasper.xmlparser.ParserUtils;
-import org.apache.jasper.xmlparser.TreeNode;
/**
* Class responsible for generating an implicit tag library containing tag
@@ -113,43 +115,46 @@
tagName.lastIndexOf(suffix));
tagFileMap.put(tagName, path);
} else if (path.endsWith(IMPLICIT_TLD)) {
- InputStream in = null;
+ InputStream is = null;
try {
- in = ctxt.getResourceAsStream(path);
- if (in != null) {
+ is = ctxt.getResourceAsStream(path);
+ if (is != null) {
// Add implicit TLD to dependency list
if (pi != null) {
pi.addDependant(path);
}
- ParserUtils pu = new ParserUtils();
- TreeNode tld = pu.parseXMLDocument(uri, in);
-
- if (tld.findAttribute("version") != null) {
- this.jspversion = tld.findAttribute("version");
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(is);
+
+ reader.require(XMLStreamConstants.START_DOCUMENT, null, null);
+ while (reader.hasNext() && reader.next() != XMLStreamConstants.START_ELEMENT) {
+ // Skip until first element
}
+
+ final int count = reader.getAttributeCount();
+ for (int i = 0; i < count; i ++) {
+ if ("version".equals(reader.getAttributeLocalName(i))) {
+ this.jspversion = reader.getAttributeValue(i);
+ }
+ }
- // Process each child element of our <taglib> element
- Iterator list = tld.findChildren();
-
- while (list.hasNext()) {
- TreeNode element = (TreeNode) list.next();
- String tname = element.getName();
-
- if ("tlibversion".equals(tname) // JSP 1.1
- || "tlib-version".equals(tname)) { // JSP 1.2
- this.tlibversion = element.getBody();
- } else if ("jspversion".equals(tname)
- || "jsp-version".equals(tname)) {
- this.jspversion = element.getBody();
- } else if ("shortname".equals(tname) || "short-name".equals(tname)) {
- // Ignore
+ while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
+ String elementName = reader.getLocalName();
+ if ("tlibversion".equals(elementName) // JSP 1.1
+ || "tlib-version".equals(elementName)) { // JSP 1.2
+ this.tlibversion = reader.getElementText().trim();
+ } else if ("jspversion".equals(elementName)
+ || "jsp-version".equals(elementName)) {
+ this.jspversion = reader.getElementText().trim();
+ } else if ("shortname".equals(elementName) || "short-name".equals(elementName)) {
+ reader.getElementText();
} else {
// All other elements are invalid
err.jspError("jsp.error.invalid.implicit", path);
}
}
+
try {
double version = Double.parseDouble(this.jspversion);
if (version < 2.0) {
@@ -159,10 +164,12 @@
err.jspError("jsp.error.invalid.implicit.version", path);
}
}
+ } catch (XMLStreamException e) {
+ err.jspError("jsp.error.invalid.implicit", path, e);
} finally {
- if (in != null) {
+ if (is != null) {
try {
- in.close();
+ is.close();
} catch (Throwable t) {
}
}
Modified: trunk/java/org/apache/jasper/compiler/TagPluginManager.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagPluginManager.java 2011-04-06 10:54:24 UTC (rev 1694)
+++ trunk/java/org/apache/jasper/compiler/TagPluginManager.java 2011-04-06 16:22:52 UTC (rev 1695)
@@ -17,13 +17,17 @@
package org.apache.jasper.compiler;
-import java.util.*;
-import java.io.*;
+import java.io.InputStream;
+import java.util.HashMap;
+
import javax.servlet.ServletContext;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.apache.jasper.JasperException;
-import org.apache.jasper.xmlparser.ParserUtils;
-import org.apache.jasper.xmlparser.TreeNode;
import org.apache.jasper.compiler.tagplugin.TagPlugin;
import org.apache.jasper.compiler.tagplugin.TagPluginContext;
@@ -38,7 +42,7 @@
private static final String TAG_PLUGINS_ROOT_ELEM = "tag-plugins";
private boolean initialized = false;
- private HashMap tagPlugins = null;
+ private HashMap<String, TagPlugin> tagPlugins = null;
private ServletContext ctxt;
private PageInfo pageInfo;
@@ -67,54 +71,77 @@
}
private void init(ErrorDispatcher err) throws JasperException {
- if (initialized)
- return;
+ if (initialized)
+ return;
- InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
- if (is == null)
- return;
+ InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
+ if (is == null)
+ return;
- TreeNode root = (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML,
- is);
- if (root == null) {
- return;
- }
+ XMLStreamReader reader;
+ try {
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(is);
+ reader.require(XMLStreamConstants.START_DOCUMENT, null, null);
- if (!TAG_PLUGINS_ROOT_ELEM.equals(root.getName())) {
- err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML,
- TAG_PLUGINS_ROOT_ELEM);
- }
+ reader.require(XMLStreamConstants.START_DOCUMENT, null, null);
+ while (reader.hasNext() && reader.next() != XMLStreamConstants.START_ELEMENT) {
+ // Skip until first element
+ }
- tagPlugins = new HashMap();
- Iterator pluginList = root.findChildren("tag-plugin");
- while (pluginList.hasNext()) {
- TreeNode pluginNode = (TreeNode) pluginList.next();
- TreeNode tagClassNode = pluginNode.findChild("tag-class");
- if (tagClassNode == null) {
- // Error
- return;
- }
- String tagClass = tagClassNode.getBody().trim();
- TreeNode pluginClassNode = pluginNode.findChild("plugin-class");
- if (pluginClassNode == null) {
- // Error
- return;
- }
+ if (!TAG_PLUGINS_ROOT_ELEM.equals(reader.getLocalName())) {
+ err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML,
+ TAG_PLUGINS_ROOT_ELEM);
+ }
- String pluginClassStr = pluginClassNode.getBody();
- TagPlugin tagPlugin = null;
- try {
- Class pluginClass = Class.forName(pluginClassStr);
- tagPlugin = (TagPlugin) pluginClass.newInstance();
- } catch (Exception e) {
- throw new JasperException(e);
- }
- if (tagPlugin == null) {
- return;
- }
- tagPlugins.put(tagClass, tagPlugin);
- }
- initialized = true;
+ tagPlugins = new HashMap<String, TagPlugin>();
+ while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
+ String elementName = reader.getLocalName();
+ if ("tag-plugin".equals(elementName)) { // JSP 1.2
+ String tagClassName = null;
+ String pluginClassName = null;
+ while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
+ String childClementName = reader.getLocalName();
+ if ("tag-class".equals(childClementName)) {
+ tagClassName = reader.getElementText().trim();
+ } else if ("plugin-class".equals(childClementName)) {
+ pluginClassName = reader.getElementText().trim();
+ } else {
+ err.jspError("jsp.error.invalid.tagplugin", TAG_PLUGINS_XML);
+ }
+ }
+ if (tagClassName == null || pluginClassName == null) {
+ err.jspError("jsp.error.invalid.tagplugin", TAG_PLUGINS_XML);
+ }
+ TagPlugin tagPlugin = null;
+ try {
+ Class<?> pluginClass = Thread.currentThread().getContextClassLoader().loadClass(pluginClassName);
+ tagPlugin = (TagPlugin) pluginClass.newInstance();
+ } catch (Exception e) {
+ throw new JasperException(e);
+ }
+ if (tagPlugin == null) {
+ return;
+ }
+ tagPlugins.put(tagClassName, tagPlugin);
+
+ } else {
+ // All other elements are invalid
+ err.jspError("jsp.error.invalid.tagplugin", TAG_PLUGINS_XML);
+ }
+ }
+ } catch (XMLStreamException e) {
+ err.jspError("jsp.error.invalid.tagplugin", TAG_PLUGINS_XML, e);
+ } catch (FactoryConfigurationError e) {
+ throw new JasperException(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ initialized = true;
}
/**
Deleted: trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
===================================================================
--- trunk/java/org/apache/jasper/xmlparser/ParserUtils.java 2011-04-06 10:54:24 UTC (rev 1694)
+++ trunk/java/org/apache/jasper/xmlparser/ParserUtils.java 2011-04-06 16:22:52 UTC (rev 1695)
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jasper.xmlparser;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.jasper.Constants;
-import org.apache.jasper.JasperException;
-import org.apache.jasper.compiler.Localizer;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-
-/**
- * XML parsing utilities for processing web application deployment
- * descriptor and tag library descriptor files. FIXME - make these
- * use a separate class loader for the parser to be used.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class ParserUtils {
-
- /**
- * An error handler for use when parsing XML documents.
- */
- static ErrorHandler errorHandler = new MyErrorHandler();
-
- /**
- * An entity resolver for use when parsing XML documents.
- */
- static EntityResolver entityResolver = new MyEntityResolver();
-
- // Turn off for JSP 2.0 until switch over to using xschema.
- public static boolean validating = false;
-
-
- // --------------------------------------------------------- Public Methods
-
- /**
- * Parse the specified XML document, and return a <code>TreeNode</code>
- * that corresponds to the root node of the document tree.
- *
- * @param uri URI of the XML document being parsed
- * @param is Input source containing the deployment descriptor
- *
- * @exception JasperException if an input/output error occurs
- * @exception JasperException if a parsing error occurs
- */
- public TreeNode parseXMLDocument(String uri, InputSource is)
- throws JasperException {
-
- Document document = null;
-
- // Perform an XML parse of this document, via JAXP
- try {
- DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(validating);
- DocumentBuilder builder = factory.newDocumentBuilder();
- builder.setEntityResolver(entityResolver);
- builder.setErrorHandler(errorHandler);
- document = builder.parse(is);
- } catch (ParserConfigurationException ex) {
- throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), ex);
- } catch (SAXParseException ex) {
- throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml.line",
- uri,
- Integer.toString(ex.getLineNumber()),
- Integer.toString(ex.getColumnNumber())),
- ex);
- } catch (SAXException sx) {
- throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), sx);
- } catch (IOException io) {
- throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), io);
- }
-
- // Convert the resulting document to a graph of TreeNodes
- return (convert(null, document.getDocumentElement()));
- }
-
-
- /**
- * Parse the specified XML document, and return a <code>TreeNode</code>
- * that corresponds to the root node of the document tree.
- *
- * @param uri URI of the XML document being parsed
- * @param is Input stream containing the deployment descriptor
- *
- * @exception JasperException if an input/output error occurs
- * @exception JasperException if a parsing error occurs
- */
- public TreeNode parseXMLDocument(String uri, InputStream is)
- throws JasperException {
-
- return (parseXMLDocument(uri, new InputSource(is)));
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Create and return a TreeNode that corresponds to the specified Node,
- * including processing all of the attributes and children nodes.
- *
- * @param parent The parent TreeNode (if any) for the new TreeNode
- * @param node The XML document Node to be converted
- */
- protected TreeNode convert(TreeNode parent, Node node) {
-
- // Construct a new TreeNode for this node
- TreeNode treeNode = new TreeNode(node.getNodeName(), parent);
-
- // Convert all attributes of this node
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- int n = attributes.getLength();
- for (int i = 0; i < n; i++) {
- Node attribute = attributes.item(i);
- treeNode.addAttribute(attribute.getNodeName(),
- attribute.getNodeValue());
- }
- }
-
- // Create and attach all children of this node
- NodeList children = node.getChildNodes();
- if (children != null) {
- int n = children.getLength();
- for (int i = 0; i < n; i++) {
- Node child = children.item(i);
- if (child instanceof Comment)
- continue;
- if (child instanceof Text) {
- String body = ((Text) child).getData();
- if (body != null) {
- body = body.trim();
- if (body.length() > 0)
- treeNode.setBody(body);
- }
- } else {
- TreeNode treeChild = convert(treeNode, child);
- }
- }
- }
-
- // Return the completed TreeNode graph
- return (treeNode);
- }
-}
-
-
-// ------------------------------------------------------------ Private Classes
-
-class MyEntityResolver implements EntityResolver {
-
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException {
- for (int i = 0; i < Constants.CACHED_DTD_PUBLIC_IDS.length; i++) {
- String cachedDtdPublicId = Constants.CACHED_DTD_PUBLIC_IDS[i];
- if (cachedDtdPublicId.equals(publicId)) {
- String resourcePath = Constants.CACHED_DTD_RESOURCE_PATHS[i];
- InputStream input = this.getClass().getResourceAsStream(
- resourcePath);
- if (input == null) {
- throw new SAXException(Localizer.getMessage(
- "jsp.error.internal.filenotfound", resourcePath));
- }
- InputSource isrc = new InputSource(input);
- return isrc;
- }
- }
- Logger log = Logger.getLogger(MyEntityResolver.class);
- if (log.isDebugEnabled())
- log.debug("Resolve entity failed" + publicId + " " + systemId);
- log.error(Localizer.getMessage("jsp.error.parse.xml.invalidPublicId",
- publicId));
- return null;
- }
-}
-
-class MyErrorHandler implements ErrorHandler {
-
- public void warning(SAXParseException ex) throws SAXException {
- Logger log = Logger.getLogger(MyErrorHandler.class);
- if (log.isDebugEnabled())
- log.debug("ParserUtils: warning ", ex);
- // We ignore warnings
- }
-
- public void error(SAXParseException ex) throws SAXException {
- throw ex;
- }
-
- public void fatalError(SAXParseException ex) throws SAXException {
- throw ex;
- }
-}
\ No newline at end of file
Deleted: trunk/java/org/apache/jasper/xmlparser/TreeNode.java
===================================================================
--- trunk/java/org/apache/jasper/xmlparser/TreeNode.java 2011-04-06 10:54:24 UTC (rev 1694)
+++ trunk/java/org/apache/jasper/xmlparser/TreeNode.java 2011-04-06 16:22:52 UTC (rev 1695)
@@ -1,360 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jasper.xmlparser;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-
-
-/**
- * Simplified implementation of a Node from a Document Object Model (DOM)
- * parse of an XML document. This class is used to represent a DOM tree
- * so that the XML parser's implementation of <code>org.w3c.dom</code> need
- * not be visible to the remainder of Jasper.
- * <p>
- * <strong>WARNING</strong> - Construction of a new tree, or modifications
- * to an existing one, are not thread-safe and such accesses must be
- * synchronized.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class TreeNode {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new node with no parent.
- *
- * @param name The name of this node
- */
- public TreeNode(String name) {
-
- this(name, null);
-
- }
-
-
- /**
- * Construct a new node with the specified parent.
- *
- * @param name The name of this node
- * @param parent The node that is the parent of this node
- */
- public TreeNode(String name, TreeNode parent) {
-
- super();
- this.name = name;
- this.parent = parent;
- if (this.parent != null)
- this.parent.addChild(this);
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The attributes of this node, keyed by attribute name,
- * Instantiated only if required.
- */
- protected HashMap attributes = null;
-
-
- /**
- * The body text associated with this node (if any).
- */
- protected String body = null;
-
-
- /**
- * The children of this node, instantiated only if required.
- */
- protected ArrayList children = null;
-
-
- /**
- * The name of this node.
- */
- protected String name = null;
-
-
- /**
- * The parent node of this node.
- */
- protected TreeNode parent = null;
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Add an attribute to this node, replacing any existing attribute
- * with the same name.
- *
- * @param name The attribute name to add
- * @param value The new attribute value
- */
- public void addAttribute(String name, String value) {
-
- if (attributes == null)
- attributes = new HashMap();
- attributes.put(name, value);
-
- }
-
-
- /**
- * Add a new child node to this node.
- *
- * @param node The new child node
- */
- public void addChild(TreeNode node) {
-
- if (children == null)
- children = new ArrayList();
- children.add(node);
-
- }
-
-
- /**
- * Return the value of the specified node attribute if it exists, or
- * <code>null</code> otherwise.
- *
- * @param name Name of the requested attribute
- */
- public String findAttribute(String name) {
-
- if (attributes == null)
- return (null);
- else
- return ((String) attributes.get(name));
-
- }
-
-
- /**
- * Return an Iterator of the attribute names of this node. If there are
- * no attributes, an empty Iterator is returned.
- */
- public Iterator findAttributes() {
-
- if (attributes == null)
- return (Collections.EMPTY_LIST.iterator());
- else
- return (attributes.keySet().iterator());
-
- }
-
-
- /**
- * Return the first child node of this node with the specified name,
- * if there is one; otherwise, return <code>null</code>.
- *
- * @param name Name of the desired child element
- */
- public TreeNode findChild(String name) {
-
- if (children == null)
- return (null);
- Iterator items = children.iterator();
- while (items.hasNext()) {
- TreeNode item = (TreeNode) items.next();
- if (name.equals(item.getName()))
- return (item);
- }
- return (null);
-
- }
-
-
- /**
- * Return an Iterator of all children of this node. If there are no
- * children, an empty Iterator is returned.
- */
- public Iterator findChildren() {
-
- if (children == null)
- return (Collections.EMPTY_LIST.iterator());
- else
- return (children.iterator());
-
- }
-
-
- /**
- * Return an Iterator over all children of this node that have the
- * specified name. If there are no such children, an empty Iterator
- * is returned.
- *
- * @param name Name used to select children
- */
- public Iterator findChildren(String name) {
-
- if (children == null)
- return (Collections.EMPTY_LIST.iterator());
-
- ArrayList results = new ArrayList();
- Iterator items = children.iterator();
- while (items.hasNext()) {
- TreeNode item = (TreeNode) items.next();
- if (name.equals(item.getName()))
- results.add(item);
- }
- return (results.iterator());
-
- }
-
-
- /**
- * Return the body text associated with this node (if any).
- */
- public String getBody() {
-
- return (this.body);
-
- }
-
-
- /**
- * Return the name of this node.
- */
- public String getName() {
-
- return (this.name);
-
- }
-
-
- /**
- * Remove any existing value for the specified attribute name.
- *
- * @param name The attribute name to remove
- */
- public void removeAttribute(String name) {
-
- if (attributes != null)
- attributes.remove(name);
-
- }
-
-
- /**
- * Remove a child node from this node, if it is one.
- *
- * @param node The child node to remove
- */
- public void removeNode(TreeNode node) {
-
- if (children != null)
- children.remove(node);
-
- }
-
-
- /**
- * Set the body text associated with this node (if any).
- *
- * @param body The body text (if any)
- */
- public void setBody(String body) {
-
- this.body = body;
-
- }
-
-
- /**
- * Return a String representation of this TreeNode.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder();
- toString(sb, 0, this);
- return (sb.toString());
-
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Append to the specified StringBuilder a character representation of
- * this node, with the specified amount of indentation.
- *
- * @param sb The StringBuilder to append to
- * @param indent Number of characters of indentation
- * @param node The TreeNode to be printed
- */
- protected void toString(StringBuilder sb, int indent,
- TreeNode node) {
-
- int indent2 = indent + 2;
-
- // Reconstruct an opening node
- for (int i = 0; i < indent; i++)
- sb.append(' ');
- sb.append('<');
- sb.append(node.getName());
- Iterator names = node.findAttributes();
- while (names.hasNext()) {
- sb.append(' ');
- String name = (String) names.next();
- sb.append(name);
- sb.append("=\"");
- String value = node.findAttribute(name);
- sb.append(value);
- sb.append("\"");
- }
- sb.append(">\n");
-
- // Reconstruct the body text of this node (if any)
- String body = node.getBody();
- if ((body != null) && (body.length() > 0)) {
- for (int i = 0; i < indent2; i++)
- sb.append(' ');
- sb.append(body);
- sb.append("\n");
- }
-
- // Reconstruct child nodes with extra indentation
- Iterator children = node.findChildren();
- while (children.hasNext()) {
- TreeNode child = (TreeNode) children.next();
- toString(sb, indent2, child);
- }
-
- // Reconstruct a closing node marker
- for (int i = 0; i < indent; i++)
- sb.append(' ');
- sb.append("</");
- sb.append(node.getName());
- sb.append(">\n");
-
- }
-
-
-}
13 years, 8 months
JBossWeb SVN: r1694 - trunk/java/org/apache/jasper.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-04-06 06:54:24 -0400 (Wed, 06 Apr 2011)
New Revision: 1694
Modified:
trunk/java/org/apache/jasper/Constants.java
Log:
- Drop tag injection by default (too costly for now).
Modified: trunk/java/org/apache/jasper/Constants.java
===================================================================
--- trunk/java/org/apache/jasper/Constants.java 2011-04-04 15:21:43 UTC (rev 1693)
+++ trunk/java/org/apache/jasper/Constants.java 2011-04-06 10:54:24 UTC (rev 1694)
@@ -195,7 +195,7 @@
Boolean.valueOf(System.getProperty("org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS", "false")).booleanValue();
public static final boolean INJECT_TAGS =
- Boolean.valueOf(System.getProperty("org.apache.jasper.Constants.INJECT_TAGS", "true")).booleanValue();
+ Boolean.valueOf(System.getProperty("org.apache.jasper.Constants.INJECT_TAGS", "false")).booleanValue();
/**
* The name of the path parameter used to pass the session identifier
13 years, 8 months
JBossWeb SVN: r1693 - sandbox/webapps.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2011-04-04 11:21:43 -0400 (Mon, 04 Apr 2011)
New Revision: 1693
Modified:
sandbox/webapps/myapp.xml
Log:
Remove the removed Servlet AS7 complains about it.
Modified: sandbox/webapps/myapp.xml
===================================================================
--- sandbox/webapps/myapp.xml 2011-04-01 18:00:38 UTC (rev 1692)
+++ sandbox/webapps/myapp.xml 2011-04-04 15:21:43 UTC (rev 1693)
@@ -100,12 +100,7 @@
<servlet-name>TestDispatch</servlet-name>
<servlet-class>TestDispatch</servlet-class>
</servlet>
- <servlet>
- <servlet-name>NPEDemoServlet</servlet-name>
- <servlet-class>NPEDemoServlet</servlet-class>
- </servlet>
-
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
@@ -162,10 +157,6 @@
<servlet-name>TestDispatch</servlet-name>
<url-pattern>/TestDispatch</url-pattern>
</servlet-mapping>
- <servlet-mapping>
- <servlet-name>NPEDemoServlet</servlet-name>
- <url-pattern>/NPEDemoServlet</url-pattern>
- </servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
13 years, 8 months
JBossWeb SVN: r1692 - in trunk/java/org/apache/catalina: core and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2011-04-01 14:00:38 -0400 (Fri, 01 Apr 2011)
New Revision: 1692
Modified:
trunk/java/org/apache/catalina/connector/Connector.java
trunk/java/org/apache/catalina/core/AprLifecycleListener.java
trunk/java/org/apache/catalina/startup/Embedded.java
Log:
- Relax protocol values.
- Remove bad Connector APIs.
- AprLifecycleListener will now control use of native.
Modified: trunk/java/org/apache/catalina/connector/Connector.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Connector.java 2011-03-31 14:02:29 UTC (rev 1691)
+++ trunk/java/org/apache/catalina/connector/Connector.java 2011-04-01 18:00:38 UTC (rev 1692)
@@ -18,8 +18,6 @@
package org.apache.catalina.connector;
-import java.lang.reflect.Method;
-import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Set;
@@ -33,6 +31,7 @@
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Service;
+import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
import org.apache.coyote.Adapter;
@@ -72,20 +71,15 @@
// ------------------------------------------------------------ Constructor
- public Connector()
- throws Exception {
- this(null);
- }
-
public Connector(String protocol)
throws Exception {
setProtocol(protocol);
// Instantiate protocol handler
try {
- Class clazz = Class.forName(protocolHandlerClassName);
+ Class<?> clazz = Class.forName(protocolHandlerClassName);
this.protocolHandler = (ProtocolHandler) clazz.newInstance();
} catch (Exception e) {
- log.error
+ throw new IllegalArgumentException
(sm.getString
("coyoteConnector.protocolHandlerInstantiationFailed", e));
}
@@ -269,7 +263,7 @@
protected Set<String> allowedHosts = null;
- protected static HashMap replacements = new HashMap();
+ protected static HashMap<String, String> replacements = new HashMap<String, String>();
static {
replacements.put("acceptCount", "backlog");
replacements.put("connectionLinger", "soLinger");
@@ -330,15 +324,6 @@
/**
- * remove a configured property.
- */
- public void removeProperty(String name) {
- // FIXME !
- //protocolHandler.removeAttribute(name);
- }
-
-
- /**
* Return the <code>Service</code> with which we are associated (if any).
*/
public Service getService() {
@@ -356,7 +341,6 @@
public void setService(Service service) {
this.service = service;
- // FIXME: setProperty("service", service);
}
@@ -580,70 +564,18 @@
}
- // ---------------------------------------------- APR Version Constants
-
- private static final int TCN_REQUIRED_MAJOR = 1;
- private static final int TCN_REQUIRED_MINOR = 1;
- private static final int TCN_REQUIRED_PATCH = 3;
- private static boolean aprInitialized = false;
-
- // APR init support
- private static synchronized void initializeAPR()
- {
- if (aprInitialized) {
- return;
- }
- int major = 0;
- int minor = 0;
- int patch = 0;
- try {
- String methodName = "initialize";
- Class paramTypes[] = new Class[1];
- paramTypes[0] = String.class;
- Object paramValues[] = new Object[1];
- paramValues[0] = null;
- Class clazz = Class.forName("org.apache.tomcat.jni.Library");
- Method method = clazz.getMethod(methodName, paramTypes);
- method.invoke(null, paramValues);
- major = clazz.getField("TCN_MAJOR_VERSION").getInt(null);
- minor = clazz.getField("TCN_MINOR_VERSION").getInt(null);
- patch = clazz.getField("TCN_PATCH_VERSION").getInt(null);
- } catch (Throwable t) {
- return;
- }
- if ((major != TCN_REQUIRED_MAJOR) ||
- (minor != TCN_REQUIRED_MINOR) ||
- (patch < TCN_REQUIRED_PATCH)) {
- try {
- // Terminate the APR in case the version
- // is below required.
- String methodName = "terminate";
- Method method = Class.forName("org.apache.tomcat.jni.Library")
- .getMethod(methodName, (Class [])null);
- method.invoke(null, (Object []) null);
- } catch (Throwable t) {
- // Ignore
- }
- return;
- }
- aprInitialized = true;
- }
-
/**
* Set the Coyote protocol which will be used by the connector.
*
* @param protocol The Coyote protocol name
*/
- public void setProtocol(String protocol) {
+ protected void setProtocol(String protocol) {
- // Test APR support
- initializeAPR();
-
- if (aprInitialized) {
- if ("HTTP/1.1".equals(protocol)) {
+ if (AprLifecycleListener.isAprInitialized()) {
+ if ("HTTP/1.1".equals(protocol) || "http".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11AprProtocol");
- } else if ("AJP/1.3".equals(protocol)) {
+ } else if ("AJP/1.3".equals(protocol) || "ajp".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.ajp.AjpAprProtocol");
} else if (protocol != null) {
@@ -653,10 +585,10 @@
("org.apache.coyote.http11.Http11AprProtocol");
}
} else {
- if ("HTTP/1.1".equals(protocol)) {
+ if ("HTTP/1.1".equals(protocol) || "http".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11Protocol");
- } else if ("AJP/1.3".equals(protocol)) {
+ } else if ("AJP/1.3".equals(protocol) || "ajp".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.ajp.AjpProtocol");
} else if (protocol != null) {
@@ -722,7 +654,7 @@
setProperty("proxyName", proxyName);
} else {
this.proxyName = null;
- removeProperty("proxyName");
+ setProperty("proxyName", null);
}
}
@@ -994,7 +926,7 @@
throws MalformedObjectNameException {
String encodedAddr = null;
if (getProperty("address") != null) {
- encodedAddr = URLEncoder.encode(getProperty("address").toString());
+ encodedAddr = ObjectName.quote(getProperty("address").toString());
}
String addSuffix = (getProperty("address") == null) ? "" : ",address="
+ encodedAddr;
Modified: trunk/java/org/apache/catalina/core/AprLifecycleListener.java
===================================================================
--- trunk/java/org/apache/catalina/core/AprLifecycleListener.java 2011-03-31 14:02:29 UTC (rev 1691)
+++ trunk/java/org/apache/catalina/core/AprLifecycleListener.java 2011-04-01 18:00:38 UTC (rev 1692)
@@ -103,11 +103,11 @@
}
try {
String methodName = "initialize";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = String.class;
Object paramValues[] = new Object[1];
paramValues[0] = null;
- Class clazz = Class.forName("org.apache.tomcat.jni.Library");
+ Class<?> clazz = Class.forName("org.apache.tomcat.jni.Library");
Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
major = clazz.getField("TCN_MAJOR_VERSION").getInt(null);
@@ -171,11 +171,11 @@
return;
}
String methodName = "randSet";
- Class paramTypes[] = new Class[1];
+ Class<?> paramTypes[] = new Class[1];
paramTypes[0] = String.class;
Object paramValues[] = new Object[1];
paramValues[0] = SSLRandomSeed;
- Class clazz = Class.forName("org.apache.tomcat.jni.SSL");
+ Class<?> clazz = Class.forName("org.apache.tomcat.jni.SSL");
Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
@@ -187,6 +187,10 @@
sslInitialized = true;
}
+ public static boolean isAprInitialized() {
+ return aprInitialized;
+ }
+
public String getSSLEngine() {
return SSLEngine;
}
Modified: trunk/java/org/apache/catalina/startup/Embedded.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Embedded.java 2011-03-31 14:02:29 UTC (rev 1691)
+++ trunk/java/org/apache/catalina/startup/Embedded.java 2011-04-01 18:00:38 UTC (rev 1692)
@@ -340,9 +340,9 @@
} else if (protocol.equals("memory")) {
connector = new Connector("org.apache.coyote.memory.MemoryProtocolHandler");
} else if (protocol.equals("http")) {
- connector = new Connector();
+ connector = new Connector("http");
} else if (protocol.equals("https")) {
- connector = new Connector();
+ connector = new Connector("http");
connector.setScheme("https");
connector.setSecure(true);
connector.setProperty("SSLEnabled","true");
13 years, 8 months