[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting ...

Ron Sigal ron_sigal at yahoo.com
Thu Mar 15 03:57:17 EDT 2007


  User: rsigal  
  Date: 07/03/15 03:57:17

  Modified:    src/main/org/jboss/remoting  Tag: remoting_2_x Client.java
  Log:
  JBREM-727:  callbackConnectors map contains sets of connectors, keyed on callback handler.  Also, added getCallbackConnectors().
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.53.2.28 +38 -8     JBossRemoting/src/main/org/jboss/remoting/Client.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Client.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/Client.java,v
  retrieving revision 1.53.2.27
  retrieving revision 1.53.2.28
  diff -u -b -r1.53.2.27 -r1.53.2.28
  --- Client.java	26 Feb 2007 11:46:27 -0000	1.53.2.27
  +++ Client.java	15 Mar 2007 07:57:17 -0000	1.53.2.28
  @@ -52,9 +52,11 @@
   import java.net.InetAddress;
   import java.util.ArrayList;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Set;
   
   /**
    * Client is a convience class for invoking remote methods for a given subsystem. It is intended to
  @@ -64,7 +66,7 @@
    * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
    *
  - * @version $Revision: 1.53.2.27 $
  + * @version $Revision: 1.53.2.28 $
    */
   public class Client implements Externalizable
   {
  @@ -579,6 +581,14 @@
      }
   
      /**
  +    * Returns the callback Connectors with which callbackHandler is registered.
  +    */
  +   public Set getCallbackConnectors(InvokerCallbackHandler callbackHandler)
  +   {
  +      return (Set) callbackConnectors.get(callbackHandler);
  +   }
  +
  +   /**
       * Gets the timeout used for network i/o in disconnect() and removeListener().
       */
      public int getDisconnectTimeout()
  @@ -868,7 +878,18 @@
                  }
                  log.debug("starting callback Connector: " + callbackLocator);
                  Connector callbackServerConnector = new Connector(callbackLocator, configuration);
  -               callbackConnectors.put(callbackhandler, callbackServerConnector);
  +               
  +               synchronized (callbackConnectors)
  +               {
  +                  Set connectors = (Set) callbackConnectors.get(callbackhandler);
  +                  if (connectors == null)
  +                  {
  +                     connectors = new HashSet();
  +                  }
  +                  connectors.add(callbackServerConnector);
  +                  callbackConnectors.put(callbackhandler, connectors);
  +               }
  +               
                  callbackServerConnector.start();
                  // have to use the locator from the server as can be modified internally
                  callbackLocator = callbackServerConnector.getServerInvoker().getLocator();
  @@ -1034,15 +1055,24 @@
                  }
               }
   
  -            // clean up callback server connector if one exists
  -            Connector callbackConnector = (Connector) callbackConnectors.remove(callbackHandler);
  +            // clean up callback server connectors if any exist
  +            Set connectors = null;
  +            synchronized (callbackConnectors)
  +            {
  +               connectors = (Set) callbackConnectors.remove(callbackHandler);
  +            }
   
  -            if (callbackConnector != null)
  +            if (connectors != null)
  +            {
  +               Iterator it = connectors.iterator();
  +               while (it.hasNext())
               {
  +                  Connector callbackConnector = (Connector) it.next();
                  callbackConnector.stop();
                  callbackConnector.destroy();
               }
            }
  +         }
            else
            {
               throw new NullPointerException("Can not remove null InvokerCallbackHandler listener.");
  
  
  



More information about the jboss-cvs-commits mailing list