commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1510294 - in /commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges: DefaultGaugeManager.java GaugeFactory.java
Date Sun, 04 Aug 2013 18:20:35 GMT
Author: rmannibucau
Date: Sun Aug  4 18:20:34 2013
New Revision: 1510294

URL: http://svn.apache.org/r1510294
Log:
adding GaugeFactory

Added:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeFactory.java
Modified:
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java

Modified: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java?rev=1510294&r1=1510293&r2=1510294&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
(original)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/DefaultGaugeManager.java
Sun Aug  4 18:20:34 2013
@@ -19,6 +19,9 @@ package org.apache.commons.monitoring.ga
 import org.apache.commons.monitoring.Role;
 import org.apache.commons.monitoring.store.DataStore;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
 import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.Timer;
@@ -58,9 +61,17 @@ public final class DefaultGaugeManager i
         }
     }
 
-    protected ServiceLoader<Gauge> findGauges() {
+    protected Collection<Gauge> findGauges() {
         // core (where gauge is) is often in an upper classloader so don't use Gauge classloader
-        return ServiceLoader.load(Gauge.class, Thread.currentThread().getContextClassLoader());
+        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        final Collection<Gauge> gauges = new LinkedList<Gauge>();
+        for (final Gauge g : ServiceLoader.load(Gauge.class, classLoader)) {
+            gauges.add(g);
+        }
+        for (final GaugeFactory gf : ServiceLoader.load(GaugeFactory.class, classLoader))
{
+            gauges.addAll(Arrays.asList(gf.gauges()));
+        }
+        return gauges;
     }
 
     @Override

Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeFactory.java?rev=1510294&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeFactory.java
(added)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/gauges/GaugeFactory.java
Sun Aug  4 18:20:34 2013
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.gauges;
+
+public interface GaugeFactory {
+    Gauge[] gauges();
+}



Mime
View raw message