[jboss-remoting-commits] JBoss Remoting SVN: r6323 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri Apr 15 15:20:27 EDT 2011


Author: ron.sigal at jboss.com
Date: 2011-04-15 15:20:27 -0400 (Fri, 15 Apr 2011)
New Revision: 6323

Modified:
   remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-1281: Added special handling for setting the tomcat executor.

Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java	2011-04-15 19:17:31 UTC (rev 6322)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java	2011-04-15 19:20:27 UTC (rev 6323)
@@ -17,6 +17,9 @@
 
 package org.jboss.remoting.transport.coyote;
 
+import org.apache.catalina.Executor;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.core.StandardThreadExecutor;
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.Adapter;
 import org.apache.coyote.ProtocolHandler;
@@ -51,6 +54,7 @@
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -162,6 +166,11 @@
       {
          String key = (String) keys.next();
          Object obj = config.get(key);
+         if ("executor".equals(key) && obj instanceof String)
+         {
+            createAndSetExecutor(protocolHandler, (String) obj);
+            continue;
+         }
          setProperty(protocolHandler, key, obj);
       }
 
@@ -961,6 +970,7 @@
          Method methods[] = o.getClass().getMethods();
          Method setPropertyMethod = null;
          Method setAttributeMethod = null;
+         Method setExecutorMethod = null;
 
          // Try a setFoo( String) or setFoo ( int ) or ( boolean )
          if (value instanceof String)
@@ -1061,13 +1071,24 @@
                else if("setProperty".equals(methods[i].getName()))
                {
                   setPropertyMethod = methods[i];
-               }   
+               }
+               else if ("setExecutor".equals(methods[i].getName()))
+               {
+                  setExecutorMethod = methods[i];
+               }
             }
          }
 
          // Ok, no setXXX found, try a setProperty("name", "value") or setAttribute("name", "value")
-         if(setAttributeMethod != null)
+         if(setExecutorMethod != null && value instanceof Executor)
          {
+            Object params[] = new Object[1];
+            params[0] = value;
+            setExecutorMethod.invoke(o, params);
+            return true;
+         }
+         else if(setAttributeMethod != null)
+         {
             Object params[] = new Object[2];
             params[0] = name;
             params[1] = value;
@@ -1082,10 +1103,10 @@
             setPropertyMethod.invoke(o, params);
             return true;
          }
-
       }
       catch(Exception e)
       {
+         log.debug("unable to set property " + name + " to " + value + ": " + e.getMessage());
          return false;
       }
       return false;
@@ -1110,6 +1131,32 @@
    {
       return contentType.indexOf('\n') + contentType.indexOf('\r') > -2;
    }
+     
+   static private void createAndSetExecutor(ProtocolHandler protocolHandler, String executorConfig)
+   {
+      Executor executor = new StandardThreadExecutor();
+      if (executorConfig != null)
+      {
+         String[] ss = executorConfig.split(",");
+         for (int i = 0; i < ss.length; i++)
+         {
+            int pos = ss[i].indexOf('=');
+            setProperty(executor, ss[i].substring(0, pos).trim(), ss[i].substring(pos + 1).trim());
+         }  
+      }
+      
+      try
+      {
+         executor.start();
+      }
+      catch (LifecycleException e)
+      {
+         log.warn("unable to start executor " + executor, e);
+         return;
+      }
+      
+      setProperty(protocolHandler, "executor", executor);
+   }
 
    public boolean event(Request req, Response res, SocketStatus status) throws Exception
    {



More information about the jboss-remoting-commits mailing list