tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1132404 - in /tomcat/trunk/java/org/apache/coyote: ./ ajp/ http11/
Date Sun, 05 Jun 2011 13:40:58 GMT
Author: markt
Date: Sun Jun  5 13:40:57 2011
New Revision: 1132404

URL: http://svn.apache.org/viewvc?rev=1132404&view=rev
Log:
Create an AbstactConnectionHandler and pull up the common JMX code from the AJP and HTTP connectors

Modified:
    tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
    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/AjpNioProtocol.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
    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

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Sun Jun  5 13:40:57 2011
@@ -18,6 +18,7 @@ package org.apache.coyote;
 
 import java.net.InetAddress;
 import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicLong;
 
 import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
@@ -247,6 +248,12 @@ public abstract class AbstractProtocol i
 
 
     /**
+     * Obtain the name of the protocol, (Http, Ajp, etc.). Used with JMX.
+     */
+    protected abstract String getProtocolName();
+
+
+    /**
      * Obtain the handler associated with the underlying Endpoint
      */
     protected abstract Handler getHandler();
@@ -442,4 +449,72 @@ public abstract class AbstractProtocol i
         if (rgOname != null)
             Registry.getRegistry(null, null).unregisterComponent(rgOname);
     }
+    
+    
+    // ------------------------------------------- Connection handler base class
+    
+    protected abstract static class AbstractConnectionHandler
+            implements AbstractEndpoint.Handler {
+
+        protected RequestGroupInfo global = new RequestGroupInfo();
+        protected AtomicLong registerCount = new AtomicLong(0);
+
+        protected abstract AbstractProtocol getProtocol();
+        protected abstract Log getLog();
+
+
+        @Override
+        public Object getGlobal() {
+            return global;
+        }
+
+
+        protected void register(AbstractProcessor processor) {
+            if (getProtocol().getDomain() != null) {
+                synchronized (this) {
+                    try {
+                        long count = registerCount.incrementAndGet();
+                        RequestInfo rp =
+                            processor.getRequest().getRequestProcessor();
+                        rp.setGlobalProcessor(global);
+                        ObjectName rpName = new ObjectName(
+                                getProtocol().getDomain() +
+                                ":type=RequestProcessor,worker="
+                                + getProtocol().getName() +
+                                ",name=" + getProtocol().getProtocolName() +
+                                "Request" + count);
+                        if (getLog().isDebugEnabled()) {
+                            getLog().debug("Register " + rpName);
+                        }
+                        Registry.getRegistry(null, null).registerComponent(rp,
+                                rpName, null);
+                        rp.setRpName(rpName);
+                    } catch (Exception e) {
+                        getLog().warn("Error registering request");
+                    }
+                }
+            }
+        }
+
+        protected void unregister(AbstractProcessor processor) {
+            if (getProtocol().getDomain() != null) {
+                synchronized (this) {
+                    try {
+                        RequestInfo rp =
+                            processor.getRequest().getRequestProcessor();
+                        rp.setGlobalProcessor(null);
+                        ObjectName rpName = rp.getRpName();
+                        if (getLog().isDebugEnabled()) {
+                            getLog().debug("Unregister " + rpName);
+                        }
+                        Registry.getRegistry(null, null).unregisterComponent(
+                                rpName);
+                        rp.setRpName(null);
+                    } catch (Exception e) {
+                        getLog().warn("Error unregistering request", e);
+                    }
+                }
+            }
+        }
+    }
 }

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java Sun Jun  5 13:40:57 2011
@@ -28,6 +28,13 @@ public abstract class AbstractAjpProtoco
         StringManager.getManager(Constants.Package);
 
 
+    @Override
+    protected String getProtocolName() {
+        return "Ajp";
+    }
+
+
+
     // ------------------------------------------------- AJP specific properties
     // ------------------------------------------ managed in the ProtocolHandler
     

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Sun Jun  5 13:40:57 2011
@@ -20,16 +20,11 @@ package org.apache.coyote.ajp;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.ObjectName;
-
-import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
+import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.AprEndpoint;
 import org.apache.tomcat.util.net.AprEndpoint.Handler;
@@ -106,11 +101,10 @@ public class AjpAprProtocol extends Abst
     // --------------------------------------  AjpConnectionHandler Inner Class
 
 
