May 30 2007

Anatomy of an Eclipse Rich Client Platform Application

Wayne Beaton, Eclipse Foundation evangelist, gave an overview of the Eclipse Rich Client Platform (RCP). As he spoke, I thought of Eclipse RCP as a Fat Client minus the lard. Wayne described a Rich Client Platform as a system that provides a rich user experience, is platform independent and extensible, and provides a component model.

The Eclipse IDE is itself a collection of plugins, or components, on top of the base Eclipse platform. A big aspect of Eclipse RCP is Equinox, the OSGi based module system used to discover Eclipse plugins. In this context, plugins, modules, and components are used interchangeably.

Wayne gave a quick overview of the plugin structure of Eclipse. Basically Eclipse provides extension or plugin points at its core level. Adding or removing functionality is as simple as adding and removing files from the plugin directory in the Eclipse installation directory.

Wayne also mentioned Mylar. Mylar monitors and remembers which resources a developer is interested in for a recorded task and hides the rest. Wayne said, “You need to look into Mylar. Mylar will change your life.”

Technorati Tags: , , , , , ,


May 30 2007

Extreme GUI Makeover 2007

This is one of the most enjoyable session in all of JavaOne. Last years Extreme GUI Makeover, the gang made over a typical looking mail client. This year Christopher Campbell, Shannon Hickey, Hans Muller, and Romain Guy presented transformed a pizza box-like business User Interface (UI) into a visually stunning UI with Swing and Java 2D. The first type presented by the extreme makeover folks is to use a modern Look and Feel like Nimbus.

According to Romain, it makes a good idea to add a splash screen, and in Java 6 this is easier than ever with the new -splash JVM option. You should also make good use of non-rectangular UI splash screen with a drop shadow, and a progress indicator. The demo here faded the splash screen image from sepia to a full color image to indicate the loading progress.

They demoed JGoodies form validation which paints a little warning icon on the text field. Another demonstration showed a modal dialog with rounded corners ala Web 2.0 which blurred the main application window below. They rounded the border by overriding the paintBorder method on the Swing component. They use of gradients everywhere. They demonstrated a set of thumbnails with reflection using ReflectionRender which you can find in SwingX project from the SwingLabs. The demo also demonstrated custom table cell rendering. The speakers said that the default cell renderer is a JLabel but that you can use any JCoponent with any layout.

The demo had some animated effects for sorting and filtering table rows by extending a TableRowSorter available in Java 6. The demo used the Timing Framework to drive the animation and used the Glass Pane to paint the animation.

One of the best moments of the demo was when Romain Guy joked, “One thing I don’t like about UI is that it is constrained inside the frame of the window.” Why stick square components inside to the bounds of a window? Romain demoed a translucent non-rectangular dialog window that floated outside the main application window. To get this effect he said he used the JNA API, which I understood him to be described as JNI for Swing.

In speaking about boring business application UIs Romain joked, “You want to call the police to arrest the guy that wrote that UI.”

In summary, if you want to makeover your Swing UI, use Java 2D, Timing Framework, SwingX, and the Nimbus L&F.

Technorati Tags: , , , , , ,


May 30 2007

Building JavaServer Faces Applications with Spring and Hibernate

This technical JavaOne 2007 session was presented by Kito Mann, author of JavaServer Faces in Action, and Chris Richardson, author of POJOs in Action. Kito and Chris talked about the holy trinity of Java-based web application development, JavaServer Faces (JSF), Spring, and Hibernate.

JSF is a server-side UI component/event model with a basic set of UI components out of the box, and a simple MVC-style framework with a basic Dependency Injection container. The standard UI component model of JSF enables third-party and open source market place for additional components.

The Spring framework simplifies JEE development with AOP, ORM support, and Dependency Injection. Spring Beans are objects created and managed by Spring. Spring AOP allows modular implementation of cross cutting concerns, such as security, logging, and more.

Hibernate is a super set of Java Persistence API (JPA). JPA is a standardized ORM, providing transparent persistence, tracks changes of objects, manages identity, and maintains concurrency. Hibernate improves productivity, performance, maintainability, and portability.

If you are going to be doing web application development with JSF, Spring, and Hibernate then you should look into JBoss Seam. JBoss Seam integrates JSF, Spring, and Hibernate with a set of generators and conventions. Seam is greater than the sum of its parts.

Technorati Tags: , , , , , ,


May 30 2007

Effective Java Reloaded – This Time It’s for Real

Joshua Bloch presented on his upcoming book Effective Java Reloaded. This was a repeat of his presentation given during last years JavaOne. I was astounded on the line to get into the room for this presentation. The line snaked the pavilion and back.

