Fernando Karnagi’s Weblog

Developing Swing Rich Client Application Using Spring Rich Client Project (Spring RCP)

Posted in Uncategorized by fernandokarnagi on July 14, 2008

Introduction

Since the booming of the Internet, more and more systems have changed from their first nature as Desktop Applications into Web Applications. Indeed we realize that Web Application promises lots of benefits, such as single point of deployment, thin client, and accessible from anywhere as long as you can access the Internet. Despite that fact, in some cases we still need to make our applications as desktop applications, considering the heavy usage of client, offline mode, and high response time.


There are also lots of Desktop Application frameworks each which provide end user with quite undistinguishable features. As the fact, your end users do not care of which technology you are using, as long as you meet their requirements. However, you have to be careful in selecting and using the framework if you are willing to have your application survived in the long run.

The followings are several aspects that you might want to consider when selecting which Desktop Application framework you would like to use:
•    Does it provide you with the application foundation so that you do not have to worry about, i.e. Menu, Toolbar, and Status Bar?
•    Does it support data binding?
•    Does it support data validation?
•    Does it support method binding?
•    Does it ease you on internationalization?
•    Does it provide generic dialogs or forms that you can use directly, i.e. Login Form, Help Window, and About Window?
•    Does it provide authentication and authorization mechanism? If yes, how does it work?
•    How does this framework provide flexibility for any extension or re-development?
•    How does this framework integrate with other third party frameworks, i.e. DAO framework, Service framework, etc.?
•    Is it commercial or open source?
•    Does is run in single platform or multi platform environment?
•    And others.

Your might think that the things as mentioned above are too much, or you might say that I am so demanding. You might also say that we can do it very easily using .NET and its Microsoft Visual Studio Architect or Borland Delphi. But, remember that we are talking about the Open Source environment that supports multiplatform, which is Java. In Java, there are some frameworks that we can use, for example: AWT, Swing, SWT with JFace, and also Netbeans RCP. Some IDEs also supports Visual Designer that eases the UI programming. But, do they support those requirements as mentioned above?

There comes Spring Rich Client Project (Spring RCP) that gives meets all those requirements.

Spring RCP Defined

As in other journal, once a technology is introduced, it has to be defined in an easy-to-understand manner. Spring RCP is a Swing based desktop application that is bundled within the Spring Framework (for you who are not familiar with Spring Framework, you should read some documentation on this framework first before you continue on this journal).

Below is the list of features that Spring RCP provides:
1.    Standard Application Foundation Component, i.e. Menu Bar, Toolbar, and Status Bar
2.    Form Data Binding
3.    Data Validation
4.    Method Binding
5.    Internationalization Support
6.    Generic, ready-to-use dialogs and forms
7.    Authentication and authorization integrated with Spring Acegi
8.    Framework extension opportunity
9.    Other third party frameworks integration
10.    It is open source and Apache License
11.    It is Java-based so it runs in multi-platforms environment
12.    Spring-based framework, so it can utilize Spring capabilities for example: Dependency Injection, Transaction Mechanism, and Aspect-oriented Programming (AOP)
13.    Simple setup for splash screen
14.    Ready to use Help and About
15.    Full control of Application Life-cycle
16.    Support SDI and MDI
17.    Easy-to-configured Look and Feel
18.    Form Component Interceptor support
19.    Separation of message sources and image sources
The above features will be explained in depth in a few more pages

Application Architecture

When we are introducing a framework to developers, they will be eager to know the underlying architecture of that framework. This section gives you enough architecture information so that you can start developing a Spring RCP application.

Application

Keith Donald, one of the founders of Spring RCP, defines Application as a singleton workbench or shell of a rich client application. The application provides a point of reference and context for an entire application. It provides an interface to open application windows.

The single instance of an Application object must be executed in order to run the Spring RCP application. It is like; the Application object is the heart of the Spring RCP application.

Application Launcher

Generally you do not interact with Application instance directly, but you deal with an instance of Application Launcher. Application Launcher is the main driver of any Spring RCP application. Using this object, you define the Spring Application Context configuration. This class gives you the facility to perform some application pre-launch processes, for example displaying the Splash Screen. These initial processes are executed first and before the other processes take place.

Application Life Cycle Advisor

Sometimes you would like to be notified during the application life cycle. This class provides the call-back methods guaranteed to be invoked on each event. Event examples are before window is opened, before the application is initialized, before the application starts up, and after the application starts up.

Application Descriptor

This bean describes the application. Version and Build No can be described using this bean.

Service Locator and Application Services

Service Locator and Application Services are beans that manage the application services. Application services are configurable beans that provide service used by application to run. Examples of Application Services are Application Object Configurer, Application Page Factory, Binder Selection Strategy, Image Source, and Rules Source.

Binder Selection Strategy

Binder selection strategy defines how the application will do the binding based on the data type. The beauty of Spring RCP is the data binding to Swing component. For example, if you bind a String property, this framework will generate a Text Field component that any changes on the Swing component can be committed back to the bound property and when you rebind that property, the Swing component value will be changed according to the property’s value.

Look and Feel Configurer

If you would like to change the look and feel of the application (i.e. background color, font, etc.), you can register a look and feel configurer bean.

Component Interceptor

You can register as many component interceptors as you wish. Component interceptor is responsible for intercepting user interaction with Swing component. This component interceptor is very helpful for doing the screen validation, for example: if you enter not-allowed characters on a particular TextField, the validation message appears. Examples of ready-to-use Component Interceptors are Overlay Validation Interceptor, Text Component Popup Interceptor, and Combo Box Auto Completion Interceptor.

Basic Configuration and Required Classes

Different developers might come up with different configurations. It is impossible to get the perfect solution for
You must be wandering now what you should include inside each of those application contexts. This section will explain in details what to define in each application contexts and also gives the brief explanation on each bean responsibilities.

References

•    Spring RCP Website, http://www.springframework.org/spring-rcp.html
•    Spring RCP Forum, http://forum.springframework.org
•    Spring RCP Wiki, http://opensource.atlassian.com/confluence/spring/display/RCP/Home
•    Bruycker P. D., The Spring Rich Client Project, AC Partner

Leave a Reply

You must be logged in to post a comment.