-    protected static class AjpConnectionHandler implements Handler {
+    protected static class AjpConnectionHandler
+            extends AbstractConnectionHandler implements Handler {
 
         protected AjpAprProtocol proto;
-        protected AtomicLong registerCount = new AtomicLong(0);
-        protected RequestGroupInfo global = new RequestGroupInfo();
 
         protected ConcurrentHashMap<SocketWrapper<Long>, AjpAprProcessor> connections
=
             new ConcurrentHashMap<SocketWrapper<Long>, AjpAprProcessor>();
@@ -160,8 +154,13 @@ public class AjpAprProtocol extends Abst
         }
 
         @Override
-        public Object getGlobal() {
-            return global;
+        protected AbstractProtocol getProtocol() {
+            return proto;
+        }
+
+        @Override
+        protected Log getLog() {
+            return log;
         }
 
         @Override
@@ -270,48 +269,5 @@ public class AjpAprProtocol extends Abst
             register(processor);
             return processor;
         }
-        
-        protected void register(AjpAprProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        long count = registerCount.incrementAndGet();
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(global);
-                        ObjectName rpName = new ObjectName
-                            (proto.getDomain() + ":type=RequestProcessor,worker="
-                                + proto.getName() + ",name=AjpRequest" + count);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Register " + rpName);
-                        }
-                        Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
-                        rp.setRpName(rpName);
-                    } catch (Exception e) {
-                        log.warn("Error registering request");
-                    }
-                }
-            }
-        }
-
-        protected void unregister(AjpAprProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(null);
-                        ObjectName rpName = rp.getRpName();
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unregister " + rpName);
-                        }
-                        Registry.getRegistry(null, null).unregisterComponent(rpName);
-                        rp.setRpName(null);
-                    } catch (Exception e) {
-                        log.warn("Error unregistering request", e);
-                    }
-                }
-            }
-        }
-
     }
-
 }

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java?rev=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java Sun Jun  5 13:40:57 2011
@@ -22,16 +22,11 @@ import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.ObjectName;
-
-import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
+import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.NioChannel;
 import org.apache.tomcat.util.net.NioEndpoint;
@@ -95,11 +90,10 @@ public class AjpNioProtocol extends Abst
     // --------------------------------------  AjpConnectionHandler Inner Class
 
 
-    protected static class AjpConnectionHandler implements Handler {
+    protected static class AjpConnectionHandler
+            extends AbstractConnectionHandler implements Handler {
 
         protected AjpNioProtocol proto;
-        protected AtomicLong registerCount = new AtomicLong(0);
-        protected RequestGroupInfo global = new RequestGroupInfo();
 
         protected ConcurrentHashMap<NioChannel, AjpNioProcessor> connections =
             new ConcurrentHashMap<NioChannel, AjpNioProcessor>();
@@ -149,8 +143,13 @@ public class AjpNioProtocol extends Abst
         }
 
         @Override
-        public Object getGlobal() {
-            return global;
+        protected AbstractProtocol getProtocol() {
+            return proto;
+        }
+
+        @Override
+        protected Log getLog() {
+            return log;
         }
 
         @Override
@@ -314,48 +313,5 @@ public class AjpNioProtocol extends Abst
             register(processor);
             return processor;
         }
-        
-        protected void register(AjpNioProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        long count = registerCount.incrementAndGet();
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(global);
-                        ObjectName rpName = new ObjectName
-                            (proto.getDomain() + ":type=RequestProcessor,worker="
-                                + proto.getName() + ",name=AjpRequest" + count);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Register " + rpName);
-                        }
-                        Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
-                        rp.setRpName(rpName);
-                    } catch (Exception e) {
-                        log.warn("Error registering request");
-                    }
-                }
-            }
-        }
-
-        protected void unregister(AjpNioProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(null);
-                        ObjectName rpName = rp.getRpName();
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unregister " + rpName);
-                        }
-                        Registry.getRegistry(null, null).unregisterComponent(rpName);
-                        rp.setRpName(null);
-                    } catch (Exception e) {
-                        log.warn("Error unregistering request", e);
-                    }
-                }
-            }
-        }
-
     }
