| By Graham P. Harrison | Article Rating: |
|
| October 16, 2006 08:15 AM EDT | Reads: |
23,423 |
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.
// 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");
When ManagementListener is run at server start-up, a connection is made to the MBean server on the (remote) administration server and the (local) ManagementListener is registered as a listener on events generated by the UserWeb MBean, with a filter set to "alert.broadcast" event types.
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, Objecthandback) {
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">
<%
}
%>
The repaintable 'status' area of the screen is defined as follows:
<span id="adminBanner" class="style1"></span>
'adminBanner' will be used to identify the repaintable area when the XML response is parsed and the message extracted.
The initAdmin() method schedules a JavaScript method, trapAlert(), to be executed after callbackTimeout milliseconds:
function setCallback() {
callBack = setTimeout('trapAlert()',callbackTimeout);
}
function initAdmin() {
setCallback();
}
It's the trapAlert() method that initiates the XMLHttpRequest with the now familiar ring:
function trapAlert() {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = processRequest;
req.open("GET", './admin?reqid=0', true);
req.send(null);
}
Published October 16, 2006 Reads 23,423
Copyright © 2006 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
![]() |
AJAXWorld News Desk 10/15/06 03:31:40 PM EDT | |||
AJAX and JMX are at opposite ends of the Systems Management stack. However, the emerging ubiquity of the AJAX model for rich browser clients has obscured the benefits the model provides in the architectural space for enhancing support patterns within the problem resolution pipeline. |
||||
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX






































