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/20 05:27:13 UTC

cvs commit: jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/excalibur/instrument/manager InstrumentProxy.java

leif        2002/08/19 20:27:12

  Modified:    instrument-manager/src/java/org/apache/excalibur/instrument/manager
                        InstrumentProxy.java
  Log:
  Make the ValueInstruments inform newly registered listeners of their last know
  value when they register.  This makes it possible to see the current size of pools
  etc.  Before they would not be known until the next time setValue was called.
  
  Revision  Changes    Path
  1.2       +13 -1     jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/excalibur/instrument/manager/InstrumentProxy.java
  
  Index: InstrumentProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/excalibur/instrument/manager/InstrumentProxy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InstrumentProxy.java	14 Aug 2002 14:58:21 -0000	1.1
  +++ InstrumentProxy.java	20 Aug 2002 03:27:12 -0000	1.2
  @@ -77,6 +77,9 @@
       /** Child logger to use for logging of new values. */
       private Logger m_valueLogger;
       
  +    /** The most recent value set if this is a value instrument. */
  +    private int m_lastValue;
  +    
       /*---------------------------------------------------------------
        * Constructors
        *-------------------------------------------------------------*/
  @@ -248,6 +251,11 @@
                   "The proxy is not configured to handle ValueInstruments." );
           }
           
  +        // Store the most recent value so that new listeners can be informed
  +        //  of the current value when they register.  ints are single memory
  +        //  locations, so synchronization is not needed here.
  +        m_lastValue = value;
  +        
           // Get a local reference to the listeners, so that synchronization can be avoided.
           InstrumentListener[] listeners = m_listeners;
           if ( listeners != null )
  @@ -473,6 +481,10 @@
           }
           
           addInstrumentListener( listener );
  +        
  +        // Inform the new listener of the current value
  +        long time = System.currentTimeMillis();
  +        listener.setValue( getName(), m_lastValue, time );
       }
       
       /**
  
  
  

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