JMX and dynamic proxies. This could be interesting. One of the things I’m not fully up to speed on with JMX is how you actually interact with the MBeans. Having managed, pluggable components is great, but my POJOs (plain old java objects) still need to access the things, and having the entire API exposed in the management interface sucks. I’m having the seed of an idea, but can’t quite verbalise it yet (not at my best at half-midnight).
Let’s see. Wrap the component in an MBean, and expose its management properties. Fine. Register the MBean in the server. Expose a management operation that returns the implementation of your component. (This is where it gets sketchy). Place the implementation inside a dynamic proxy, and have the application container pass the proxy to any objects that need the component (inversion of control). Do something with notifications so that the implementation object or app. server itself can be called back whenever a managed property is altered. Retrieve the new component instance from the JMX server and place that inside the dynamic proxy, replacing the old one. Any clients that have a reference to the proxy instance should now be calling the new component. Hot swapping. Hot damn.
Am I making any sense?