-
 }

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java Sun Jun  5 13:40:57 2011
@@ -21,16 +21,11 @@ import java.net.Socket;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.ObjectName;
-
-import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
+import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.JIoEndpoint;
 import org.apache.tomcat.util.net.JIoEndpoint.Handler;
@@ -95,11 +90,10 @@ public class AjpProtocol extends Abstrac
     // --------------------------------------  AjpConnectionHandler Inner Class
 
 
-    protected static class AjpConnectionHandler implements Handler {
+    protected static class AjpConnectionHandler
+            extends AbstractConnectionHandler implements Handler {
 
         protected AjpProtocol proto;
-        protected AtomicLong registerCount = new AtomicLong(0);
-        protected RequestGroupInfo global = new RequestGroupInfo();
 
         protected ConcurrentHashMap<SocketWrapper<Socket>, AjpProcessor> connections
=
             new ConcurrentHashMap<SocketWrapper<Socket>, AjpProcessor>();
@@ -144,13 +138,19 @@ public class AjpProtocol extends Abstrac
             }
         };
 
+        
         public AjpConnectionHandler(AjpProtocol proto) {
             this.proto = proto;
         }
         
         @Override
-        public Object getGlobal() {
-            return global;
+        protected AbstractProtocol getProtocol() {
+            return proto;
+        }
+
+        @Override
+        protected Log getLog() {
+            return log;
         }
 
         @Override
@@ -227,47 +227,5 @@ public class AjpProtocol extends Abstrac
             register(processor);
             return processor;
         }
-        
-        protected void register(AjpProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        long count = registerCount.incrementAndGet();
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(global);
-                        ObjectName rpName = new ObjectName
-                            (proto.getDomain() + ":type=RequestProcessor,worker="
-                                + proto.getName() + ",name=AjpRequest" + count);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Register " + rpName);
-                        }
-                        Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
-                        rp.setRpName(rpName);
-                    } catch (Exception e) {
-                        log.warn("Error registering request");
-                    }
-                }
-            }
-        }
-
-        protected void unregister(AjpProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(null);
-                        ObjectName rpName = rp.getRpName();
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unregister " + rpName);
-                        }
-                        Registry.getRegistry(null, null).unregisterComponent(rpName);
-                        rp.setRpName(null);
-                    } catch (Exception e) {
-                        log.warn("Error unregistering request", e);
-                    }
-                }
-            }
-        }
     }
-
 }

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java Sun Jun  5 13:40:57
2011
@@ -28,6 +28,12 @@ public abstract class AbstractHttp11Prot
         StringManager.getManager(Constants.Package);
 
 
+    @Override
+    protected String getProtocolName() {
+        return "Http";
+    }
+
+
     // ------------------------------------------------ HTTP specific properties
     // ------------------------------------------ managed in the ProtocolHandler
 

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Sun Jun  5 13:40:57
2011
@@ -17,21 +17,14 @@
 
 package org.apache.coyote.http11;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.ObjectName;
-
-import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
+import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.AprEndpoint;
 import org.apache.tomcat.util.net.AprEndpoint.Handler;
@@ -190,11 +183,10 @@ public class Http11AprProtocol extends A
 
     // --------------------  Connection handler --------------------
 
