Sunday, July 27, 2008

GWT Weblets and On-The-Fly Compiling

GWT has been out for a while now and has proven to be a good platform for building web applications. One of the keys to GWT's success is the way it translates java into javascript and provides developers with an all java environment to work in.

But there is a limitation (what doesn't). Translating java into javascript is cool, but this can be a problem for dynamic environments. Unlike JSPs for example, GWT can't be compiled on the fly by Tomcat. Basically you always have to distribute the javascript. This is perfectly fine for distributing monolithic applications but this is not acceptable for dynamic and "pluggable" environments where you want to distribute only the java byte code jars (and client source in the case of GWT).

What GWT needs is a plugin model, maybe something similar to the way java servlets work but to have them be client centric. An example of this is a project called SOAFaces. It allows for the packaging of GWT applications into plugin modules called Weblets. These are pure GWT components that can be deployed and linked dynamically in a server environment and accessed by the client. A Weblet has a simple GWT API and a simple packaging specification for putting the Weblets into a JAR that can be distributed to any container that supports Weblets.

It is then the responsibility of the Container to compile the GWT component into javascript (sort of like how a j2ee container can compile a JSP page into java byte code).

Well as you may have guessed, the SOAFaces framework facilitates this capability. In general it would be good for the GWT community to start thinking about components and how to package, share, and deploy them in dynamic environments.

For an example of something that already supports the SOAFaces specification check out the product JobServer. JobServer supports the concept of hot deploying of Weblets and compiling GWT on the fly. JobServer provides and integrated job scheduling environment and support for Mule and SOA.

No comments: