commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r731993 - in /commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring: ./ metrics/ monitors/
Date Tue, 06 Jan 2009 16:35:52 GMT
Author: nicolas
Date: Tue Jan  6 08:35:51 2009
New Revision: 731993

URL: http://svn.apache.org/viewvc?rev=731993&view=rev
Log:
remove generics on Metric / Role as they don't make things simplier.

Modified:
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Counter.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Gauge.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Metric.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Role.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/AbstractMetric.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpCounter.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpGauge.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObservableMetric.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverCounter.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverGauge.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverMetric.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockCounter.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockGauge.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedCounter.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedGauge.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeCounter.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeGauge.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/CreateMetricsOnDemandMonitor.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/NullMonitor.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObservableMonitor.java
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObserverMonitor.java

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Counter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Counter.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Counter.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Counter.java
Tue Jan  6 08:35:51 2009
@@ -24,7 +24,7 @@
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 public interface Counter
-    extends Metric<Counter>
+    extends Metric
 {
 
     /**
@@ -35,7 +35,7 @@
     void add( double delta, Unit unit );
 
     public interface Observable
-        extends Metric.Observable<Counter>, Counter
+        extends Metric.Observable, Counter
     {
 
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Gauge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Gauge.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Gauge.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Gauge.java
Tue Jan  6 08:35:51 2009
@@ -23,7 +23,7 @@
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 public interface Gauge
-    extends Metric<Gauge>
+    extends Metric
 {
     /**
      * @return the current Gauge value
@@ -37,7 +37,7 @@
     void decrement( Unit unit );
 
     public interface Observable
-        extends Metric.Observable<Gauge>, Gauge
+        extends Metric.Observable, Gauge
     {
 
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Metric.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Metric.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Metric.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Metric.java
Tue Jan  6 08:35:51 2009
@@ -26,7 +26,7 @@
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
-public interface Metric<M extends Metric<?>>
+public interface Metric
 {
     public enum Type
     {
@@ -56,7 +56,7 @@
     /**
      * @return the role for this Metric in the monitor
      */
-    Role<M> getRole();
+    Role getRole();
 
     /**
      * @return the data unit
@@ -66,7 +66,7 @@
     /**
      * Listener for Metric events
      */
-    public static interface Listener<M extends Metric<?>>
+    public static interface Listener
         extends EventListener
     {
         /**
@@ -78,23 +78,24 @@
          * @param metric
          * @param value
          */
-        void onValueChanged( Observable<M> metric, double value );
+        void onValueChanged( Observable metric, double value );
     }
 
     /**
      * A metric that support the Observer pattern.
      */
-    public interface Observable<M extends Metric<?>> extends Metric<M>
+    public interface Observable
+        extends Metric
     {
         /**
          * @param listener listener to get registered
          */
-        void addListener( Listener<M> listener );
+        void addListener( Listener listener );
 
         /**
          * @param listener listener to get removed
          */
-        void removeListener( Listener<M> listener );
+        void removeListener( Listener listener );
     }
 
     // --- Statistical indicators --------------------------------------------

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
Tue Jan  6 08:35:51 2009
@@ -50,16 +50,16 @@
     // --- Predefined roles -------------------------------------------------------------------
 
     /** Predefined role key for code performances */
-    Role<Counter> PERFORMANCES = new Role<Counter>( "performances", Unit.MILLIS,
Counter.class );
+    Role PERFORMANCES = new Role( "performances", Unit.MILLIS, Metric.Type.COUNTER );
 
     /** Predefined role key for cpu time */
-    Role<Counter> CPU = new Role<Counter>( "cpu", Unit.MILLIS, Counter.class
);
+    Role CPU = new Role( "cpu", Unit.MILLIS, Metric.Type.COUNTER );
 
     /** Predefined role for multi-thread concurrency */
-    Role<Gauge> CONCURRENCY = new Role<Gauge>( "concurrency", Unit.UNARY, Gauge.class
);
+    Role CONCURRENCY = new Role( "concurrency", Unit.UNARY, Metric.Type.GAUGE );
 
     /** Predefined Role for the invocation failure counter */
-    Role<Counter> FAILURES = new Role<Counter>( "failures", Unit.UNARY, Counter.class
);
+    Role FAILURES = new Role( "failures", Unit.UNARY, Metric.Type.COUNTER );
 
 
     /**
@@ -82,7 +82,7 @@
      * @param role the Counter role in the monitor
      * @return the Counter
      */
-    Counter getCounter( Role<Counter> role );
+    Counter getCounter( Role role );
 
     /**
      * Retrieve a Gauge in the monitor
@@ -98,7 +98,7 @@
      * @param role the gauge role in the monitor
      * @return the Gauge
      */
-    Gauge getGauge( Role<Gauge> role );
+    Gauge getGauge( Role role );
 
     /**
      * Retrieve a Metric.
@@ -106,7 +106,7 @@
      * @param role a unique identifier for a Metric in the monitor
      * @return the Metric
      */
-    Metric<?> getMetric( String role );
+    Metric getMetric( String role );
 
     /**
      * Retrieve a Metric in the monitor
@@ -114,18 +114,17 @@
      * @param role the Metric role in the monitor
      * @return the Metric
      */
-    <M extends Metric<?>> M getMetric( Role<M> role );
+    Metric getMetric( Role role );
 
     /**
      * @return an unmodifiable collection of registered Metrics roles
      */
-    @SuppressWarnings("unchecked")
     Collection<Role> getRoles();
 
     /**
      * @return an unmodifiable collection of registered Metrics
      */
-    Collection<Metric<?>> getMetrics();
+    Collection<Metric> getMetrics();
 
     /**
      * Reset all Metrics (don't remove them)
@@ -271,7 +270,7 @@
     public interface Listener
     extends EventListener
     {
-        void onMetricRegistered( Monitor.Observable monitor, Metric<?> metric );
+        void onMetricRegistered( Monitor.Observable monitor, Metric metric );
     }
 
     /**

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Role.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Role.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Role.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Role.java
Tue Jan  6 08:35:51 2009
@@ -30,20 +30,21 @@
  * @param <M> The metric this role relates to
  */
 @SuppressWarnings("unchecked")
-public class Role<M extends Metric>
+public class Role
     implements Comparable<Role>
 {
     private String name;
 
     private Unit unit;
 
-    private Class<M> type;
+    private Metric.Type type;
 
     private static final Map<String, Role> ROLES = new ConcurrentHashMap<String,
Role>();
 
     public static Role getRole( String name )
     {
         return ROLES.get( name );
+
     }
 
     public static Collection<Role> getRoles()
@@ -51,7 +52,7 @@
         return Collections.unmodifiableCollection( ROLES.values() );
     }
 
-    public Role( String name, Unit unit, Class<M> type )
+    public Role( String name, Unit unit, Metric.Type type )
     {
         super();
         if ( name == null )
@@ -66,10 +67,6 @@
         {
             throw new IllegalArgumentException( "A type is required" );
         }
-        if ( !Metric.class.isAssignableFrom( type ) )
-        {
-            throw new IllegalArgumentException( "The type must extend Metric" );
-        }
         this.name = name;
         this.unit = unit;
         this.type = type;
@@ -149,7 +146,7 @@
         return name;
     }
 
-    public Class<M> getType()
+    public Metric.Type getType()
     {
         return type;
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/AbstractMetric.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/AbstractMetric.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/AbstractMetric.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/AbstractMetric.java
Tue Jan  6 08:35:51 2009
@@ -31,20 +31,24 @@
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
-public abstract class AbstractMetric<M extends Metric<?>>
-    implements Metric<M>
+public abstract class AbstractMetric
+    implements Metric
 {
     private Monitor monitor;
 
     private SummaryStatistics statistics;
 
-    private Role<M> role;
+    private Role role;
 
     private Unit unit;
 
-    public AbstractMetric( Role<M> role )
+    public AbstractMetric( Role role )
     {
         super();
+        if ( role.getType() != this.getType() )
+        {
+            throw new IllegalArgumentException( "Invalid Role type for " + getClass().getName()
);
+        }
         this.role = role;
         this.unit = role.getUnit();
         this.statistics = new SummaryStatistics();
@@ -70,7 +74,7 @@
         return monitor;
     }
 
-    public Role<M> getRole()
+    public Role getRole()
     {
         return role;
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpCounter.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpCounter.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpCounter.java
Tue Jan  6 08:35:51 2009
@@ -6,10 +6,10 @@
 import org.apache.commons.monitoring.Unit;
 
 public class NoOpCounter
-    extends AbstractMetric<Counter>
+    extends AbstractMetric
     implements Counter
 {
-    public NoOpCounter( Role<Counter> role )
+    public NoOpCounter( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpGauge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpGauge.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpGauge.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/NoOpGauge.java
Tue Jan  6 08:35:51 2009
@@ -6,10 +6,10 @@
 import org.apache.commons.monitoring.Unit;
 
 public class NoOpGauge
-    extends AbstractMetric<Gauge>
+    extends AbstractMetric
     implements Gauge
 {
-    public NoOpGauge( Role<Gauge> role )
+    public NoOpGauge( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObservableMetric.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObservableMetric.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObservableMetric.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObservableMetric.java
Tue Jan  6 08:35:51 2009
@@ -14,28 +14,28 @@
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 @SuppressWarnings("unchecked")
-public abstract class ObservableMetric<M extends Metric>
-    extends AbstractMetric<M>
-    implements Metric.Observable<M>
+public abstract class ObservableMetric
+    extends AbstractMetric
+    implements Metric.Observable
 {
 
-    private List<Listener<M>> listeners;
+    private List<Listener> listeners;
 
     /**
      * Constructor
      */
-    public ObservableMetric( Role<M> role )
+    public ObservableMetric( Role role )
     {
         super( role );
-        this.listeners = new CopyOnWriteArrayList<Listener<M>>();
+        this.listeners = new CopyOnWriteArrayList<Listener>();
     }
 
-    public void addListener( Listener<M> listener )
+    public void addListener( Listener listener )
     {
         listeners.add( listener );
     }
 
-    public void removeListener( Listener<M> listener )
+    public void removeListener( Listener listener )
     {
         listeners.remove( listener );
     }
@@ -43,7 +43,7 @@
     protected void fireValueChanged( double d )
     {
         // Notify listeners
-        for ( Listener<M> listener : listeners )
+        for ( Listener listener : listeners )
         {
             listener.onValueChanged( this, d );
         }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverCounter.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverCounter.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverCounter.java
Tue Jan  6 08:35:51 2009
@@ -11,7 +11,7 @@
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 public class ObserverCounter
-extends ObserverMetric<Counter>
+    extends ObserverMetric
 implements Counter
 {
     private Counter.Observable observable;
@@ -33,12 +33,12 @@
     }
 
     @Override
-    protected Metric.Observable<Counter> getObservable()
+    protected Metric.Observable getObservable()
     {
         return observable;
     }
 
-    public void onValueChanged( Metric.Observable<Counter> metric, double value )
+    public void onValueChanged( Metric.Observable metric, double value )
     {
         delegate.threadSafeAdd( value );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverGauge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverGauge.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverGauge.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverGauge.java
Tue Jan  6 08:35:51 2009
@@ -11,7 +11,7 @@
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 public class ObserverGauge
-    extends ObserverMetric<Gauge>
+    extends ObserverMetric
     implements Gauge
 {
     private Gauge.Observable observable;
@@ -34,12 +34,12 @@
     }
 
     @Override
-    protected Metric.Observable<Gauge> getObservable()
+    protected Metric.Observable getObservable()
     {
         return observable;
     }
 
-    public void onValueChanged( Metric.Observable<Gauge> metric, double value )
+    public void onValueChanged( Metric.Observable metric, double value )
     {
         delegate.threadSafeSet( value );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverMetric.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverMetric.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverMetric.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ObserverMetric.java
Tue Jan  6 08:35:51 2009
@@ -4,11 +4,11 @@
 import org.apache.commons.monitoring.Metric;
 import org.apache.commons.monitoring.Role;
 
-public abstract class ObserverMetric<M extends Metric<?>>
-    extends AbstractMetric<M>
-    implements Detachable, Metric.Listener<M>
+public abstract class ObserverMetric
+    extends AbstractMetric
+    implements Detachable, Metric.Listener
 {
-    protected abstract Metric.Observable<M> getObservable();
+    protected abstract Metric.Observable getObservable();
 
     private boolean detached;
 
@@ -16,7 +16,7 @@
 
     private long detachedAt;
 
-    public ObserverMetric( Role<M> role )
+    public ObserverMetric( Role role )
     {
         super( role );
         attachedAt = System.currentTimeMillis();

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockCounter.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockCounter.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockCounter.java
Tue Jan  6 08:35:51 2009
@@ -21,7 +21,6 @@
 
 import org.apache.commons.monitoring.Counter;
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.metrics.CounterBench;
 
 /**
  * Thread-safe implementation of <code>Counter</code>.
@@ -42,7 +41,7 @@
 
     ReentrantLock lock = new ReentrantLock();
 
-    public RentrantLockCounter( Role<Counter> role )
+    public RentrantLockCounter( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockGauge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockGauge.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockGauge.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/RentrantLockGauge.java
Tue Jan  6 08:35:51 2009
@@ -32,7 +32,7 @@
 {
     private ReentrantLock lock = new ReentrantLock();
 
-    public RentrantLockGauge( Role<Gauge> role )
+    public RentrantLockGauge( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedCounter.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedCounter.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedCounter.java
Tue Jan  6 08:35:51 2009
@@ -39,7 +39,7 @@
 
     ReentrantLock lock = new ReentrantLock();
 
-    public SynchronizedCounter( Role<Counter> role )
+    public SynchronizedCounter( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedGauge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedGauge.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedGauge.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/SynchronizedGauge.java
Tue Jan  6 08:35:51 2009
@@ -33,7 +33,7 @@
     extends ThreadSafeGauge
     implements Gauge
 {
-    public SynchronizedGauge( Role<Gauge> role )
+    public SynchronizedGauge( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeCounter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeCounter.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeCounter.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeCounter.java
Tue Jan  6 08:35:51 2009
@@ -5,10 +5,10 @@
 import org.apache.commons.monitoring.Unit;
 
 public abstract class ThreadSafeCounter
-    extends ObservableMetric<Counter>
+    extends ObservableMetric
     implements Counter, Counter.Observable
 {
-    public ThreadSafeCounter( Role<Counter> role )
+    public ThreadSafeCounter( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeGauge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeGauge.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeGauge.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/metrics/ThreadSafeGauge.java
Tue Jan  6 08:35:51 2009
@@ -14,7 +14,7 @@
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
 public abstract class ThreadSafeGauge
-    extends ObservableMetric<Gauge>
+    extends ObservableMetric
     implements Gauge, Gauge.Observable
 {
     protected double value;
@@ -27,7 +27,7 @@
 
     protected Max max = new Max();
 
-    public ThreadSafeGauge( Role<Gauge> role )
+    public ThreadSafeGauge( Role role )
     {
         super( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/AbstractMonitor.java
Tue Jan  6 08:35:51 2009
@@ -37,7 +37,7 @@
 {
 
     @SuppressWarnings("unchecked")
-    private final ConcurrentMap<Role, Metric<?>> metrics;
+    private final ConcurrentMap<Role, Metric> metrics;
     private final Key key;
 
     public AbstractMonitor( Key key )
@@ -54,9 +54,9 @@
      * @return the ConcurrentMap implementation to use for storing metrics
      */
     @SuppressWarnings("unchecked")
-    protected ConcurrentHashMap<Role, Metric<?>> createConcurrentMap()
+    protected ConcurrentHashMap<Role, Metric> createConcurrentMap()
     {
-        return new ConcurrentHashMap<Role, Metric<?>>();
+        return new ConcurrentHashMap<Role, Metric>();
     }
 
     /**
@@ -70,15 +70,14 @@
     /**
      * {@inheritDoc}
      */
-    public final Metric<?> getMetric( String role )
+    public final Metric getMetric( String role )
     {
         return metrics.get( role );
     }
 
-    @SuppressWarnings("unchecked")
-    public <T extends Metric<?>> T getMetric( Role<T> role )
+    public final Metric getMetric( Role role )
     {
-        return (T) metrics.get( role );
+        return metrics.get( role );
     }
 
     @SuppressWarnings("unchecked")
@@ -87,7 +86,7 @@
         return Collections.unmodifiableCollection( metrics.keySet() );
     }
 
-    public Collection<Metric<?>> getMetrics()
+    public Collection<Metric> getMetrics()
     {
         return Collections.unmodifiableCollection( metrics.values() );
     }
@@ -99,11 +98,10 @@
      * @return a previously registered Metric if existed, or <code>null</code>
if the metric has been successfully
      * registered
      */
-    @SuppressWarnings("unchecked")
-    protected <M extends Metric<?>> M register( M metric )
+    protected Metric register( Metric metric )
     {
         metric.setMonitor( this );
-        return (M) metrics.putIfAbsent( metric.getRole(), metric );
+        return metrics.putIfAbsent( metric.getRole(), metric );
     }
 
     /**
@@ -111,7 +109,7 @@
      */
     public void reset()
     {
-        for ( Metric<?> metric : metrics.values() )
+        for ( Metric metric : metrics.values() )
         {
             metric.reset();
         }
@@ -120,21 +118,21 @@
     @SuppressWarnings("unchecked")
     public Counter getCounter( String role )
     {
-        return getCounter( (Role<Counter>) Role.getRole( role ) );
+        return getCounter( Role.getRole( role ) );
     }
 
     @SuppressWarnings("unchecked")
     public Gauge getGauge( String role )
     {
-        return getGauge( (Role<Gauge>) Role.getRole( role ) );
+        return getGauge( Role.getRole( role ) );
     }
 
-    public Counter getCounter( Role<Counter> role )
+    public Counter getCounter( Role role )
     {
         return (Counter) getMetric( role );
     }
 
-    public Gauge getGauge( Role<Gauge> role )
+    public Gauge getGauge( Role role )
     {
         return (Gauge) getMetric( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/CreateMetricsOnDemandMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/CreateMetricsOnDemandMonitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/CreateMetricsOnDemandMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/CreateMetricsOnDemandMonitor.java
Tue Jan  6 08:35:51 2009
@@ -37,27 +37,27 @@
         super( key );
     }
 
-    public Counter getCounter( Role<Counter> role )
+    public Counter getCounter( Role role )
     {
-        Counter counter = getMetric( role );
+        Counter counter = (Counter) getMetric( role );
         if ( counter != null )
         {
             return counter;
         }
         counter = newCounterInstance( role );
-        Counter previous = register( counter );
+        Counter previous = (Counter) register( counter );
         return previous != null ? previous : counter;
     }
 
-    public Gauge getGauge( Role<Gauge> role )
+    public Gauge getGauge( Role role )
     {
-        Gauge gauge = getMetric( role );
+        Gauge gauge = (Gauge) getMetric( role );
         if ( gauge != null )
         {
             return gauge;
         }
         gauge = newGaugeInstance( role );
-        Gauge previous = register( gauge );
+        Gauge previous = (Gauge) register( gauge );
         return previous != null ? previous : gauge;
     }
 
@@ -68,7 +68,7 @@
      * executed to create more than one instance for the same role, so DON'T
      * assume unicity here.
      */
-    protected abstract Counter newCounterInstance( Role<Counter> role );
+    protected abstract Counter newCounterInstance( Role role );
 
     /**
      * Create a new Gauge instance
@@ -77,5 +77,5 @@
      * executed to create more than one instance for the same role, so DON'T
      * assume unicity here.
      */
-    protected abstract Gauge newGaugeInstance( Role<Gauge> role );
+    protected abstract Gauge newGaugeInstance( Role role );
 }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/DefaultMonitor.java
Tue Jan  6 08:35:51 2009
@@ -39,13 +39,13 @@
     }
 
     @Override
-    protected Counter newCounterInstance( Role<Counter> role )
+    protected Counter newCounterInstance( Role role )
     {
         return new RentrantLockCounter( role );
     }
 
     @Override
-    protected Gauge newGaugeInstance( Role<Gauge> role )
+    protected Gauge newGaugeInstance( Role role )
     {
         return new RentrantLockGauge( role );
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/NullMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/NullMonitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/NullMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/NullMonitor.java
Tue Jan  6 08:35:51 2009
@@ -23,20 +23,20 @@
 public class NullMonitor
     implements Monitor
 {
-    private static Role NOOP = new Role( "NoOp", Unit.UNARY, Metric.class );
+    private static Role NOOP = new Role( "NoOp", Unit.UNARY, Metric.Type.COUNTER );
 
     private static NoOpCounter counter = new NoOpCounter( NOOP );
 
     private static NoOpGauge gauge = new NoOpGauge( NOOP );
 
-    private Collection<Metric<?>> metrics = Arrays.asList( new Metric<?>[]
{ counter, gauge } );
+    private Collection<Metric> metrics = Arrays.asList( new Metric[] { counter, gauge
} );
 
     public Counter getCounter( String role )
     {
         return counter;
     }
 
-    public Counter getCounter( Role<Counter> role )
+    public Counter getCounter( Role role )
     {
         return counter;
     }
@@ -46,7 +46,7 @@
         return gauge;
     }
 
-    public Gauge getGauge( Role<Gauge> role )
+    public Gauge getGauge( Role role )
     {
         return gauge;
     }
@@ -61,12 +61,12 @@
         return counter;
     }
 
-    public <M extends Metric<?>> M getMetric( Role<M> role )
+    public Metric getMetric( Role role )
     {
-        return (M) counter;
+        return counter;
     }
 
-    public Collection<Metric<?>> getMetrics()
+    public Collection<Metric> getMetrics()
     {
         return metrics;
     }

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObservableMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObservableMonitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObservableMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObservableMonitor.java
Tue Jan  6 08:35:51 2009
@@ -56,9 +56,9 @@
      * @return the registered metric, or a previously existing one for the role
      */
     @Override
-    protected <T extends Metric<?>> T register( T metric )
+    protected Metric register( Metric metric )
     {
-        T previous = (T) super.register( metric );
+        Metric previous = super.register( metric );
         if ( previous != null )
         {
             return previous;

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObserverMonitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObserverMonitor.java?rev=731993&r1=731992&r2=731993&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObserverMonitor.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/monitors/ObserverMonitor.java
Tue Jan  6 08:35:51 2009
@@ -30,7 +30,7 @@
         this.attachedAt = System.currentTimeMillis();
         this.detached = false;
         this.observable.addListener( this );
-        for ( Metric<?> metric : observable.getMetrics() )
+        for ( Metric metric : observable.getMetrics() )
         {
             onMetricRegistered( observable, metric );
         }
@@ -53,11 +53,11 @@
     public void detach()
     {
         detached = true;
-        for ( Metric<?> metric : observable.getMetrics() )
+        for ( Metric metric : observable.getMetrics() )
         {
-            if ( metric instanceof Metric.Observable<?> )
+            if ( metric instanceof Metric.Observable )
             {
-                Metric.Observable<?> observableMetric = (Metric.Observable<?>)
metric;
+                Metric.Observable observableMetric = (Metric.Observable) metric;
                 Metric.Listener observer = (Metric.Listener) getMetric( metric.getRole()
);
                 observableMetric.removeListener( observer );
             }



Mime
View raw message