Open Source Ajax Framework For Java EE Application Developers

ICEfaces RIA Journal

Subscribe to ICEfaces RIA Journal: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get ICEfaces RIA Journal: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

ICEfaces Authors: Ted Goddard, Steve Maryka, Pat Romanski, Ken Fyten, Shay Shmeltzer

Related Topics: RIA Developer's Journal, ICEfaces RIA Journal, Apache Web Server Journal, Open Web Magazine

RIA & Ajax: Article

Is Web 2.0 Possible with Existing Open Source Technologies?

AJAX Pushed

As we assess different push mechanisms it'll be important to understand how they address the connection-sharing problem, since it's complex and beyond the scope of what the typical application developer should be exposed to. As an aside, browser vendors could drastically reduce the complexities of connection sharing by allowing two connections per window or providing XmlHttpRequest with control over HTTP pipelining, thereby allowing distinct windows to share a single connection.

Application Server Scalability
When we examine the open connection issue from the perspective of the application server, we see a variation on the problem. It turns out that modern application servers can handle a large number of connections efficiently, but under the existing servlet model, each of those connections requires a thread for execution. If these connections become long-lived due to sporadic server-initiated updates, server scalability is severely compromised by thread pool exhaustion.

While standards activities related to asynchronous communication in the servlet model progress in JSR 315, the industry has tackled the problem in disparate, non-standard ways. The lack of a standard mechanism is discouraging because any scalable push mechanism will need to be tightly integrated with the underlying server mechanism, requiring deployment-specific implementations. The good new is that a variety of solutions has emerged across open source applications servers, which we'll survey.

Tomcat 6 provides Asynchronous Request Processing (ARP) through an additional servlet interface, org.apache.catalina.CometProcessor. The CometProcessor enables the servlet to receive events when data is available for reading, rather than consuming a thread during a blocking read. The event-based mechanism gives the developer fine-grained control over asynchronous I/O processing unlike the normal service() method. Tomcat 6 also provides a CometFilter interface that enables a filter chain that's invoked when comet events are processed.

Glassfish V2/Grizzly provides ARP through the class com.sun.enterprise.web.connector.grizzly.comet.CometEngine. Applications can register to receive events through a CometHandler and, like Tomcat 6, process READ events when data becomes available, versus performing a blocking read.

Jetty 6 provides a continuation mechanism that supports ARP in the existing servlet API. The org.mortbay.util.ajax.Continuation class provides suspend/resume members that suspend the request processing and let it asynchronously resume later, potentially on a different thread. When suspend() is called from inside the servlet's service() member, an exception is generated, which is caught by the Jetty server and used to identify the request to be resumed. Resuming the request reinvokes the service() method, which can then proceed with writing the response. One complication with continuations is that the service() method must be implemented specifically to support the double invocation. The advantage is that standard servlet filtering can be applied, although filters must handle double invocation as well.

ICEfaces Asynchronous HTTP Server (AHS) is not an application server at all, but co-exists alongside any application server to provide ARP to ICEfaces applications. Unlike the previously described mechanisms, there's no programming API associated with the AHS and its functionality is specific to ICEfaces. The AHS is configured to handle the asynchronous communication channel, matching updates with pending requests using a bounded thread pool. It can be deployed in clustered environments and includes a servlet mode that can be used to handle AJAX Push in portal environments.

Development Models
A basic understanding of the push mechanism and its associated complexities leaves the developer pretty far away from actually implementing push-style applications. We'll now turn our attention to open source AJAX technologies that specifically facilitate push-style application development.

Dojo/Cometd/Bayeux provides a client-centric programming model and a general-purpose publish/subscribe mechanism that extends to the server. Unique channels can be defined for specific message classes, and clients to those channels can exist in the browser and server. JavaScript application logic is implemented to handle messages pushed from the server and update the UI appropriately. From the server's perspective, a push channel is defined and server-side application logic publishes events over that channel. Cometd is a flexible mechanism that supports both Java and Python implementation at the server. Cometd has been integrated with Tomcat 6, Grizzly, and Jetty 6. Browser connection sharing is possible using a shared cookie mechanism that supports bulk data transfers between windows. Essentially, the Cometd approach yields a loosely coupled distributed system and as such requires that the application developer address associated complexities such as security and maintainability.

