Java Dynamic Management Kit 5.1 Tutorial

7.4 Running the MBean Server Interceptor Example

The MBean server interceptor example in the examples directory shows you two of the main functions of MBean server interceptors, forwarding requests to a specific MBean server interceptor, and creating virtual MBeans.

The examplesDir/current/MBeanServerInterceptor directory contains the following source files:

To Run the MBean Server Interceptor Example
  1. Compile all files in the examplesDir/current/MBeanServerInterceptor directory with the javac command.

    For example, on the Solaris platform, type:

    $ cd examplesDir/current/MBeanServerInterceptor/
    $ javac -classpath classpath *.java
  2. Run the example using the classes you have just built, by typing the following command in a terminal window:

    $ java \ \

    Here, you can see that the system property is set to com.sun.jdmk.JdmkMBeanServerBuilder before the Agent is started, as explained in 7.3 Changing the Default Interceptor.

  3. Interact with the agent through the standard input and output in the window where it was started.

  4. Load the agent's URL in your web browser:


    You only see the MBeans registered in the DefaultMBeanInterceptor, namely the connector and adaptor MBeans, and the MBeanServerDelegate.

  5. Press Enter to insert the FileMBeanServerInterceptor and view the files from the local directory as virtual MBeans.

  6. Reload the agent's URL in your web browser to view the new MBeans:

  7. Press Enter to stop the agent.