Skip to main content

Woke From Dreaming

Posted by editor on March 22, 2007 at 7:18 AM PDT

Giving your clients a kick

Aren't distributed events a fun problem to solve? It was nearly ten years ago that I read and was profoundly inspired by a HotWired (remember them?!) article, Writing Chat Systems with Java 1.1's RMI, which showed how to build a chat system that used RMI to asynchronously send new messages to all the participants (or let two participants exchange messages directly, without touching the server). In fact, a year or two later, I designed a client-server system that put a nice, clean event listener metaphor around RMI communication, so the Swing clients would get asynchronous updates from the server when new media arrived that they'd be interested in. It worked great, so long as you didn't get hosed by RMI's inexplicable and evil reverse-DNS lookup, which is a rant for another time. If I had it to do over, I'd probably use Jini, since it would be more robust and tolerant of failure (and I was already pretty pro-active about dead clients). But suffice to say that asynchronous updating of clients is one of those interesting problems you see over and over again.

To wit, what if instead of a nice thick Swing client on the LAN, your client is a web page somewhere halfway across the internet? And what if the nature of your application still calls for the server to send asynchronous notifications to the client? This is handily addressed by the Direct Web Remoting Ajax framework, and its new "Reverse Ajax" feature. Katherine Martin has details in
our Feature Article,
Developing Applications Using Reverse Ajax.

DWR, hosted on, is a Java open source library that helps developers to write websites that include Ajax technology. When DWR broke onto the Ajax scene with release 1.0, its announced mantra was "Easy Ajax for Java." It aids the developer in many ways, not least by allowing code in the web browser to use Java functions running on the web server as if they were in the browser.

With release 2.0, DWR continues on the same theme, removing from the developers shoulders the pesky problem of "pushing" information. It introduces the term reverse Ajax to describe this asynchronous transfer of messages from server to browser or browsers. While, as mentioned above, techniques for doing this already exist, the beauty of "reverse Ajax" is that it wraps them all up neatly and then automatically selects the best method to use transparently to the user.

In a nice bit of irony, the sample code for Katherine's code, included as part of the DWR 2.0 application, is a chat application... just like the HotWired article from 10 years ago. The more things change, the more they stay the same.

In Java Today,
the just-announced (and still-incubated) GWT4NB project is an effort to develop a NetBeans module to support Google Web Toolkit development. GWT is "is an open source Java software development framework that makes writing AJAX applications (...) easy for developers who don't speak browser quirks as a second language." GWT4NB's features include using GWT with new or existing web projects,
deploying, running, and debugging GWT-enabled Web Apps using and arbitrary application server, and
assistance to deal with some code editing nuances such as creating services efficiently.

The JAXP project, the reference implementation of the Java API for XML Processing, has released Version 1.4.1. This is the first patch since JAXP 1.4 was released in October, and among 36 issues addressed, it fixes a regression in which DOM generated by code from a DocumentBuilder using DOM level 1 methods (createElement, etc) fails validation against an XML schema.

Not clear on the point of portlets, or where the spec stands today? Get a reset from the SDN article Introducing Java Portlet Specifications: JSR 168 and JSR 286. "In February 2006, the JSR 286 Expert Group was formed to start work on Java Portlet Specification 2.0. When that is finalized, backward compatibility will be in place: JSR 168 portlets will be able to run seamlessly in JSR 286 portlet containers. No recompilation will be necessary. This article spotlights JSR 168 and the associated software, Portlet Container 1.0 and the NetBeans Portlet Plug-in. Also described are sample portlets and JSR 286 in its draft state."

Ahmed Hashim has some Tips to save client's bandwidth in today's Weblogs. "In this post, I will write about the client/server bandwidth saving. In some countries, the cost of the Internet is based on the bandwidth consumption, you pay for the number of MB's you have used as traffic, so, if there is a website which contains pages with large size, you will consume the client bandwidth!"

Joshua Marinacci offers more detail on his latest project in
AB5k Widgets in Depth:
"Well it's been two weeks since AB5k was released and the response has been, well, interesting. Some people really love it. Others have complained it's slow and buggy (which it is), and still others ask "why make another widget system, but this time in Java?". We got somewhat panned at JavaLobby in particular."

Finally, in
Tools You Can't Live Without and the Soviet Bread Line, Edward Ort says you'll
"learn how a technical session on Ajax and JavaScript at the ServerSide Java Symposium led to the Soviet breadline."

In today's Forums,
ksak explains GlassFish behavior in
Re: Problem (bug?) using @EJB annotation
"Each injection of an @EJB field for a stateful session bean creates a new stateful session bean identity. In your code, it's a stateless session bean instance that defines the @EJB. That simply means that each stateless session bean instance that is created will have a reference to a stateful session bean. However, each time your client calls the stateless session bean, there is no guarantee as to which stateless session bean instance will process the request. That's why it's possible for more than one client thread to be returned the same stateful session bean."

eyal757 seems to have some 2D/3D cognitive impedence in
Cylinder and a Mouse:
"Hi All. I have a problem. I draw a Cylinder (using Cylinder class) on Canvas3D inside JPanel. I add to this JPanel a mouse MouseMotionListener and a JLabel that shows the mouse cursor position (x,y,z coordinates). The problem is that the class MouseEvent has only getX() and getY() method. How can I get the z coordinate position with the mouse?"

xigua is thinking about a
Dev Performance Monitoring tool:
"I don't want to duplicate the efforts that the performance team is doing, instead I am more interested in getting the detailed performance related info about, say, 'every unit test'. The picture in my mind is, there are a special set of unit tests (or maybe all the unit tests). Each unit test will have a list of baseline performance data such as the execution time, # of objects being created, total amount of memory being allocated during the execution, # of queries (if not an integration test, then no need), execution time spent in each layer, and more... These tests will be executed every night or for every build, a report will be generated to show how many improved and how many degredation, etc.. I could probably use AOP to do some of it and use tools like P6spy to get the DB part, however, it will be even much easier if there are tools out there that can do this."

Current and upcoming Java

Registered users can submit event listings for the href=""> Events Page using our href="">events submission form.
All submissions go through an editorial review before being posted to the

Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of it will be
archived along with other past issues in the href=""> Archive.

Giving your clients a kick