The following are some the suggestions given by Joshua during the Effective Java Reloaded session.

For object creation, Joshua recommends using the static factory pattern. The static factory has advantages over constructors, such as allowing flexibility for returning subtypes, caching, and in Java 5 you can do type inference.

Use the builder pattern to overcome the numerous telescoping constructor signatures or the bean style getter/setter methods. The build() method of the builder class constructs a object in a consistent state and can check for inconsistencies.

The following tips deal with Java generics.

Joshua suggested to avoid raw type in new code. Use generics for compile time checking. He recommends that you fully understand each warnings caused by generics and try to eliminate them if possible. If you can’t eliminate the warnings, suppress them at the lowest possible scope using the @SuppressWarnings annotation.

Use bounded wildcards to increase applicability of APIs. Use <? extends T> when parameterized instance is a T producer. <? super T> when the API is a T consumer.

Don’t confuse bounded wildcards with bounded type variables. A bounded type variable, <T extends Number>, restricts the actual class to a subclass of the typed parameter, in this case Number.

As a rule of thumb, if a type variable appears only once in a method signature, use wildcard instead. It is usually best to avoid bounded wildcards in return types. Don’t overuse wildcards, it might water down the benefits of generics.

Generics do not mix well with arrays or variable length arguments. If given a choice, choose generics.

Joshua also talked about a cool mind expanding pattern, the Typesafe Heterogeneous Container (THC) pattern, which he talked about last year.

Joshua said that generics are tricky but well worth learning as they make your code better and safe.

Joshua also recommended the use of the @Override annotation every time you want and think you are overriding a method because sometimes you are overloading a method instead.

And finally, final is the new private. Minimize mutability where ever possible, but be caution when working with serialization or cloneable.

Technorati Tags: , , , ,


May 29 2007

Swing Vector Graphics

Luan O’Carroll, director of Xeotrope and lead developer of the XUI project, talked about how to improve your average pizza box-like business User Interface with Swing and Vector Graphics. According to Luan, the basic application UI is horrible with lack of style. It is hard to enhance or create a custom Swing Look and Feel so most developers don’t bother and instead hope and wait that Sun will make a push for the desktop.

Luan provides a prescription for better User Interfaces which include using Synth, SVG, Swing, Java2D, Swinglabs, Timing Framework, and the Painter API.

Synth provides support for application UI skins and themes. Synth is basically a configurable L&F which can easily allow for skins. Synth requires less knowledge for customing the UI that creating a new L&F from scratch. Luan recommends you use SVG instead of rasterized images with Synth because one size does not fit all with raster images.

SVG is an XML-based standardized format for describing vector graphics. Gaphic illustrators and graphics tools are familiar with this format. SVG provides a rich feature set such as animations, layers, overlays, and effects. There are seveal Java toolkits for woking with SVG, such as Apache Batik and SVG Salamander.

You can breakout of the square Swing component with SVG graphics. Custom SVG/Swing components can be animated and support mouse events such as clicks and rollovers. It is possible to have Jave2D interact with SVG and vice versa so you can get the best of both worlds.

Luan mentioned the Synth SkinBuilder application which helps to customize the Synth Look and Feel. As of this writing, SkinBuilder does not seem to be available check Luan’s blog for updates.

Technorati Tags: , , , , , , ,


May 29 2007

JavaOne 2007: Wednesday General Session

Thomas Kurian, Senior Vice President of Development in Oracle, gave the Wednesday morning general session. Thomas said that Oracle is following four key technological trends including JEE 5.0, Server-Oriented Architecture and Event Driven Architecture, Web 2.0, and grid computing. As Thomas spoke I keep thinking of JEE 5.0 as a MVC framework with EJB3/JPA as the model, JSF/AJAX as the view, and JSF as the controller.

Thomas talked about having JSF components that would generate AJAX or Flash widgets just as naturally as HTML. Thomas also talked a bit about enterprise mashups as corporations begin to bridge together AJAX, JSF, SMS, RSS, wiki, blogs, and social applications with business applications.

Thomas also position Oracle as a large and committed Open Source contributer and mentioned EclipseLink, Oracle recent code donation to the Eclipse Foundation.

While Thomas spoke about Oracle’s position in the middleware, a thought occurred to me. Plain Old Java Objects (POJO) as used in EJB 3 and JPA are not as plain as you are lead to believe, but these objects might well be renamed to Plain Annotated Java Objects (PAJO).

Technorati Tags: , , , , , , , ,