-    protected static class Http11ConnectionHandler implements Handler {
+    protected static class Http11ConnectionHandler
+            extends AbstractConnectionHandler implements Handler {
         
         protected Http11AprProtocol proto;
-        protected AtomicLong registerCount = new AtomicLong(0);
-        protected RequestGroupInfo global = new RequestGroupInfo();
         
         protected ConcurrentHashMap<Long, Http11AprProcessor> connections =
             new ConcurrentHashMap<Long, Http11AprProcessor>();
@@ -245,8 +237,13 @@ public class Http11AprProtocol extends A
         }
 
         @Override
-        public Object getGlobal() {
-            return global;
+        protected AbstractProtocol getProtocol() {
+            return proto;
+        }
+
+        @Override
+        protected Log getLog() {
+            return log;
         }
         
         @Override
@@ -418,61 +415,5 @@ public class Http11AprProtocol extends A
             register(processor);
             return processor;
         }
-        
-        protected void register(Http11AprProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        long count = registerCount.incrementAndGet();
-                        final RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(global);
-                        final ObjectName rpName = new ObjectName
-                            (proto.getDomain() + ":type=RequestProcessor,worker="
-                                + proto.getName() + ",name=HttpRequest" + count);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Register " + rpName);
-                        }
-                        if (Constants.IS_SECURITY_ENABLED) {
-                            AccessController.doPrivileged(new PrivilegedAction<Void>()
{
-                                @Override
-                                public Void run() {
-                                    try {
-                                        Registry.getRegistry(null, null).registerComponent(rp,
rpName, null);
-                                    } catch (Exception e) {
-                                        log.warn("Error registering request");
-                                    }
-                                    return null;
-                                }
-                            });
-                        } else {
-                            Registry.getRegistry(null, null).registerComponent(rp, rpName,
null);
-                        }
-                        rp.setRpName(rpName);
-                    } catch (Exception e) {
-                        log.warn("Error registering request");
-                    }
-                }
-            }
-        }
-
-        protected void unregister(Http11AprProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(null);
-                        ObjectName rpName = rp.getRpName();
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unregister " + rpName);
-                        }
-                        Registry.getRegistry(null, null).unregisterComponent(rpName);
-                        rp.setRpName(null);
-                    } catch (Exception e) {
-                        log.warn("Error unregistering request", e);
-                    }
-                }
-            }
-        }
-
     }
 }

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Sun Jun  5 13:40:57
2011
@@ -19,22 +19,15 @@ package org.apache.coyote.http11;
 
 import java.nio.channels.SelectionKey;
 import java.nio.channels.SocketChannel;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.ObjectName;
-
-import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
+import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.NioChannel;
 import org.apache.tomcat.util.net.NioEndpoint;
@@ -158,11 +151,10 @@ public class Http11NioProtocol extends A
 
     // --------------------  Connection handler --------------------
 
-    protected static class Http11ConnectionHandler implements Handler {
+    protected static class Http11ConnectionHandler
+            extends AbstractConnectionHandler implements Handler {
 
         protected Http11NioProtocol proto;
-        protected AtomicLong registerCount = new AtomicLong(0);
-        protected RequestGroupInfo global = new RequestGroupInfo();
 
         protected ConcurrentHashMap<NioChannel, Http11NioProcessor> connections =
             new ConcurrentHashMap<NioChannel, Http11NioProcessor>();
@@ -182,7 +174,7 @@ public class Http11NioProtocol extends A
                         size.incrementAndGet();
                     }
                 }
-                if (!result) deregister(processor);
+                if (!result) unregister(processor);
                 return result;
             }
             
@@ -199,7 +191,7 @@ public class Http11NioProtocol extends A
             public void clear() {
                 Http11NioProcessor next = poll();
                 while ( next != null ) {
-                    deregister(next);
+                    unregister(next);
                     next = poll();
                 }
                 super.clear();
@@ -212,11 +204,17 @@ public class Http11NioProtocol extends A
         }
         
         @Override
-        public Object getGlobal() {
-            return global;
+        protected AbstractProtocol getProtocol() {
+            return proto;
         }
 
         @Override
+        protected Log getLog() {
+            return log;
+        }
+        
+        
+        @Override
         public SSLImplementation getSslImplementation() {
             return proto.sslImplementation;
         }
@@ -238,7 +236,7 @@ public class Http11NioProtocol extends A
                     it.remove();
                     Http11NioProcessor result = entry.getValue();
                     result.recycle();
-                    deregister(result);
+                    unregister(result);
                     released = true;
                     break;
                 }
@@ -436,60 +434,5 @@ public class Http11NioProtocol extends A
             register(processor);
             return processor;
         }
