You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/08/23 11:41:40 UTC

cvs commit: jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl DefaultConnectionListener.java

leif        2002/08/23 02:41:40

  Modified:    altrmi/src/java/org/apache/excalibur/altrmi/client/impl
                        DefaultConnectionListener.java
  Log:
  Make it possible to set the number of retry attempts.
  
  Revision  Changes    Path
  1.4       +35 -3     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DefaultConnectionListener.java
  
  Index: DefaultConnectionListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DefaultConnectionListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultConnectionListener.java	24 Apr 2002 12:42:56 -0000	1.3
  +++ DefaultConnectionListener.java	23 Aug 2002 09:41:40 -0000	1.4
  @@ -20,6 +20,29 @@
    */
   public class DefaultConnectionListener implements AltrmiConnectionListener
   {
  +    private int m_maxReconnectAttempts;
  +    
  +    /**
  +     * Creates a new DefaultConnectionListener.
  +     */
  +    public DefaultConnectionListener()
  +    {
  +        this( 3 );  // Default to 3 reconnect attempts.
  +    }
  +    
  +    /**
  +     * Creates a new DefaultConnectionListener.
  +     *
  +     * @param maxReconnectAttempts Specifies the maximum number of times that
  +     *                             the client will attempt to reconnect to
  +     *                             the server if the connection is lost.  A
  +     *                             value of 0 implies that no reconnect
  +     *                             attempts should be made.
  +     */
  +    public DefaultConnectionListener( int maxReconnectAttempts )
  +    {
  +        m_maxReconnectAttempts = maxReconnectAttempts;
  +    }
   
       /**
        * Method methodCalled
  @@ -96,9 +119,18 @@
       {
   
           // Lets say that ten retries is too many.
  -        if( attempt == 3 )
  +        if( attempt >= m_maxReconnectAttempts )
           {
  -            throw new AltrmiInvocationException( "Too many retries on abended service" );
  +            String msg;
  +            if ( m_maxReconnectAttempts <= 0 )
  +            {
  +                msg = "Reconnect to abended service disabled.";
  +            }
  +            else
  +            {
  +                msg = "Too many retries on abended service";
  +            }
  +            throw new AltrmiInvocationException( msg );
           }
   
           System.out.println( "AltRMI service abnormally ended, Trying to reconnect (attempt "
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>