Package net.sf.sensor.counter

This package provides support for counting simple properties of runtime components.

See:
          Description

Class Summary
Counter Implements a simple labeled counter that supports incrementing and decrementing operations.
CounterRuntime Main entry point for working with Counters.
 

Package net.sf.sensor.counter Description

This package provides support for counting simple properties of runtime components. Counters usually keep track of a countable piece of business information, like the number of orders processed, the number of active sessions, the number of logged in users, etc.

Counters should preferably be applied to code using the various AOP methods provided by the Sensor AOP module (Spring interceptors, AspectJ aspects, etc.) Or by using them in your own AOP code. Using manual (ie directly in the original source code) counting is pretty invasive and is not encouraged. But just in case, here is an example of (very simple) Counter usage:

  // ...
  // get a reference to the CounterRuntime class through dependency injection
  // or by using the static method in the StaticSensorRuntime support class.
  // ...

  public void validateOrder() {
    try {
      // process the order.
      ...
      
      // If the order is valid...
      counterRuntime.getCounter("Number of valid orders").increment();
    } catch (OrderProcessingException ope) {
      // If the order is invalid...
      counterRuntime.getCounter("Number of invalid orders").increment();
    }
  }
    



Copyright © 2005-2006 SourceForge. All Rights Reserved.