cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: Little easier to setup as it can pull the registry from the extensions/bus
Date Thu, 19 Mar 2015 17:24:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c5da4140d -> 237ace40e


Little easier to setup as it can pull the registry from the extensions/bus


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/237ace40
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/237ace40
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/237ace40

Branch: refs/heads/master
Commit: 237ace40ea2c204f68848309b9483c322499b524
Parents: c5da414
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Mar 19 13:24:16 2015 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Mar 19 13:24:16 2015 -0400

----------------------------------------------------------------------
 .../apache/cxf/management/codahale/Metrics.java | 26 ++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/237ace40/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java b/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
index 666ba36..09d90a5 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/codahale/Metrics.java
@@ -62,15 +62,20 @@ public class Metrics {
     public Metrics(MetricRegistry reg) {
         registry = reg;
     }
-    
-    public void setBus(Bus b) {
+    public Metrics(Bus b) {
+        registry = b.getExtension(MetricRegistry.class);
         bus = b;
-        if (bus != null) {
-            registerInterceptorsToBus();
+        registerInterceptorsToBus();
+        if (registry == null) {
+            registry = new MetricRegistry();
+            setupJMXReporter(b, registry);
         }
-        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
+    }
+    
+    protected final void setupJMXReporter(Bus b, MetricRegistry reg) {
+        InstrumentationManager im = b.getExtension(InstrumentationManager.class);
         if (im != null) {
-            JmxReporter reporter = JmxReporter.forRegistry(registry).registerWith(im.getMBeanServer())
+            JmxReporter reporter = JmxReporter.forRegistry(reg).registerWith(im.getMBeanServer())
                 .inDomain("org.apache.cxf")
                 .createsObjectNamesWith(new ObjectNameFactory() {
                     public ObjectName createName(String type, String domain, String name)
{
@@ -85,12 +90,19 @@ public class Metrics {
             reporter.start();
         }
     }
+    public void setBus(Bus b) {
+        bus = b;
+        if (bus != null) {
+            registerInterceptorsToBus();
+            setupJMXReporter(bus, registry);
+        }
+    }
 
     public Bus getBus() {
         return bus;
     }
             
-    void registerInterceptorsToBus() {
+    private void registerInterceptorsToBus() {
         ResponseTimeMessageInInterceptor in = new ResponseTimeMessageInInterceptor();
         ResponseTimeMessageInOneWayInterceptor oneway = new ResponseTimeMessageInOneWayInterceptor();
         ResponseTimeMessageOutInterceptor out = new ResponseTimeMessageOutInterceptor();


Mime
View raw message