Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
Learn how the Data Transfer Object design pattern is implemented in Java ME architectures and why you might want to use XML-based DTOs rather than Java beans for faster data interchange between tiers. Author Mario La Menza presents an example architecture that supports the use of XML-based DTOs and also introduces MockMe, a free tool for generating XML-based mock objects so you can test the presentation layer of your Java mobile applications without waiting for server-side data.
This article introduces the use of XML-based objects for data transport in multi-tier Java ME applications. I first explain how the DTO design pattern is commonly implemented in multi-tier Java ME architectures. I then explain the shortcomings of using Java beans as DTOs and propose using XML-based data transfer objects instead. I discuss the advantages of this approach and present an example architecture that supports using XML for data interchange. In a sidebar to this article I also introduce MockMe, a tool for generating XML-based mock objects so you can test your application's presentation layer sooner.
Data Transfer Object is a Java enterprise design pattern for exchanging data between tiers in a multi-tier application or between components in a distributed application. Data access from a remote component often implies collecting data from more than one information source. The number of data access calls required to satisfy a request can affect the performance of the calling application or client. The purpose of the DTO pattern is to resolve the performance problems associated with distributed components remotely accessing data from business objects.
By definition, a DTO is an object created exclusively to transport data. The data, which may originate from one or more information sources, are packed into a Java bean. The bean then travels through the application locally, or (more importantly) is serialized and sent across the network. Serializing the Java bean enables clients to access model information from just one object with just one call.
Because a DTO is a Java bean, it does not usually provide business logic or validation logic of any kind. It only provides access to the bean properties. Some developers stress that the bean in a DTO pattern implementation must be immutable because its changes must not be reflected in the system. However, this obviously clashes with the JavaBeans specification, which requires all private attributes to have set and get methods.
As usual, you, the developer, have the last word, as well as the responsibility for deciding how to manage the DTO's mutability. Whatever the case, DTOs should be considered part of your model because they are immutable copies of business objects.
I briefly mentioned object serialization in the DTO design pattern. Serialization is the process of transforming an object into a byte stream before sending it across a network. On arrival, the byte stream is reassembled into an object and used locally. Java ME does not support serialization or reflection (that is, the mechanism by which objects inspect themselves to discover their methods, attributes, parameters, constructors and so on). Subsequently, whatever serialization you do in your Java mobile applications must be developed ad-hoc and is subject to some restrictions -- for instance, it cannot be fully automated.
To achieve serialization in Java ME, you start by creating a serializable interface with methods such as writeObject(ObjectOutputStream out) and readObject(ObjectInputStream in). You then provide the DTOs made to implement each method (a specialized implementation of each method) for each object.
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq