| By Graham P. Harrison | Article Rating: |
|
| December 14, 2005 06:30 AM EST | Reads: |
91,029 |
Each step is described in detail below.
Register MBeans and MBean Listeners
On each J2EE server instance, two start-up classes are run at server start-up:
- ManagementStartup: Registers the UserWeb MBean in the local MBean server. Startup class parameters include default settings of the alert status, as well as the MBean name and MBean class. For example:
<StartupClass
Arguments="ServerName=admin,
MBeanName=ExampleApp:Name=UserWeb,
MBeanClass=com.grahamh.management.userWeb.UserWeb"
ClassName="com.grahamh.management.startup.ManagementStartup"
FailureIsFatal="true" Name="UserWEB" Notes=""
Targets="admin,OLTPCluster"/> - MbeanRegistrations: Used to register a Singleton POJO, ManagementListener, with the UserWeb MBean on the administration server.
A javax.management.NotificationFilterSupport object is used to list the notification types that the UserWeb MBean will generate and the listener will receive:
// MbeanRegistrations.java
MBeanHelperFactory.getWebHelper().registerListener();
// UserWebMbeanListener.java
public void registerListener() throws UserWebException{
try {
// get listener and filter
ManagementListener listener = MBeanHelperFactory.getListener();
NotificationFilterSupport filter = listener.getSupportedEvents();
// get admin mbean server;
//register the listener and filter with the UserWeb MBean
RemoteMBeanServer rmbs = getAdminMbeanServer();
rmbs.addNotificationListener
("ExampleApp:Name=UserWeb", listener, filter, null);
}
catch (Exception e) {
throw new UserWebException
("Unable to registerListener: "+ e.getMessage(), e);
}
}The listener.getSupportedEvents() method returns the following filter:
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType("alert.broadcast");
Because the ManagementListener implements Weblogic.management.RemoteNotificationListener, it can get JMX notifications that are generated in either the local JVM or a remote JVM; in this case, generated in the remote administration server JVM.
Broadcast Admin MBean properties
The administration and managed UserWeb MBeans can be set independently, giving any one J2EE server a localized AJAX response. However, a general Operations, Administration & Support (OA&M) support pattern would set the admin MBean properties and then broadcast these properties to the MBeans on the remote application servers, using the Notification model, for subsequent AJAX retrieval.
Because the UserWeb MBean is based on ApplicationMBean, which extends javax.management.NotificationBroadcasterSupport, the infrastructure is in place for the UserWeb MBean to notify all listeners. Hence, the administrator sets the relevant MBean properties (using the HTMLAdaptor) and clicks BroadcastState (see Figure 2).
Consequently, the UserWeb.broadcastState()method is executed, which notifies all listeners synchronously with the state of the admin MBean:
public void broadcastState() throws Exception {
try {
Notification n = new Notification
("alert.broadcast", "ExampleApp:Name=UserWeb", 0);
n.setUserData(new UserWeb(this));
this.sendNotification(n);
}
catch (Exception e) {
throw e;
}
}
Because the data is serialized over the network, the non-transient object graph must be serializable.
Receive Notification of MBean Props via Listener
The event listener is the ManagementListener Singleton. The JMX Notification framework on the administration server makes a remote call to the ManagementListener handleNotification() method in each listener on each of the OLTP cluster JVMs, which registered on server start-up:
public void handleNotification(Notification notification, Object handback) {
System.out.println("Received alert: " + notification.getType());
// get event userdata from notification
Object userData = notification.getUserData();
if (userData instanceof UserWeb) {
// comes from destin8 Web
UserWeb WebVo = (UserWeb)userData;
UserWebMBeanHelper helper = MBeanHelperFactory.getWebHelper();
// get from value object and set into local MBean using
MBeanHelper
helper.setAlertMessage(WebVo.getAlertMessage());
helper.setAlertStatus(WebVo.getAlertStatus());
helper.setCallBack(WebVo.getCallBack());
helper.setRefreshAlertStatus(WebVo.getRefreshAlertStatus());
}
}
The 'master' UserWeb data is set into the local User-Web MBean via its MBean helper. Consequently each managed server is updated with the master UserWeb state.
That's as far as the JMX elements need to go.
AJAX Request of Management State
The browser client is AJAX-enabled as follows:
- main.jsp - instrumented JSP page that checks the (JMX) alert status and polls the server for alerts. It includes admin.js
- admin.js - JavaScript utilities that use XMLHttpRequest to poll the server for the management state, parse the XML response, and repaint the 'status' area of the screen
<script type="text/javascript" src="./js/admin.js" ></script>
Rather than poll continuously, we will only poll if alerting is enabled. We use the UserWebMBeanHelper to check this status. If enabled, the JavaScript function initAdmin() is invoked when the page loads:
<%
if (MBeanHelperFactory.getWebHelper().isAlertEnabled()) {
%>
<body bgcolor="#F4FFE4" onload="initAdmin();">
<%
} else {
%>
<body bgcolor="#F4FFE4">
<%
}
%>
Published December 14, 2005 Reads 91,029
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Graham P. Harrison
Previously a Senior Consultant with BEA, Graham is the author of Dynamic Web Programming using Java (Prentice Hall, 2000) in addition to a number of articles for the Java Developers Journal and IBM DeveloperWorks. He has a focus on Enterprise Architecture, Performance Tuning and Capacity Planning
![]() |
Mark 09/29/06 02:36:10 PM EDT | |||
I would like to get a copy of the source code that accompanies this article. Please send it to elihusmails[at]gmail[dot]com thank you. |
||||
![]() |
Mark 09/29/06 02:29:13 PM EDT | |||
I would like to get a copy of the source code that accompanies this article. Please send it to elihusmails[at]gmail[dot]com thank you. |
||||
![]() |
hong li 05/29/06 09:40:54 AM EDT | |||
My email address is : hongli3648@yahoo.com.cn |
||||
![]() |
hong li 05/29/06 09:38:44 AM EDT | |||
Could you please forward the whole source code to me which show those code to implement function of notification system useing Ajax and JMX? Thanks! |
||||
![]() |
Pete 02/05/06 09:10:28 AM EST | |||
Great article when you want to understand an integration point between AJAX and wider J2EE space. |
||||
![]() |
Bill Ley 01/31/06 07:44:42 PM EST | |||
This is an awful article. |
||||
![]() |
?? ???? 12/22/05 09:12:21 PM EST | |||
Trackback Added: AJAX with the JMX Notification Framework; blockquote>Integrating AJAX with the JMX Notifica |
||||
- Kindle 2 vs Nook
- Is Cloud Computing Like Teenage Sex?
- GovIT Expo Highlights Cloud Computing
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Cloud Computing Can Revitalize Your Career as Software Developer
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Virtualization Journal "Readers' Choice Awards" Voting Is Now Open
- Einstein, Sharks and Clouds: IT Security in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Virtualization Expo Call for Papers Deadline December 15
- Amazon Web Services Database in the Cloud
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Is Cloud Computing Like Teenage Sex?
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Ulitzer News: Search vs New Media
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Confessions of a Ulitzer Addict
- GovIT Expo Highlights Cloud Computing
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- Linus' Top Ten SCO Barbs
- A Closer Look at Damn Small Linux
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Where Are RIA Technologies Headed in 2008?
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- i-Technology Viewpoint: The New Paradigm of IT Buying
- Is Linux Desktop-Ready Yet...or Not?






























