Re-factoring in support of https://issues.apache.org/bugzilla/show_bug.cgi?id=50360
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 8 Dec 2010 13:37:11 +0000 (13:37 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 8 Dec 2010 13:37:11 +0000 (13:37 +0000)
Align the init() methods (JSSE still to go)

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

java/org/apache/coyote/ajp/AjpAprProtocol.java
java/org/apache/coyote/ajp/AjpProtocol.java
java/org/apache/coyote/ajp/Constants.java
java/org/apache/coyote/http11/Http11AprProtocol.java
java/org/apache/coyote/http11/Http11NioProtocol.java
java/org/apache/coyote/http11/Http11Protocol.java

index 241a50d..1ff933b 100644 (file)
@@ -66,9 +66,11 @@ public class AjpAprProtocol extends AbstractAjpProtocol {
     public AjpAprProtocol() {
         endpoint = new AprEndpoint();
         cHandler = new AjpConnectionHandler(this);
+        ((AprEndpoint) endpoint).setHandler(cHandler);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
+        setUseSendfile(Constants.DEFAULT_USE_SENDFILE);
     }
 
     
@@ -89,8 +91,6 @@ public class AjpAprProtocol extends AbstractAjpProtocol {
     @Override
     public void init() throws Exception {
         endpoint.setName(getName());
-        ((AprEndpoint)endpoint).setHandler(cHandler);
-        ((AprEndpoint)endpoint).setUseSendfile(false);
 
         try {
             endpoint.init();
index da8a3dc..3c13326 100644 (file)
@@ -67,6 +67,7 @@ public class AjpProtocol extends AbstractAjpProtocol {
     public AjpProtocol() {
         endpoint = new JIoEndpoint();
         cHandler = new AjpConnectionHandler(this);
+        ((JIoEndpoint) endpoint).setHandler(cHandler);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
@@ -90,7 +91,6 @@ public class AjpProtocol extends AbstractAjpProtocol {
     @Override
     public void init() throws Exception {
         endpoint.setName(getName());
-        ((JIoEndpoint)endpoint).setHandler(cHandler);
 
         try {
             endpoint.init();
index 7e2313e..b73157e 100644 (file)
@@ -42,6 +42,7 @@ public final class Constants {
     public static final int DEFAULT_CONNECTION_TIMEOUT = -1;
     public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
     public static final boolean DEFAULT_TCP_NO_DELAY = true;
+    public static final boolean DEFAULT_USE_SENDFILE = false;
 
     // Prefix codes for message types from server to container
     public static final byte JK_AJP13_FORWARD_REQUEST   = 2;
index 4e477f8..8a5b1d4 100644 (file)
@@ -72,6 +72,7 @@ public class Http11AprProtocol extends AbstractHttp11Protocol {
     public Http11AprProtocol() {
         endpoint = new AprEndpoint();
         cHandler = new Http11ConnectionHandler(this);
+        ((AprEndpoint) endpoint).setHandler(cHandler);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
@@ -83,7 +84,6 @@ public class Http11AprProtocol extends AbstractHttp11Protocol {
     @Override
     public void init() throws Exception {
         endpoint.setName(getName());
-        ((AprEndpoint)endpoint).setHandler(cHandler);
 
         try {
             endpoint.init();
@@ -123,7 +123,7 @@ public class Http11AprProtocol extends AbstractHttp11Protocol {
             log.info(sm.getString("http11protocol.start", getName()));
     }
 
-    private Http11ConnectionHandler cHandler;
+    private final Http11ConnectionHandler cHandler;
 
     public boolean getUseSendfile() { return ((AprEndpoint)endpoint).getUseSendfile(); }
     public void setUseSendfile(boolean useSendfile) { ((AprEndpoint)endpoint).setUseSendfile(useSendfile); }
index 92ea015..06ce6e1 100644 (file)
@@ -68,7 +68,8 @@ public class Http11NioProtocol extends AbstractHttp11JsseProtocol {
 
     public Http11NioProtocol() {
         endpoint=new NioEndpoint();
-        cHandler = new Http11ConnectionHandler( this );
+        cHandler = new Http11ConnectionHandler(this);
+        ((NioEndpoint) endpoint).setHandler(cHandler);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
@@ -86,7 +87,6 @@ public class Http11NioProtocol extends AbstractHttp11JsseProtocol {
     @Override
     public void init() throws Exception {
         endpoint.setName(getName());
-        ((NioEndpoint)endpoint).setHandler(cHandler);
         
         try {
             endpoint.init();
index 36ae00e..b205329 100644 (file)
@@ -72,6 +72,7 @@ public class Http11Protocol extends AbstractHttp11JsseProtocol {
     public Http11Protocol() {
         endpoint = new JIoEndpoint();
         cHandler = new Http11ConnectionHandler(this);
+        ((JIoEndpoint) endpoint).setHandler(cHandler);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
@@ -91,8 +92,7 @@ public class Http11Protocol extends AbstractHttp11JsseProtocol {
 
     @Override
     public void init() throws Exception {
-        ((JIoEndpoint)endpoint).setName(getName());
-        ((JIoEndpoint)endpoint).setHandler(cHandler);
+        endpoint.setName(getName());
 
         // Verify the validity of the configured socket factory
         try {