« July 2008 »
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
26
27
28
29
30
31
  
       
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 1253

Powered by Roller Weblogger.
« Previous day (Jul 16, 2008) | Main | Next day (Jul 18, 2008) »
20080718 Friday July 18, 2008

BTrace and JMX

You can dyanamically attach BTrace to a Java process to inject trace code into it. BTrace client classescollect the trace output via a socket -- these client classes are used by BTrace command line client as well as VisualVM plugin for BTrace. How about attaching a JMX client to collect BTrace's trace data? Yes, it is possible to access a BTrace class's static fields as attributes of a MBean with this RFE.

There are two MBean samples in the BTrace repository. I attached both BTrace samples to a "Java2D demo" process. And then I attached VisualVM to view the Mbean registered by these BTrace samples:

  1. ThreadCounterBean.java - this sample instruments java.lang.Thread.start() method to update a counter field. This counter field is accessible by JMX clients.



  2. HistogramBean.java - this sample collects histogram of java.awt.Component objects created by an application and exposes the histogram (map) as MBean attribute.




( Jul 18 2008, 07:56:56 PM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

Copyright (C) 2005, A. Sundararajan's Weblog