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

Ron Sigal ron_sigal at yahoo.com
Sat Jun 16 02:09:37 EDT 2007


  User: rsigal  
  Date: 07/06/16 02:09:37

  Modified:    src/main/org/jboss/remoting  Tag: remoting_2_x Client.java
  Log:
  JBREM-641, JBREM-755: (1) If callbackHandler cannot be found, getCallbacks() can either log an error or throw an exception. (2) new version of addConnectionListener() with metadata added.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.53.2.32 +33 -5     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.31
  retrieving revision 1.53.2.32
  diff -u -b -r1.53.2.31 -r1.53.2.32
  --- Client.java	5 May 2007 07:37:40 -0000	1.53.2.31
  +++ Client.java	16 Jun 2007 06:09:37 -0000	1.53.2.32
  @@ -68,7 +68,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.31 $
  + * @version $Revision: 1.53.2.32 $
    */
   public class Client implements Externalizable
   {
  @@ -151,6 +151,8 @@
       */
      public static final int DEFAULT_DISCONNECT_TIMEOUT = -1;
   
  +   public static final String THROW_CALLBACK_EXCEPTION = "throwCallbackException";
  +
      private static final Logger log = Logger.getLogger(Client.class);
   
      private static final long serialVersionUID = 5679279425009837934L;
  @@ -348,6 +350,20 @@
       */
      public void addConnectionListener(ConnectionListener listener, int pingPeriod)
      {
  +      HashMap metadata = new HashMap();
  +      metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, Integer.toString(pingPeriod));
  +      addConnectionListener(listener, metadata);
  +   }
  +   
  +   /**
  +    * Adds a connection listener that will be notified if/when the connection to the server fails
  +    * while the client is idle (no calls being made). The current behavior is to ping the server
  +    * periodically.  Various parameters may be specified in metadata.
  +    * 
  +    * @see org.jboss.remoting.ConnectionValidator
  +    */
  +   public void addConnectionListener(ConnectionListener listener, Map metadata)
  +   {
         if (invoker == null)
         {
            throw new RuntimeException("Can not add connection listener to remoting client " +
  @@ -364,7 +380,7 @@
   
         if (connectionValidator == null)
         {
  -         connectionValidator = new ConnectionValidator(this, pingPeriod);
  +         connectionValidator = new ConnectionValidator(this, metadata);
         }
         connectionValidator.addConnectionListener(listener);
      }
  @@ -1145,12 +1161,24 @@
            }
            else
            {
  -            log.error("Could not find listener id for InvokerCallbackHandler (" + callbackHandler +
  -                      "), please verify handler has been registered as listener.");
  +            String errorMessage = "Could not find listener id for InvokerCallbackHandler (" +
  +                                  callbackHandler +
  +                                  "), please verify handler has been registered as listener.";
  +
  +            String errorMode = (String) metadata.get(THROW_CALLBACK_EXCEPTION);
  +            boolean throwError = Boolean.valueOf(errorMode).booleanValue();
   
  +            if (throwError)
  +            {
  +               throw new IOException(errorMessage);
  +            }
  +            else
  +            {
  +               log.error(errorMessage);
               return null;
            }
         }
  +      }
         else
         {
            throw new NullPointerException("Can not remove null InvokerCallbackHandler listener.");
  
  
  



More information about the jboss-cvs-commits mailing list