[jboss-remoting-commits] JBoss Remoting SVN: r4829 - remoting2/branches/2.2/src/main/org/jboss/remoting/callback.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Sat Jan 17 23:18:44 EST 2009


Author: ron.sigal at jboss.com
Date: 2009-01-17 23:18:44 -0500 (Sat, 17 Jan 2009)
New Revision: 4829

Modified:
   remoting2/branches/2.2/src/main/org/jboss/remoting/callback/CallbackPoller.java
Log:
JBREM-1082, JBREM-1084: If "useAllParams" parameter is set to "true", uses InvokerLocator parameters and Client's configuration map.

Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/callback/CallbackPoller.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/callback/CallbackPoller.java	2009-01-18 04:16:08 UTC (rev 4828)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/callback/CallbackPoller.java	2009-01-18 04:18:44 UTC (rev 4829)
@@ -32,6 +32,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.remoting.Client;
 import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.transport.ClientInvoker;
 
 /**
  * CallbackPoller is used to simulate push callbacks on transports that don't support
@@ -120,7 +121,7 @@
    private boolean running;
    private int maxErrorCount = -1;
    private int errorCount;
-   
+   private boolean useAllParams;
 
    private ArrayList toHandleList = new ArrayList();
    private ArrayList toAcknowledgeList = new ArrayList();
@@ -581,145 +582,170 @@
    
    private void configureParameters()
    {
-      if (metadata != null)
+      Map config = new HashMap();
+      ClientInvoker invoker = client.getInvoker();
+      if (invoker != null)
       {
-         Object val = metadata.get(ServerInvoker.BLOCKING_MODE);
-         if (val != null)
+         config.putAll(invoker.getLocator().getParameters());
+      }
+      config.putAll(client.getConfiguration());
+      config.putAll(metadata);
+      
+      Object val = config.get(Client.USE_ALL_PARAMS);
+      if (val != null)
+      {
+         if (val instanceof String)
          {
-            if (val instanceof String)
+            useAllParams = Boolean.valueOf((String) val).booleanValue();
+         }
+         else
+         {
+            log.warn("Value for " + Client.USE_ALL_PARAMS + " must be of type " +
+                     String.class.getName() + " and is " + val.getClass().getName());
+         }
+      }
+      log.debug(this + ": useAllParams: " + useAllParams);
+      if (!useAllParams)
+      {
+         config = metadata;
+      }
+      
+      val = config.get(ServerInvoker.BLOCKING_MODE);
+      if (val != null)
+      {
+         if (val instanceof String)
+         {
+            if (ServerInvoker.BLOCKING.equals(val))
             {
-               if (ServerInvoker.BLOCKING.equals(val))
-               {
-                  blocking = true;
-                  synchronizedShutdown = false;
-               }
-               else if (ServerInvoker.NONBLOCKING.equals(val))
-               {
-                  blocking = false;
-                  synchronizedShutdown = true;
-               }
-               else
-               {
-                  log.warn("Value for " + ServerInvoker.BLOCKING_MODE + 
-                           " configuration is " + val + ". Must be either " +
-                           ServerInvoker.BLOCKING + " or " + ServerInvoker.NONBLOCKING +
-                           ". Using " + ServerInvoker.BLOCKING + ".");
-               }
+               blocking = true;
+               synchronizedShutdown = false;
             }
+            else if (ServerInvoker.NONBLOCKING.equals(val))
+            {
+               blocking = false;
+               synchronizedShutdown = true;
+            }
             else
             {
                log.warn("Value for " + ServerInvoker.BLOCKING_MODE + 
-                     " configuration must be of type " + String.class.getName() +
-                        " and is of type " + val.getClass().getName());
+                     " configuration is " + val + ". Must be either " +
+                     ServerInvoker.BLOCKING + " or " + ServerInvoker.NONBLOCKING +
+                     ". Using " + ServerInvoker.BLOCKING + ".");
             }
          }
-         
-         // Default blocking mode on server is nonblocking.
-         if (blocking)
-            metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
-         
-         val = metadata.get(ServerInvoker.BLOCKING_TIMEOUT);
-         if (val != null)
+         else
          {
-            if (val instanceof String)
-            {
-               try
-               {
-                  int blockingTimeout = Integer.parseInt((String) val);
-                  metadata.put(ServerInvoker.TIMEOUT, Integer.toString(blockingTimeout));
-               }
-               catch (NumberFormatException e)
-               {
-                  log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long.  " + e.getMessage());
-               }
-            }
-            else
-            {
-               log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() +
-                        " and is " + val.getClass().getName());
-            }
+            log.warn("Value for " + ServerInvoker.BLOCKING_MODE + 
+                  " configuration must be of type " + String.class.getName() +
+                  " and is of type " + val.getClass().getName());
          }
-         
-         val = metadata.get(SYNCHRONIZED_SHUTDOWN);
-         if (val != null)
+      }
+
+      // Default blocking mode on server is nonblocking.
+      if (blocking)
+         metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
+
+      val = config.get(ServerInvoker.BLOCKING_TIMEOUT);
+      if (val != null)
+      {
+         if (val instanceof String)
          {
-            if (val instanceof String)
+            try
             {
-               synchronizedShutdown = Boolean.valueOf((String) val).booleanValue();
+               int blockingTimeout = Integer.parseInt((String) val);
+               metadata.put(ServerInvoker.TIMEOUT, Integer.toString(blockingTimeout));
             }
-            else
+            catch (NumberFormatException e)
             {
-               log.warn("Value for " + SYNCHRONIZED_SHUTDOWN + " must be of type " + String.class.getName() +
-                     " and is " + val.getClass().getName());
+               log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long.  " + e.getMessage());
             }
          }
-         
-         val = metadata.get(CALLBACK_POLL_PERIOD);
-         if (val != null)
+         else
          {
-            if (val instanceof String)
+            log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() +
+                  " and is " + val.getClass().getName());
+         }
+      }
+
+      val = config.get(SYNCHRONIZED_SHUTDOWN);
+      if (val != null)
+      {
+         if (val instanceof String)
+         {
+            synchronizedShutdown = Boolean.valueOf((String) val).booleanValue();
+         }
+         else
+         {
+            log.warn("Value for " + SYNCHRONIZED_SHUTDOWN + " must be of type " + String.class.getName() +
+                  " and is " + val.getClass().getName());
+         }
+      }
+
+      val = config.get(CALLBACK_POLL_PERIOD);
+      if (val != null)
+      {
+         if (val instanceof String)
+         {
+            try
             {
-               try
-               {
-                  pollPeriod = Long.parseLong((String) val);
-               }
-               catch (NumberFormatException e)
-               {
-                  log.warn("Error converting " + CALLBACK_POLL_PERIOD + " to type long.  " + e.getMessage());
-               }
+               pollPeriod = Long.parseLong((String) val);
             }
-            else
+            catch (NumberFormatException e)
             {
-               log.warn("Value for " + CALLBACK_POLL_PERIOD + " configuration must be of type " + String.class.getName() +
-                        " and is " + val.getClass().getName());
+               log.warn("Error converting " + CALLBACK_POLL_PERIOD + " to type long.  " + e.getMessage());
             }
          }
-         val = metadata.get(CALLBACK_SCHEDULE_MODE);
-         if (val != null)
+         else
          {
-            if (val instanceof String)
+            log.warn("Value for " + CALLBACK_POLL_PERIOD + " configuration must be of type " + String.class.getName() +
+                  " and is " + val.getClass().getName());
+         }
+      }
+      val = config.get(CALLBACK_SCHEDULE_MODE);
+      if (val != null)
+      {
+         if (val instanceof String)
+         {
+            if (SCHEDULE_FIXED_DELAY.equals(val) || SCHEDULE_FIXED_RATE.equals(val))
             {
-               if (SCHEDULE_FIXED_DELAY.equals(val) || SCHEDULE_FIXED_RATE.equals(val))
-               {
-                  scheduleMode = (String) val;
-               }
-               else
-               {
-                  log.warn("Unrecognized value for " + CALLBACK_SCHEDULE_MODE + ": " + val);
-                  log.warn("Using " + scheduleMode);
-               }
+               scheduleMode = (String) val;
             }
             else
             {
-               log.warn("Value for " + CALLBACK_SCHEDULE_MODE + " must be of type " + String.class.getName() +
-                     " and is " + val.getClass().getName());
+               log.warn("Unrecognized value for " + CALLBACK_SCHEDULE_MODE + ": " + val);
+               log.warn("Using " + scheduleMode);
             }
          }
-         val = metadata.get(MAX_ERROR_COUNT);
-         if (val != null)
+         else
          {
-            if (val instanceof String)
+            log.warn("Value for " + CALLBACK_SCHEDULE_MODE + " must be of type " + String.class.getName() +
+                  " and is " + val.getClass().getName());
+         }
+      }
+      val = config.get(MAX_ERROR_COUNT);
+      if (val != null)
+      {
+         if (val instanceof String)
+         {
+            try
             {
-               try
-               {
-                  maxErrorCount = Integer.parseInt((String) val);
-               }
-               catch (NumberFormatException e)
-               {
-                  log.warn("Error converting " + MAX_ERROR_COUNT + " to type int.  " + e.getMessage());
-               }
+               maxErrorCount = Integer.parseInt((String) val);
             }
-            else
+            catch (NumberFormatException e)
             {
-               log.warn("Value for " + MAX_ERROR_COUNT + " configuration must be of type " + String.class.getName() +
-                        " and is " + val.getClass().getName());
+               log.warn("Error converting " + MAX_ERROR_COUNT + " to type int.  " + e.getMessage());
             }
          }
-         if (metadata.get(REPORT_STATISTICS) != null)
+         else
          {
-            reportStatistics = true;
+            log.warn("Value for " + MAX_ERROR_COUNT + " configuration must be of type " + String.class.getName() +
+                  " and is " + val.getClass().getName());
          }
       }
+      if (config.get(REPORT_STATISTICS) != null)
+      {
+         reportStatistics = true;
+      }
    }
 
 




More information about the jboss-remoting-commits mailing list