tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1519623 - in /tomcat/trunk/java/org/apache/tomcat/util/net: ./ jsse/
Date Tue, 03 Sep 2013 09:51:58 GMT
Author: markt
Date: Tue Sep  3 09:51:57 2013
New Revision: 1519623

URL: http://svn.apache.org/r1519623
Log:
Create AbstractEndpoint.processSocketAsync() which will enable some further refactoring in
the AJP processors.
This requires adding generics to the endpoint so this patch also deals with the side effects
of adding generics.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java
    tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java
    tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java
    tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Tue Sep  3 09:51:57
2013
@@ -43,7 +43,7 @@ import org.apache.tomcat.util.threads.Th
  * @author Mladen Turk
  * @author Remy Maucherat
  */
-public abstract class AbstractEndpoint {
+public abstract class AbstractEndpoint<S> {
 
     // -------------------------------------------------------------- Constants
     protected static final StringManager sm = StringManager.getManager("org.apache.tomcat.util.net.res");
@@ -589,6 +589,12 @@ public abstract class AbstractEndpoint {
     }
 
 
+    // ---------------------------------------------- Request processing methods
+
+    protected abstract void processSocketAsync(SocketWrapper<S> socketWrapper,
+            SocketStatus socketStatus);
+
+
     // ------------------------------------------------------- Lifecycle methods
 
     /*

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Sep  3 09:51:57 2013
@@ -63,7 +63,7 @@ import org.apache.tomcat.util.net.Abstra
  * @author Mladen Turk
  * @author Remy Maucherat
  */
-public class AprEndpoint extends AbstractEndpoint {
+public class AprEndpoint extends AbstractEndpoint<Long> {
 
 
     // -------------------------------------------------------------- Constants
@@ -850,7 +850,8 @@ public class AprEndpoint extends Abstrac
     }
 
 
-    public boolean processSocketAsync(SocketWrapper<Long> socket,
+    @Override
+    public void processSocketAsync(SocketWrapper<Long> socket,
             SocketStatus status) {
         try {
             synchronized (socket) {
@@ -871,7 +872,7 @@ public class AprEndpoint extends Abstrac
                         if (executor == null) {
                             log.warn(sm.getString("endpoint.warn.noExector",
                                     socket, status));
-                            return false;
+                            return;
                         } else {
                             executor.execute(proc);
                         }
@@ -887,15 +888,12 @@ public class AprEndpoint extends Abstrac
             }
         } catch (RejectedExecutionException x) {
             log.warn("Socket processing request was rejected for: "+socket, x);
-            return false;
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
             // This means we got an OOM or similar creating a thread, or that
             // the pool and its queue are full
             log.error(sm.getString("endpoint.process.fail"), t);
-            return false;
         }
-        return true;
     }
 
     private void destroySocket(long socket) {

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java Tue Sep 
3 09:51:57 2013
@@ -35,7 +35,7 @@ public class DefaultServerSocketFactory 
      *
      * @param endpoint  Unused in this implementation.
      */
-    public DefaultServerSocketFactory(AbstractEndpoint endpoint) {
+    public DefaultServerSocketFactory(AbstractEndpoint<?> endpoint) {
     }
 
     @Override

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Tue Sep  3 09:51:57 2013
@@ -51,7 +51,7 @@ import org.apache.tomcat.util.net.jsse.J
  * @author Yoav Shapira
  * @author Remy Maucherat
  */
-public class JIoEndpoint extends AbstractEndpoint {
+public class JIoEndpoint extends AbstractEndpoint<Socket> {
 
 
     // -------------------------------------------------------------- Constants
@@ -557,12 +557,9 @@ public class JIoEndpoint extends Abstrac
      * @param status    Only OPEN and TIMEOUT are used. The others are used for
      *                  Comet requests that are not supported by the BIO (JIO)
      *                  Connector.
-     * @return          <code>true</code> if the socket is passed to the
-     *                  executor, <code>false</code> if something went wrong.
-     *                  Returning <code>false</code> is an indication to close
-     *                  the socket immediately.
      */
-    public boolean processSocketAsync(SocketWrapper<Socket> socket,
+    @Override
+    public void processSocketAsync(SocketWrapper<Socket> socket,
             SocketStatus status) {
         try {
             synchronized (socket) {
@@ -581,7 +578,7 @@ public class JIoEndpoint extends Abstrac
                         }
                         // During shutdown, executor may be null - avoid NPE
                         if (!running) {
-                            return false;
+                            return;
                         }
                         getExecutor().execute(proc);
                         //TODO gotta catch RejectedExecutionException and properly handle
it
@@ -600,9 +597,7 @@ public class JIoEndpoint extends Abstrac
             // This means we got an OOM or similar creating a thread, or that
             // the pool and its queue are full
             log.error(sm.getString("endpoint.process.fail"), t);
-            return false;
         }
-        return true;
     }
 
     protected ConcurrentLinkedQueue<SocketWrapper<Socket>> waitingRequests =

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue Sep  3 09:51:57 2013
@@ -71,7 +71,7 @@ import org.apache.tomcat.util.net.jsse.N
  * @author Remy Maucherat
  * @author Filip Hanik
  */
-public class NioEndpoint extends AbstractEndpoint {
+public class NioEndpoint extends AbstractEndpoint<NioChannel> {
 
 
     // -------------------------------------------------------------- Constants
@@ -600,6 +600,13 @@ public class NioEndpoint extends Abstrac
         return true;
     }
 
+
+    @Override
+    protected void processSocketAsync(SocketWrapper<NioChannel> socketWrapper,
+            SocketStatus socketStatus) {
+        dispatchForEvent(socketWrapper.getSocket(), socketStatus, true);
+    }
+
     public boolean dispatchForEvent(NioChannel socket, SocketStatus status, boolean dispatch)
{
         if (dispatch && status == SocketStatus.OPEN_READ) {
             socket.getPoller().add(socket, OP_CALLBACK);

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java Tue Sep  3 09:51:57
2013
@@ -81,11 +81,11 @@ public abstract class SSLImplementation 
     public abstract String getImplementationName();
 
     public abstract ServerSocketFactory getServerSocketFactory(
-            AbstractEndpoint endpoint);
+            AbstractEndpoint<?> endpoint);
 
     public abstract SSLSupport getSSLSupport(Socket sock);
 
     public abstract SSLSupport getSSLSupport(SSLSession session);
 
-    public abstract SSLUtil getSSLUtil(AbstractEndpoint ep);
+    public abstract SSLUtil getSSLUtil(AbstractEndpoint<?> ep);
 }

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java Tue Sep  3 09:51:57
2013
@@ -43,7 +43,7 @@ public class JSSEImplementation extends 
     }
 
     @Override
-    public ServerSocketFactory getServerSocketFactory(AbstractEndpoint endpoint)  {
+    public ServerSocketFactory getServerSocketFactory(AbstractEndpoint<?> endpoint)
 {
         return new JSSESocketFactory(endpoint);
     }
 
@@ -58,7 +58,7 @@ public class JSSEImplementation extends 
     }
 
     @Override
-    public SSLUtil getSSLUtil(AbstractEndpoint endpoint) {
+    public SSLUtil getSSLUtil(AbstractEndpoint<?> endpoint) {
         return new JSSESocketFactory(endpoint);
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java?rev=1519623&r1=1519622&r2=1519623&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java Tue Sep  3 09:51:57
2013
@@ -142,7 +142,7 @@ public class JSSESocketFactory implement
     }
 
 
-    private AbstractEndpoint endpoint;
+    private AbstractEndpoint<?> endpoint;
 
     protected SSLServerSocketFactory sslProxy = null;
     protected String[] enabledCiphers;
@@ -160,7 +160,7 @@ public class JSSESocketFactory implement
     protected boolean wantClientAuth    = false;
 
 
-    public JSSESocketFactory (AbstractEndpoint endpoint) {
+    public JSSESocketFactory (AbstractEndpoint<?> endpoint) {
         this.endpoint = endpoint;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message