David,

Here's an example application that has a CounterServlet that counts hits
for example... Here are the classes that I used

- CounterServlet - just counts number of hits, calls
MyCounter.incrementAndGet() static method
- MyCounter - class that implements the counter (static calls to reset
counter, get current count, etc...)

- CounterMBean - interface for the MBean I am registering ... all methods
getXxxxxx() will get translated into attribute "xxxxx", all methods
setXxxxxx() will translate into writable attribute "xxxxxx"
- Counter - implements CounterMBean interface (naming is important here
Counter class and CounterMBean interface ... i.e. Xxxx class and XxxxMBean
interface)

- RegisterMBeansListener - @WebListener that implements
ServletContextListener and registers/unregisters the mbean upon
deployment/undeployment

That's it....

I will attach the WAR file, so you can just deploy it and call the MBean
from jconsole/jvisualvm. I registered:

JmxExample:type=Counter  ... operations are resetCounter() and
resetCounter(int), attributes are currentTimeMilis, currentTime,
currentCount

If the WAR didn't make it to the mailing list, contact me directly and I
will attach it.

Have fun with JMX :))
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to