YOUR FEEDBACK
3rd International Virtualization Conference & Expo: Themes & Topics
queZZtion wrote: Who is the current leader in the market for backup and di...
SOA World Conference
Virtualization Conference
$50 Savings Expire May 23, 2008... – Register Today!

SYS-CON.TV

2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
TOP THREE LINKS YOU MUST CLICK ON


Integrating AJAX with JMX: Opposite Ends of the Systems Management Stack
"AJAX presents architectural opportunities that shouldn't be overshadowed by the rich-client frenzy."

Digg This!

Page 2 of 3   « previous page   next page »

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");

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
JavaScript (described below) is included in main.jsp as follows:

<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);
}



Page 2 of 3   « previous page   next page »

About 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 wrote: 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.
read & respond »
LATEST AJAXWORLD STORIES
AJAX World - SOA Created AJAX and Rich Internet Applications
SOA has come a long way from a concept to wide-scale adoption by the enterprise at multiple layers of IT. SOA implementation at the UI layer is the latest in SOA adoption trends. SOA has manifested itself in a number of flavors such as the creation of a rich user experience by us
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in mi
Curl CSO to Speak at SYS-CON's AJAX World RIA Conference & Expo
According to Jnan Dash, Chief Strategy Officer of Curl, 2008 and beyond will see increased adoption of Web 2.0 in the enterprise. 'But the door for this entry will be RIAs (Rich Internet Applications),' Dash notes, 'rather than mash-ups or blogs or wikis.' An industry veteran who
AJAX World - Deploying an ASP.NET AJAX RSS Reader on Linux
Have you ever wished you could run ASP.NET applications on Linux, without having to rewrite your code or leave the Visual Studio development environment? In this article, I show you how to port Steve Clements' AJAX ASP.NET RSS Reader to native Java and deploy it to Apache Tomcat
Facelift Your SOA with Rich Internet Applications
We are entering an era of Rich Internet Applications (RIA) and enhancing the user experience of consumers of the services becomes an important part in designing and implementing SOA. But if you decide to develop rich clients, you'll be facing the dilemma - which way to go - remai
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE