View Javadoc

1   /*
2    * $Id: AggregateCounter.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.util.counters.impl;
12  
13  import org.mule.util.counters.Counter;
14  import org.mule.util.counters.CounterFactory.Type;
15  
16  public abstract class AggregateCounter extends AbstractCounter
17  {
18  
19      private final Counter base;
20  
21      public AggregateCounter(String name, Type type, AbstractCounter base)
22      {
23          super(name, type);
24          this.base = base;
25          base.addAggregate(this);
26      }
27  
28      public double increment()
29      {
30          throw new UnsupportedOperationException();
31      }
32  
33      public double incrementBy(double value)
34      {
35          throw new UnsupportedOperationException();
36      }
37  
38      public double decrement()
39      {
40          throw new UnsupportedOperationException();
41      }
42  
43      public void setRawValue(double value)
44      {
45          throw new UnsupportedOperationException();
46      }
47  
48      public final synchronized void compute()
49      {
50          this.doCompute();
51          this.propagate();
52      }
53  
54      public Counter getBase()
55      {
56          return this.base;
57      }
58  
59      public abstract double nextValue();
60  
61      public abstract void doCompute();
62  
63  }