OpenAjax Hub 1.0 and InteropFest

September 22, 2007 – 12:28 am by coachwei | Category WebDev |

OpenAjax Alliance has made substantial progress in the last 12 months since its inception. The cornerstone is OpenAjaxHub 1.0 (OaaHub 1.0).

OaaHub 1.0, an open source project under Apache V2 license, focuses on interoperability - it enables different Ajax components to inter-operate with each other using a “pub/sub” mechanism while these Ajax components may have no knowledge of each other at all. OaaHub 1.0 is extremely small (6KB, uncompressed, and with comments) but it is powerful and extremely useful for building Ajax applications.

The power and the adoption of OaaHub 1.0 are both demonstrated at OpenAjax InteropFest, to be hosted alongside the coming AjaxWorld Conference. At the time of writing this post, there are 17 Ajax toolkits participating the InteropFest. These toolkits are:

  1. Apache XAP (http://incubator.apache.org/xap)
  2. Dojo Toolkit (http://www.dojotoolkit.com)
  3. Ext (http://www.extjs.com)
  4. ILOG JViews (http://jviews.ilog.com)
  5. IT Mill Toolkit (http://www.itmill.com)
  6. JQuery (http://jquery.com)
  7. Lightstreamer (http://www.lightstreamer.com)
  8. Microsoft Ajax Library (http://ajax.asp.net)
  9. Nexaweb Ajax Client (http://www.nexaweb.com)
  10. OAT: OpenLink AJAX Toolkit (http://oat.openlinksw.com/)
  11. OpenSpot CalcDesk (http://www.openspot.com/)
  12. Prototype (http://www.prototypejs.org/)
  13. script.aculo.us (http://script.aculo.us/)
  14. Software AG’s webMethods Composite Application Framework (wM CAF) (http://www.webmethods.com/Products/CAF)
  15. TIBCO General Interface Professional Open Source Ajax Toolkit (http://developer.tibco.com/gi)
  16. 24SevenOffice Vili (Ajax toolkit from 24SevenOffice)
  17. YUI (http://developer.yahoo.com/yui/)

Note some of these are OpenAjax members and some are not. Some of these are open source and some are not. They represent the leading Ajax offerings in the market today. The ability to enable all these offerings to work with other components, without requiring these offerings to be modified or changed, speak well to the technical merits of OpenAjaxHub 1.0.

I had fun participating the InteropFest myself. In my sample application, a “data generation” component provided by OpenAjax Alliance, Nexaweb Ajax Client, and OpenAjax Hub are all wired together using the “pub/sub” mechanism. The “data generation” component generates and publishes simulated stock quotes. A managed client object called “DataVisualMco” (implemented using Javascript), loaded and managed by Nexaweb Ajax Client, subscribes to this topic when it is being initialized:

     DataVisualMco.prototype.init = function(event) {
                  if(window["OpenAjax"])      {
                     OpenAjax.hub.registerLibrary(”xap”, “http://incubator.apache.org/xap”, “1.0″);                                                                        OpenAjax.hub.subscribe(”org.openajax.interopfest10.datagen.stockpriceupdate”,
“stockpriceupdate”, this);
                          }          

                 this.session=event.session;
                 this.message_count=0;
      };

(note that I use “prototye” to define functions. It is arguable whether it is better to use “prototype” or a “JSON” like format to define classes. See To prototype or not to prototype).

Then when a message is received, the “DataVisualMco” simply updates the UI:

       DataVisualMco.prototype.stockpriceupdate=function(eventName, stock) {
                    this.message_count++;
                    this.updateStockTable(stock.tickerName, stock.corpName, stock.price);
                    this.updateMsgTable(stock.tickerName, stock.corpName, stock.price);
       };

The above is all the code required to use OpenAjaxHub 1.0 to receive data from some foreign components. Sweet!

Here is the demo (you can also see the source code from the “About” tab):

http://dev.nexaweb.com/openajaxtest

The demo downloads the entire Nexaweb Ajax Client package (which is not necessary given that most of the widgets are not used in the demo) and it is not compressed. If we compress it, I think the footprint would be under 100KB.

Post a Comment