20070611 JonFerraiolo OpenAjax Hub

From MemberWiki

Jump to: navigation, search

Contents

About this wiki page

This wiki page contains a proposed revised write-up for /OpenAjax%20Hub.html that provides an introduction to the OpenAjax Hub and attempts to give outsiders a basic understanding of what it is and what benefits it provides.

The proposed new write-up on the OpenAjax Hub

OpenAjax Hub

What is the OpenAjax Hub?

The OpenAjax Hub (the "Hub") addresses Ajax application scenarios where a Web application developer needs to use multiple Ajax runtime libraries together within the same application. The Hub provides standard JavaScript that, when included with an Ajax-powered Web application, promotes the ability for multiple Ajax toolkits to work together on the same page.

The OpenAjax Hub is a key technology component within the umbrella term OpenAjax Conformance [hyperlink]. To be OpenAjax Conformant, among other requirements, Ajax runtime libraries must support the conformance criteria found within the OpenAjax Hub Specification [hyperlink].

The OpenAjax Alliance recommends that Web developers and IT professionals demand OpenAjax Conformance as an industry requirement from its Ajax technology providers. By requiring OpenAjax Conformance, customers gain confidence in their technology and product choices and realize benefits in terms of the ability to integrate Ajax technologies from multiple suppliers, the ability to change suppliers at reduced costs, and increased certainty that their suppliers are adopting industry best practices.

When is the OpenAjax Hub needed?

There is great diversity among the requirements of Ajax application developers, and as a result there is great diversity in the architecture and features in the 200+ Ajax products in the marketplace today. For some developers, the most important factor will be finding an Ajax toolkit that offers strong integration with back-end servers. For other developers, the most important factor will be the availability of particular client-side components (e.g., a rich data grid widgets or an interactive charting widget). As a result, the Ajax ecosystem has developed such that most of the time the developer can find an Ajax toolkit that matches each particular requirement, but often the developer finds that he must mix and match multiple Ajax toolkits within the same Web application in order to address all of his requirements.

One important scenario for the Hub is portals and mashups, where the application developer creates a page of loosely assembled pre-packaged application components. It is virtually guaranteed that a sophisticated portal or mashup will pull in Ajax-powered components that are built using multiple different Ajax toolkits.

Features

Version 1.0 of the OpenAjax Hub includes the following two key features for Ajax interoperability:

  • Ajax library loading and unloading control - The Hub provides APIs for registering libraries, unregistering libraries, and querying about previously registered libraries.
  • Publish/Subscribe Event Hub - The Hub provides an event hub using a publish/subscribe approach allows libraries to publish and subscribe to events in a reliable manner in order to coordinate actions across components from different Ajax libraries.

The Hub's publish/subscribe manager

The Hub's key feature is its publish/subscribe manager (the "pub/sub manager"). The pub/sub manager allows one part of a mashup to broadcast an event to which other application components subscribe. For example, suppose there is a calendar widget that allows the user to pick a particular date. The mashup might have multiple UI components that need to update their visual appearance whenever a new calendar date is chosen. In this case, the calendar widget would publish a "new calendar date" event to which the other visualization widgets would subscribe. Therefore, the pub/sub manager's generic messaging benefits is a key integration mechanism between components built from different Ajax toolkits.

