Here's a link to some code used by the nightly
testsuite to access the MBeanServer within JBoss.
It should be relatively easy to adapt to your needs.
Alternatively, for a better explanation, buy Juha's book. You can also download the example code for an
RMI, Soap and JMS connector.