-
-        protected void register(Http11NioProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        long count = registerCount.incrementAndGet();
-                        final RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(global);
-                        final ObjectName rpName = new ObjectName
-                            (proto.getDomain() + ":type=RequestProcessor,worker="
-                             + proto.getName() + ",name=HttpRequest" + count);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Register " + rpName);
-                        }
-                        if (Constants.IS_SECURITY_ENABLED) {
-                            AccessController.doPrivileged(new PrivilegedAction<Void>()
{
-                                @Override
-                                public Void run() {
-                                    try {
-                                        Registry.getRegistry(null, null).registerComponent(rp,
rpName, null);
-                                    } catch (Exception e) {
-                                        log.warn("Error registering request");
-                                    }
-                                    return null;
-                                }
-                            });
-                        } else {
-                            Registry.getRegistry(null, null).registerComponent(rp, rpName,
null);
-                        }
-                        rp.setRpName(rpName);
-                    } catch (Exception e) {
-                        log.warn("Error registering request");
-                    }
-                }
-            }
-        }
-    
-        protected void deregister(Http11NioProcessor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(null);
-                        ObjectName rpName = rp.getRpName();
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unregister " + rpName);
-                        }
-                        Registry.getRegistry(null, null).unregisterComponent(rpName);
-                        rp.setRpName(null);
-                    } catch (Exception e) {
-                        log.warn("Error unregistering request", e);
-                    }
-                }
-            }
-        }
     }
 }

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=1132404&r1=1132403&r2=1132404&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Sun Jun  5 13:40:57 2011
@@ -18,20 +18,13 @@
 package org.apache.coyote.http11;
 
 import java.net.Socket;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.ObjectName;
-
-import org.apache.coyote.RequestGroupInfo;
-import org.apache.coyote.RequestInfo;
+import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.JIoEndpoint;
 import org.apache.tomcat.util.net.JIoEndpoint.Handler;
@@ -109,11 +102,10 @@ public class Http11Protocol extends Abst
 
     // -----------------------------------  Http11ConnectionHandler Inner Class
 
-    protected static class Http11ConnectionHandler implements Handler {
+    protected static class Http11ConnectionHandler
+            extends AbstractConnectionHandler implements Handler {
 
         protected Http11Protocol proto;
-        protected AtomicLong registerCount = new AtomicLong(0);
-        protected RequestGroupInfo global = new RequestGroupInfo();
             
         protected ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor> connections
=
             new ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor>();
@@ -163,11 +155,16 @@ public class Http11Protocol extends Abst
         }
 
         @Override
-        public Object getGlobal() {
-            return global;
+        protected AbstractProtocol getProtocol() {
+            return proto;
         }
 
         @Override
+        protected Log getLog() {
+            return log;
+        }
+        
+        @Override
         public SSLImplementation getSslImplementation() {
             return proto.sslImplementation;
         }
@@ -261,60 +258,5 @@ public class Http11Protocol extends Abst
             register(processor);
             return processor;
         }
-        
-        protected void register(Http11Processor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        long count = registerCount.incrementAndGet();
-                        final RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(global);
-                        final ObjectName rpName = new ObjectName
-                            (proto.getDomain() + ":type=RequestProcessor,worker="
-                                + proto.getName() + ",name=HttpRequest" + count);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Register " + rpName);
-                        }
-                        if (Constants.IS_SECURITY_ENABLED) {
-                            AccessController.doPrivileged(new PrivilegedAction<Void>()
{
-                                @Override
-                                public Void run() {
-                                    try {
-                                        Registry.getRegistry(null, null).registerComponent(rp,
rpName, null);
-                                    } catch (Exception e) {
-                                        log.warn("Error registering request");
-                                    }
-                                    return null;
-                                }
-                            });
-                        } else {
-                            Registry.getRegistry(null, null).registerComponent(rp, rpName,
null);
-                        }
-                        rp.setRpName(rpName);
-                    } catch (Exception e) {
-                        log.warn("Error registering request");
-                    }
-                }
-            }
-        }
-
-        protected void unregister(Http11Processor processor) {
-            if (proto.getDomain() != null) {
-                synchronized (this) {
-                    try {
-                        RequestInfo rp = processor.getRequest().getRequestProcessor();
-                        rp.setGlobalProcessor(null);
-                        ObjectName rpName = rp.getRpName();
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unregister " + rpName);
-                        }
-                        Registry.getRegistry(null, null).unregisterComponent(rpName);
-                        rp.setRpName(null);
-                    } catch (Exception e) {
-                        log.warn("Error unregistering request", e);
-                    }
-                }
-            }
-        }
     }
 }



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


Mime
View raw message