Pluggable MBeanServerForwarder
From JPPF 6.2 Documentation
Main Page > Extending and Customizing JPPF > Pluggable MBeanServerForwarder |
JPPF provides the ability to set an MBeanServerForwarder on all JMX remote servers created by the drivers and nodes. This can be used, for example, to implement an authorization mechanism that will grant or deny access to operations on the MBeans.
A forwarder implements the MBeanServerForwarder interface and is declared in a driver's or node's configuration file as follows:
jppf.management.server.forwarder = my.forwarder.Implementation param1 ... paramN
The value of the property is a set of space-separated strings, where the first string is the fully qualified class name of an implementation of MBeanServerForwarder, and the remaining strings are optional parameters passed on to the forwarder at construction time.
For the parameters to be passed on, the forwarder must also implement either of:
- a constructor that takes a String[] argument
- a setParameters(String[]) method
If both are implemented, then only the constructor will be used. If none is implemented, then no parameter will be passed, even if they are declared in the configuration. Additionally, a no-arg constructor is then expected.
In practice, it may be more convenient to extend the class MBeanServerForwarderAdapter, which implements all the methods of the MBeanServerForwarder interface and merely delegates to the underlying MBeanServer if it has been set. It also provides a getter and setter for the parameters, so you don't have to implement a setParameters(String[]) method either:
public class MBeanServerForwarderAdapter implements MBeanServerForwarder { // Set the parameters defined in the configuration, if any public void setParameters(final String[] parameters) // Get the parameters defined in the configuration, if any public String[] getParameters() // ... methods from the MBeanServerForwarder interface ... }
Note: each JMX server created in a driver or node has a distinct MBeanServerForwarder instance.
To get access to a configured MBeanServerForwarder, you first need to access the JMXServer that encloses it:
- in a driver, use JPPFDriver.getInstance().getJMXServer(boolean secure)
- in a node, obtain a reference to the Node, then use Node.getJmxServer()
Main Page > Extending and Customizing JPPF > Pluggable MBeanServerForwarder |