原文地址: http://blogs.oracle.com/WebLogicServer/2010/09/developing_custom_mbeans_to_ma_2.html Copyright © Oracle
By philippe Le Mouel on September 23, 2010 3:37 PM
Part III was intended to be the final blog entry in this serie of blogs, that demonstrate how to add management capability to our own application using JMX MBeans. However I received several requests regarding notification supports and how it could be added to the sample code we developed so far. This last entry will demonstrate just that. Below is a quick reminder of what we have done so far with associated links:
In Part I we saw:
- How to implement a custom MBean to manage configuration associated with an application.
- How to package the resulting code and configuration as part of the application’s ear file.
- How to register MBeans upon application startup, and unregistered them upon application stop (or undeployment).
- How to use generic JMX clients such as JConsole to browse and edit our application’s MBean.
In Part II we saw:
- How to add localized descriptions to our MBean, MBean attributes, MBean operations and MBean operation parameters.
- How to specify meaningful name to our MBean operation parameters.
- We also touched on future enhancements that will simplify how we can implement localized MBeans.
In Part III we saw:
- How to localize our MBean based on the calling client’s locale as opposed to the server’s locale.
- How to take advantage of the default resource mapping provided by WebLogic Server to localize MBean descriptions.
- How to write a simple client that access our MBean using a locale other than the server’s locale.
- How to set the locale associated with JConsole.
In this new blog entry we will demonstrate:
- How to emit an AttributeChangeNotification each time a new property is added or changed through our MBean.
- How to properly localize our notifications.
- How to observe notification using JConsole.
- How to write a client that subscribes to the notification emitted by our MBean.
The complete code sample and associated build files for part IV are available as a zip file. The code has been tested against WebLogic Server 10.3.3.0 and JDK6. To build and deploy our sample application, please follow the instruction provided in Part I, as they also apply to part IV’s code and associated zip file.