(Note: The Hub's pub/sub manager offers various advanced features, such as strong support for wildcards within event names, that are not shown in the example below.)

An example

Let's suppose we have a business intelligence application that uses the following Ajax runtime libraries:

  • UTILS.js, which provides highly useful extensions to the browser's JavaScript environment, such as XMLHttpRequestAPIs
  • CALENDAR.js, which provides a calendar widget
  • CHARTS.js, which provides a charting widget
  • DATAGRID.js, which provides an interactive data grid widget

The application has a single calendar widget and the ability for the user to choose among a number of data views in the form of chart widgets (e.g., bar charts for daily status, weekly status, monthly status, and yearly status) and data grid widgets (e.g., regional data versus national data, both with user-selected columns of interest). Whenever a new date is selected in the calendar widget, the various user-specified visualization components (i.e., charts and/or data grid widgets) need to be updated.

One way to implement this application is to load the JavaScript for the OpenAjax Hub before the other Ajax libraries. For example:

<html>
  <head>
    ...
     <script type="text/javascript" src="OpenAjax.js"/>
     <script type="text/javascript" src="UTILS.js"/>
     <script type="text/javascript" src="CALENDAR.js"/>
     <script type="text/javascript" src="CHARTS.js"/>
     <script type="text/javascript" src="DATAGRID.js"/>
    ...
  </head>
  ...

(Note: Some Ajax runtimes will include the OpenAjax Hub as part of their standard distribution, in which case, so long as the given Ajax runtime's JavaScript is loaded before other OpenAjax-compatible runtimes are loaded, it might not be necessary to include a separate <script> element for OpenAjax.js.)

To make the application work, the developer registers a callback function that is invoked whenever the user selects a new date in the calendar widget. This callback function then broadcasts the new date event using the OpenAjax Hub's publish() function:

    <script type="text/javascript">
      ...
      // Somewhere in earlier JavaScript code, you need to invoke 
      // the calendar widget's APIs to register MyCalendarCallback 
      // as the callback function for when a new date is selected
      ...
      function MyCalendarCallback(...) {
        // Publish (i.e., broadcast) the "myapp.newdata" event via the OpenAjax Hub.
        OpenAjax.hub.publish("myapp.newdate", newdate);
      }
      ...
    </script>

Then the developer includes code such that each chart widget and data grid widget subscribes to the new date event and provides a callback function. The various callback functions then update the given visualization widget appropriately:

    <script type="text/javascript">
      ...
      function SubscribeNewDateCallback(eventname, publisherData, subscriberData) {
        ...
        // Update the given visualization widget
        ...
      }
      // Subscribe to (i.e., listen for) any "myapp.newdata" events via the OpenAjax Hub.
      OpenAjax.hub.subscribe("myapp.newdate", SubscribeNewDateCallback);
      ...
    </script>

Future toolkit support for the OpenAjax Hub

OpenAjax Alliance is working with the industry to achieve widespread support for the OpenAjax Hub. A particular Ajax toolkit can support the OpenAjax Hub as follows:

  • An Ajax toolkit can include the Hub (most preferable). The Hub can be implemented with <3K of JavaScript, so some Ajax toolkits will simply bundle the Hub as a standard component of their toolkit.
  • An Ajax toolkit can use the Hub if present. Other Ajax toolkits may decide not to ship the Hub within their distribution, but instead check to see if the Hub has been loaded previously, and if so, use the Hub's services.
  • A 3rd party can developer an adapter. For most toolkits, it is possible for a 3rd party developer to write a small amount of JavaScript that adds Hub support to the given toolkit.

When Ajax toolkits include built-in support for the Hub, the application developer's tasks are easier, but by finding or writing a simple adapter, the Hub can still be used with toolkits that have not yet implemented support for the Hub.

Version 1 Status

The OpenAjax Alliance is approaching completion of OpenAjax Hub 1.0. The OpenAjax Hub 1.0 Specification, the open source reference implementation (http://openajaxallianc.sourceforge.net), and the test suite are all in the final stages of development. The Hub previously has gone through a major review and feedback cycle centered around the InteropFest that occurred in March 2007, when 12 vendors integrated preliminary OpenAjax Hub support into their toolkits (see the OpenAjax Alliance's InteropFest wiki page [hyperlink]). After the InteropFest, the feature set for OpenAjax Hub 1.0 was streamlined and refined, along with corresponding updates to the Specification, reference open source, and test suite. The primary remaining activity is a final round of integration with various toolkits to verify that the specification and open source are complete and address industry requirements.

Futures

It is expected that the OpenAjax Hub will evolve over time and address other interoperability issues in subsequent versions. Future versions of the OpenAjax Hub will provide improved support for existing features and support new features. Among the features under development for a future version of the OpenAjax Hub are:

  • Coordination of communications requests, including server-push using Comet techniques
  • Ability to achieve "secure mashups" (i.e., allowing for the convenience of mashups, but without sacrificing security)
  • Enabling data binding across Ajax libraries
  • Expanded list of standardized events and payloads
Personal tools