DWR/Reverse AJAX provides a client-centric programming model based on Remote Procedure Calls (RPC). Basically, DWR facilitates calling server-side Java objects from the client via JavaScript stubs, and Reverse AJAX facilitates calling JavaScript objects from server-side Java objects. For a push interaction, a JavaScript implementation is required to handle the specific update, and the sever-side Java logic must invoke that JavaScript appropriately. The DWR servlet handles the marshaling of RPC calls over the HTTP connection, but the connection-sharing problem hasn't been addressed in the JavaScript implementation. DWR is integrated with Jetty 6.

ICEfaces/AJAX Push provides a server-centric programming model based on JavaServer Faces (JSF). The ICEfaces extensions to JSF enable a transparent AJAX bridge that delivers incremental changes to the browser based on the standard execution of the JSF life cycle. A simple extension API allows application logic to request a page render based on some asynchronous event, and the resulting incremental changes are propagated to the browser over the bridge. ICEfaces provides APIs to support group renderers, where logical groups of browser clients can receive the same updates. It also provides a RenderHub that handles synchronization and optimizes performance of the low-level asynchronous rendering mechanism. ICEfaces can be configured to use ARP mechanisms from Tomcat 6, Grizzly, and Jetty, as well as the ICEfaces AHS. The ICEfaces bridge supports connection sharing through a shared cookie mechanism, and when configured with the AHS in servlet mode supports AJAX Push in portal environments.

We have characterized Web 2.0 as a platform for spontaneous and instantaneous social networking, and have examined the complexities associated with delivering the required push-style capabilities using lightweight Web-based techniques. While most of the existing AJAX technologies do nothing to address the problem, a small handful of open source technologies have emerged that deliver the necessary capabilities. So, yes, Web 2.0 is possible today with existing open source technologies. Further standardization will help, and next-generation browser implementations will ultimately alleviate some of the complexities. If push-style Web applications and Web 2.0 are on your horizon, dive in and see what is possible. A word of caution, though, you should carefully examine your existing development best practices and deployment constraints, and devise an approach that will empower you to focus on application development, not low-level push infrastructure development.

More Stories By Ted Goddard

Ted Goddard is the senior architect of the ICEfaces AJAX framework. Following a Ph.D. in mathematics, he proceeded with postdoctoral research in component and Web-based collaborative technologies. He currently participates in the JavaServer Faces and Servlet expert groups.

More Stories By Steve Maryka

Stephen Maryka is CTO at ICEsoft Technologies Inc., and leads the ICEfaces open source project. He has been involved in Java-based AJAX techniques since 2003 - a time before the term "AJAX" was even coined. Prior to joining ICEsoft, Steve was co-founder of AudeSi Technologies where he served as VP of Technology and led Java product development for Internet appliances. After AudeSi was acquired by Wind River Systems in 2000, he served as a principle technologist there until joining ICEsoft.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Most Recent Comments
radixweb 08/13/08 09:21:00 AM EDT

Hey, Great Post.. Thanks for this..

MiamiWebDesigner 08/02/08 09:34:25 AM EDT

Web 2.0 Is Like Pornography

Like so many tech articles posted since Tim O'Reilly coined the term in 2004, this one references "Web 2.0" as if it were something tangible--or at least a concept with clear, concise definition. It is not. In 2006, Web founder Sir Tim Berners-Lee sagely observed that "nobody knows what it means":

In 2007, Michael Wesch put together this video that supposedly "explains what Web 2.0 really is about":

It is a cool video. But the message is all about XML and how it can be used to separate form and content. There was no mention of CSS and XHTML, but no matter. I was writing XML parsers in the '90s, and XHTML/CSS web design pre-dates "Web 2.0" as well. No cigar, Professor Wesch.

And now in 2008, the most honest thing we can say is that "Web 2.0" means whatever the techno-marketeer (ab)using it wants it to mean. Otherwise, why would intelligent people like Isaac O'Bannon still be writing articles asking "What is Web 2.0?":

And, why would McKinsey's just-released best-of-breed report entitled "Building the Web 2.0 Enterprise" ...

... include no attempt at defining the term other than to list the "Web 2.0 Tools" that comprise or enable it? And even there, the chief ingredient is identified only as "Web Services", adding more mystery to the mix as one ethereal term is offered up to explain another.

As originated in an website design posting...

... "Web 2.0" is like pornography: Nobody has defined it, but you know it when you see it.

Bruce Arnold, Web Designer, Miami Florida