tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1042873 - in /tomcat/trunk/java/org/apache: coyote/ coyote/ajp/ coyote/http11/ tomcat/util/net/
Date Tue, 07 Dec 2010 00:08:38 GMT
Author: markt
Date: Tue Dec  7 00:08:38 2010
New Revision: 1042873

URL: http://svn.apache.org/viewvc?rev=1042873&view=rev
Log:
Re-factoring in support of https://issues.apache.org/bugzilla/show_bug.cgi?id=50360
Pull up the concrete destroy() method - required a fair bit of refactoring
Pull up the abstract init() method()

Modified:
    tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java
    tomcat/trunk/java/org/apache/coyote/LocalStrings.properties
    tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
    tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
    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/JIoEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java Tue Dec  7 00:08:38 2010
@@ -26,6 +26,7 @@ import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
 import org.apache.juli.logging.Log;
+import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler;
 import org.apache.tomcat.util.res.StringManager;
@@ -332,4 +333,33 @@ public abstract class AbstractProtocolHa
     public void postDeregister() {
         // NOOP
     }
+
+
+    // ------------------------------------------------------- Lifecycle methods
+
+    // TODO Keep current state and check for invalid transitions
+
+    @Override
+    public abstract void init() throws Exception;
+
+
+    @Override
+    public final void destroy() {
+        if(getLog().isInfoEnabled()) {
+            getLog().info(sm.getString("abstractProtocolHandler.destroy",
+                    getName()));
+        }
+        try {
+            endpoint.destroy();
+        } catch (Exception e) {
+            getLog().error(sm.getString(
+                    "abstractProtocolHandler.endPointDestroyError", getName()),
+                    e);
+        }
+        
+        if( tpOname!=null )
+            Registry.getRegistry(null, null).unregisterComponent(tpOname);
+        if( rgOname != null )
+            Registry.getRegistry(null, null).unregisterComponent(rgOname);
+    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/LocalStrings.properties?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/LocalStrings.properties Tue Dec  7 00:08:38 2010
@@ -15,5 +15,7 @@
 
 abstractProtocolHandler.getAttribute=Get attribute [{0}] with value [{1}]
 abstractProtocolHandler.setAttribute=Set attribute [{0}] with value [{1}]
+abstractProtocolHandler.endPointDestroyError=Failed to destroy end point associated with
ProtocolHandler [{0}]
+abstractProtocolHandler.destroy=Destroying ProtocolHandler [{0}]
 
 asyncStateMachine.invalidAsyncState=Calling [{0}] is not valid for a request with Async state
[{1}]

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java Tue Dec  7 00:08:38 2010
@@ -17,7 +17,6 @@
 package org.apache.coyote.ajp;
 
 import org.apache.coyote.AbstractProtocolHandler;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.res.StringManager;
 
 public abstract class AbstractAjpProtocol extends AbstractProtocolHandler {
@@ -114,16 +113,4 @@ public abstract class AbstractAjpProtoco
         if (getLog().isInfoEnabled())
             getLog().info(sm.getString("ajpprotocol.stop", getName()));
     }
-
-
-    @Override
-    public void destroy() throws Exception {
-        if (getLog().isInfoEnabled())
-            getLog().info(sm.getString("ajpprotocol.destroy", getName()));
-        endpoint.destroy();
-        if (tpOname!=null)
-            Registry.getRegistry(null, null).unregisterComponent(tpOname);
-        if (rgOname != null)
-            Registry.getRegistry(null, null).unregisterComponent(rgOname);
-    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Tue Dec  7 00:08:38 2010
@@ -151,10 +151,6 @@ public class AjpAprProtocol extends Abst
         protected AjpAprProtocol proto;
         protected AtomicLong registerCount = new AtomicLong(0);
         protected RequestGroupInfo global = new RequestGroupInfo();
-        @Override
-        public RequestGroupInfo getGlobal() {
-            return global;
-        }
 
         protected ConcurrentHashMap<SocketWrapper<Long>, AjpAprProcessor> connections
=
             new ConcurrentHashMap<SocketWrapper<Long>, AjpAprProcessor>();
@@ -203,6 +199,16 @@ public class AjpAprProtocol extends Abst
             this.proto = proto;
         }
 
+        @Override
+        public RequestGroupInfo getGlobal() {
+            return global;
+        }
+
+        @Override
+        public void recycle() {
+            recycledProcessors.clear();
+        }
+        
         // FIXME: Support for this could be added in AJP as well
         @Override
         public SocketState event(SocketWrapper<Long> socket, SocketStatus status) {

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java Tue Dec  7 00:08:38 2010
@@ -140,10 +140,6 @@ public class AjpProtocol extends Abstrac
         protected AjpProtocol proto;
         protected AtomicLong registerCount = new AtomicLong(0);
         protected RequestGroupInfo global = new RequestGroupInfo();
-        @Override
-        public RequestGroupInfo getGlobal() {
-            return global;
-        }
 
         protected ConcurrentHashMap<SocketWrapper<Socket>, AjpProcessor> connections
=
             new ConcurrentHashMap<SocketWrapper<Socket>, AjpProcessor>();
@@ -193,6 +189,16 @@ public class AjpProtocol extends Abstrac
         }
         
         @Override
+        public RequestGroupInfo getGlobal() {
+            return global;
+        }
+
+        @Override
+        public void recycle() {
+            recycledProcessors.clear();
+        }
+        
+        @Override
         public SocketState process(SocketWrapper<Socket> socket) {
             return process(socket,SocketStatus.OPEN);
         }

Modified: tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties Tue Dec  7 00:08:38 2010
@@ -23,7 +23,6 @@
 # AjpAprProtocol
 #
 
-ajpprotocol.destroy=Destroying Coyote AJP/1.3 on {0}
 ajpprotocol.endpoint.initerror=Error initializing endpoint
 ajpprotocol.endpoint.starterror=Error starting endpoint
 ajpprotocol.endpoint.stoperror=Error stopping endpoint

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java Tue Dec  7 00:08:38
2010
@@ -17,7 +17,6 @@
 package org.apache.coyote.http11;
 
 import org.apache.coyote.AbstractProtocolHandler;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.res.StringManager;
 
 public abstract class AbstractHttp11Protocol extends AbstractProtocolHandler {
@@ -195,9 +194,6 @@ public abstract class AbstractHttp11Prot
     // ------------------------------------------------------- Lifecycle methods
     
     @Override
-    public abstract void init() throws Exception;
-
-    @Override
     public void pause() throws Exception {
         try {
             endpoint.pause();
@@ -235,17 +231,4 @@ public abstract class AbstractHttp11Prot
         if(getLog().isInfoEnabled())
             getLog().info(sm.getString("http11protocol.stop", getName()));
     }
-
-    @Override
-    public void destroy() throws Exception {
-        if(getLog().isInfoEnabled())
-            getLog().info(sm.getString("http11protocol.destroy", getName()));
-        endpoint.destroy();
-        if( tpOname!=null )
-            Registry.getRegistry(null, null).unregisterComponent(tpOname);
-        if( rgOname != null )
-            Registry.getRegistry(null, null).unregisterComponent(rgOname);
-    }
-    
-
 }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Tue Dec  7 00:08:38
2010
@@ -123,12 +123,6 @@ public class Http11AprProtocol extends A
             log.info(sm.getString("http11protocol.start", getName()));
     }
 
-    @Override
-    public void destroy() throws Exception {
-        cHandler.recycledProcessors.clear();
-        super.destroy();
-    }
-
     private Http11ConnectionHandler cHandler;
 
     public boolean getUseSendfile() { return ((AprEndpoint)endpoint).getUseSendfile(); }
@@ -245,13 +239,10 @@ public class Http11AprProtocol extends A
         protected Http11AprProtocol proto;
         protected AtomicLong registerCount = new AtomicLong(0);
         protected RequestGroupInfo global = new RequestGroupInfo();
-        @Override
-        public RequestGroupInfo getGlobal() {
-            return global;
-        }
         
         protected ConcurrentHashMap<SocketWrapper<Long>, Http11AprProcessor>
connections =
             new ConcurrentHashMap<SocketWrapper<Long>, Http11AprProcessor>();
+
         protected ConcurrentLinkedQueue<Http11AprProcessor> recycledProcessors = 
             new ConcurrentLinkedQueue<Http11AprProcessor>() {
             private static final long serialVersionUID = 1L;
@@ -298,6 +289,16 @@ public class Http11AprProtocol extends A
         }
 
         @Override
+        public RequestGroupInfo getGlobal() {
+            return global;
+        }
+        
+        @Override
+        public void recycle() {
+            recycledProcessors.clear();
+        }
+        
+        @Override
         public SocketState event(SocketWrapper<Long> socket, SocketStatus status) {
             Http11AprProcessor processor = connections.get(socket);
             

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Tue Dec  7 00:08:38
2010
@@ -207,13 +207,10 @@ public class Http11NioProtocol extends A
         protected Http11NioProtocol proto;
         protected static int count = 0;
         protected RequestGroupInfo global = new RequestGroupInfo();
-        @Override
-        public RequestGroupInfo getGlobal() {
-            return global;
-        }
 
         protected ConcurrentHashMap<NioChannel, Http11NioProcessor> connections =
             new ConcurrentHashMap<NioChannel, Http11NioProcessor>();
+
         protected ConcurrentLinkedQueue<Http11NioProcessor> recycledProcessors = new
ConcurrentLinkedQueue<Http11NioProcessor>() {
             private static final long serialVersionUID = 1L;
             protected AtomicInteger size = new AtomicInteger(0);
@@ -258,7 +255,12 @@ public class Http11NioProtocol extends A
         }
         
         @Override
-        public void releaseCaches() {
+        public RequestGroupInfo getGlobal() {
+            return global;
+        }
+
+        @Override
+        public void recycle() {
             recycledProcessors.clear();
         }
         

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Tue Dec  7 00:08:38 2010
@@ -159,14 +159,8 @@ public class Http11Protocol extends Abst
     }
 
 
-    @Override
-    public void destroy() throws Exception {
-        cHandler.recycledProcessors.clear();
-        super.destroy();
-    }
     // ------------------------------------------------------------- Properties
 
-
     /**
      * Name of the socket factory.
      */
@@ -191,10 +185,6 @@ public class Http11Protocol extends Abst
         protected Http11Protocol proto;
         protected AtomicLong registerCount = new AtomicLong(0);
         protected RequestGroupInfo global = new RequestGroupInfo();
-        @Override
-        public RequestGroupInfo getGlobal() {
-            return global;
-        }
             
         protected ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor> connections
=
             new ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor>();
@@ -244,6 +234,16 @@ public class Http11Protocol extends Abst
         }
 
         @Override
+        public RequestGroupInfo getGlobal() {
+            return global;
+        }
+
+        @Override
+        public void recycle() {
+            recycledProcessors.clear();
+        }
+
+        @Override
         public SocketState process(SocketWrapper<Socket> socket) {
             return process(socket,SocketStatus.OPEN);
         }

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=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Tue Dec  7 00:08:38
2010
@@ -76,7 +76,7 @@ public abstract class AbstractEndpoint {
 
     public static interface Handler {
         /**
-         * Different types of socket states to react upon
+         * Different types of socket states to react upon.
          */
         public enum SocketState {
             OPEN, CLOSED, LONG, ASYNC_END
@@ -84,9 +84,15 @@ public abstract class AbstractEndpoint {
         
 
         /**
-         * Obtain the GlobalRequestProcessor associated with the handler
+         * Obtain the GlobalRequestProcessor associated with the handler.
          */
         public RequestGroupInfo getGlobal();
+        
+        
+        /**
+         * Recycle resources associated with the handler.
+         */
+        public void recycle();
     }
 
     // Standard SSL Configuration attributes

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=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Dec  7 00:08:38 2010
@@ -690,6 +690,8 @@ public class AprEndpoint extends Abstrac
             rootPool = 0;
         }
 
+        handler.recycle();
+
         initialized = false;
     }
 

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=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Tue Dec  7 00:08:38 2010
@@ -466,6 +466,7 @@ public class JIoEndpoint extends Abstrac
             }
             serverSocket = null;
         }
+        handler.recycle();
         initialized = false ;
     }
 

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=1042873&r1=1042872&r2=1042873&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue Dec  7 00:08:38 2010
@@ -427,7 +427,7 @@ public class NioEndpoint extends Abstrac
         this.keyCache.clear();
         this.nioChannels.clear();
         this.processorCache.clear();
-        if ( handler != null ) handler.releaseCaches();
+        if ( handler != null ) handler.recycle();
         
     }
     
@@ -1478,7 +1478,6 @@ public class NioEndpoint extends Abstrac
     public interface Handler extends AbstractEndpoint.Handler {
         public SocketState process(NioChannel socket);
         public SocketState event(NioChannel socket, SocketStatus status);
-        public void releaseCaches();
         public void release(NioChannel socket);
         public void release(SocketChannel socket);
     }



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


Mime
View raw message