remm 2005/04/28 05:29:51
Modified: catalina/src/share/org/apache/catalina/connector
Connector.java LocalStrings.properties
util/java/org/apache/tomcat/util/net AprEndpoint.java
Log:
- Use APR if present (oops for SSL mode, where right now the protocol class
would have to be specified). I'm still unsure about the APRized AJP (motivation
is a bit lacking, although it would be good for straight comparisons).
- Useless code removal.
Revision Changes Path
1.17 +55 -9
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Connector.java
Index: Connector.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Connector.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Connector.java 29 Jan 2005 19:44:43 -0000 1.16
+++ Connector.java 28 Apr 2005 12:29:51 -0000 1.17
@@ -17,6 +17,7 @@
package org.apache.catalina.connector;
+import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.util.HashMap;
@@ -548,9 +549,13 @@
public String getProtocol() {
if ("org.apache.coyote.http11.Http11Protocol".equals
+ (getProtocolHandlerClassName())
+ || "org.apache.coyote.http11.Http11AprProtocol".equals
(getProtocolHandlerClassName())) {
return "HTTP/1.1";
} else if ("org.apache.jk.server.JkCoyoteHandler".equals
+ (getProtocolHandlerClassName())
+ || "org.apache.coyote.ajp.AjpAprProtocol".equals
(getProtocolHandlerClassName())) {
return "AJP/1.3";
}
@@ -566,14 +571,55 @@
*/
public void setProtocol(String protocol) {
- if ("HTTP/1.1".equals(protocol)) {
- setProtocolHandlerClassName
- ("org.apache.coyote.http11.Http11Protocol");
- } else if ("AJP/1.3".equals(protocol)) {
- setProtocolHandlerClassName
- ("org.apache.jk.server.JkCoyoteHandler");
- } else if (protocol != null) {
- setProtocolHandlerClassName(protocol);
+ // Test APR support
+ boolean apr = false;
+ try {
+ String methodName = "initialize";
+ Class paramTypes[] = new Class[1];
+ paramTypes[0] = String.class;
+ Object paramValues[] = new Object[1];
+ paramValues[0] = null;
+ Method method = Class.forName("org.apache.tomcat.jni.Library")
+ .getMethod(methodName, paramTypes);
+ method.invoke(null, paramValues);
+ apr = true;
+ } catch (Throwable t) {
+ if (!log.isDebugEnabled()) {
+ log.info(sm.getString("coyoteConnector.noApr",
+ System.getProperty("java.library.path")));
+ } else {
+ log.debug(sm.getString("coyoteConnector.noApr",
+ System.getProperty("java.library.path")), t);
+ }
+ }
+
+ if (apr) {
+ if ("HTTP/1.1".equals(protocol)) {
+ setProtocolHandlerClassName
+ ("org.apache.coyote.http11.Http11AprProtocol");
+ } else if ("AJP/1.3".equals(protocol)) {
+ /*
+ setProtocolHandlerClassName
+ ("org.apache.coyote.ajp.AjpAprProtocol");
+ */
+ setProtocolHandlerClassName
+ ("org.apache.jk.server.JkCoyoteHandler");
+ } else if (protocol != null) {
+ setProtocolHandlerClassName(protocol);
+ } else {
+ setProtocolHandlerClassName
+ ("org.apache.coyote.http11.Http11AprProtocol");
+ }
+ } else {
+ if ("HTTP/1.1".equals(protocol)) {
+ setProtocolHandlerClassName
+ ("org.apache.coyote.http11.Http11Protocol");
+ } else if ("AJP/1.3".equals(protocol)) {
+ setProtocolHandlerClassName
+ ("org.apache.jk.server.JkCoyoteHandler");
+ } else if (protocol != null) {
+ setProtocolHandlerClassName(protocol);
+ }
}
}
1.7 +3 -0
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LocalStrings.properties 29 Jan 2005 19:44:43 -0000 1.6
+++ LocalStrings.properties 28 Apr 2005 12:29:51 -0000 1.7
@@ -16,6 +16,9 @@
coyoteConnector.protocolHandlerResumeFailed=Protocol handler resume failed
coyoteConnector.MapperRegistration=register Mapper: {0}
coyoteConnector.protocolUnregistrationFailed=Protocol handler stop failed
+coyoteConnector.noApr=The Apache Portable Runtime which allows optimal
performance in production environments was not found on the java.library.path:
{0}
+
+
#
# CoyoteAdapter
#
1.23 +0 -15
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java
Index: AprEndpoint.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- AprEndpoint.java 24 Apr 2005 13:18:28 -0000 1.22
+++ AprEndpoint.java 28 Apr 2005 12:29:51 -0000 1.23
@@ -25,7 +25,6 @@
import org.apache.tomcat.jni.Address;
import org.apache.tomcat.jni.Error;
import org.apache.tomcat.jni.File;
-import org.apache.tomcat.jni.Library;
import org.apache.tomcat.jni.Poll;
import org.apache.tomcat.jni.Pool;
import org.apache.tomcat.jni.Socket;
@@ -326,18 +325,6 @@
/**
- * Return the APR memory pool for the server socket, to be used by
handler
- * which would need to allocate things like pollers, while having
- * consistent resource handling.
- *
- * @return the id for the server socket pool
- */
- public long getServerSocketPool() {
- return serverSockPool;
- }
-
-
- /**
* Return the amount of threads that are managed by the pool.
*
* @return the amount of threads that are managed by the pool
@@ -388,8 +375,6 @@
if (initialized)
return;
- // Initialize APR
- Library.initialize(null);
// Create the root APR memory pool
rootPool = Pool.create(0);
// Create the pool for the server socket
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]