You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2015/04/07 22:47:19 UTC

[4/6] cxf git commit: Setup JMX for the throttling server so you can "watch" what is happening with JConsole

Setup JMX for the throttling server so you can "watch" what is happening with JConsole


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

Branch: refs/heads/master
Commit: 72ba5f34d674012e2f8ca8ef5add0b022235ee06
Parents: b248d09
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Apr 7 15:03:53 2015 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Apr 7 16:30:26 2015 -0400

----------------------------------------------------------------------
 .../src/main/java/demo/throttling/server/Customer.java      | 2 +-
 .../src/main/java/demo/throttling/server/Server.java        | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/72ba5f34/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Customer.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Customer.java b/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Customer.java
index 012463f..8436ded 100644
--- a/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Customer.java
+++ b/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Customer.java
@@ -38,7 +38,7 @@ public abstract class Customer {
     
     MetricsContext getMetricsContext(MetricRegistry registry) {
         if (metrics == null) {
-            metrics = new CodahaleMetricsContext("Customer-" + name, registry);
+            metrics = new CodahaleMetricsContext("demo.server:customer=" + name +",type=Customer,", registry);
         }
         return metrics;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/72ba5f34/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Server.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Server.java b/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Server.java
index 05b726c..aa722cf 100644
--- a/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Server.java
+++ b/distribution/src/main/release/samples/throttling/src/main/java/demo/throttling/server/Server.java
@@ -29,9 +29,10 @@ import javax.xml.ws.Endpoint;
 import com.codahale.metrics.MetricRegistry;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.CXFBusFactory;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.metrics.MetricsFeature;
+import org.apache.cxf.metrics.codahale.CodahaleMetricsProvider;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.throttling.ThrottleResponse;
 import org.apache.cxf.throttling.ThrottlingFeature;
@@ -49,8 +50,12 @@ public class Server {
         customers.put("Malcolm", new Customer.CheapCustomer("Malcolm"));
         customers.put("Jonas", new Customer.TrialCustomer("Jonas"));
         
-        Bus b = BusFactory.getDefaultBus();
+        Map<String, Object> properties = new HashMap<>();
+        properties.put("bus.jmx.usePlatformMBeanServer", Boolean.TRUE);
+        properties.put("bus.jmx.enabled", Boolean.TRUE);
+        Bus b = new CXFBusFactory().createBus(null, properties);
         MetricRegistry registry = new MetricRegistry();
+        CodahaleMetricsProvider.setupJMXReporter(b, registry);
         b.setExtension(registry, MetricRegistry.class);        
         
         ThrottlingManager manager = new ThrottlingManager() {