Overview of ValueObjects

The need for a framework

Most web services development tools support sending messages with simple data type, such as integers and strings. Unless you are building a "Hello world" web service, chances are you will need to exchange persistent business objects. The most robust way to build business objects is to use Object-Relational Mapping frameworks such as ADF Business Components (BC4J), TopLink, Castor, Hibernate, etc. Unfortunately, objects created using these frameworks are not compatible with SOAP and web services platforms. For instance, ADF Business Components use oracle.jbo.Row and oracle.jbo.domain types; TopLink, Castor and Hibernate use Java collections. These objects can not be received or returned by web services without defining SOAP-encoding or translators. Both options require custom coding and/or complex configuration, taking the developers' time away from actual development.

ValueObjects - Business Objects for Web Services

ValueObjects is a wizard-driven Java framework developed by Zak Mandhro that implements the Value Object (also known as Data Transfer Object) pattern for Web Services. Valueobjects have the following properties:

  1. ValueObjects are SOAP 1.1-compliant. All non-supported data types are converted and decomposed to simple XML types. This translation is extensible via a simple XML mapping file.

  2. ValueObjects are persistable as business objects. They can initialize from a persistent business object, such as a View Object in ADF Business Components or an Entity EJB. They can mutate persistent objects based on the state of the ValueObject. This two-way mutability is provided using simple method calls, initializeFrom() and persistAs().

  3. ValueObjects are serializable. They can be persisted to object streams or send over the wire using RMI.

  4. ValueObjects are JavaBeans. They can be used as abstraction objects for your presentation layer, such as Java Server Faces and JSP.

  5. ValueObjects are Comparable. ValueObjectComparator offers a simple mechanism for sorting collections of ValueObjects.

  6. ValueObjects have cyclic redundancy checking (CRC). Using a simple checksum() method call, services can check with the objects have been modified.

  7. ValueObjects are composite objects. They implement object composition to support one-to-one and one-to-many relationships.

  8. ValueObjects provide String and XML rendering. The toString() method call on any valueobject renders the entire contents (recursively rendering composed objects) as string; toXmlString() renders as XML.

The current release of ValueObjects supports all the above listed features.

Accelerated Service-Oriented Architecture Development

ValueObjects framework provides accelerated Service-Oriented Architecture development. This is accomplished by releasing ?wizards? for popular IDEs that analyze business objects to automatically generate code for ValueObjects. The wizards do the plumbing so developers can focus on building the business entities and business logic.

Oracle JDeveloper 10g is the first platform to have a ValueObjects wizard. Future platforms may include NetBeans and Eclipse. O-R frameworks planned for ValueObjects support include Hibernate, TopLink and Castor.

ValueObjects Extension for Oracle JDeveloper 10g

Oracle JDeveloper 10g is the first platform to benefit from a wizard for ValueObjects. I picked this platform because (1) it is what I use at work and what our client needs ? this ensures that the implementation of ValueObjects will be clean and robust, (2) because JDeveloper 10g is a highly productive visual development platform for J2EE and especially for web services.

Oracle JDeveloper 10g and the Oracle Application Development Framework (ADF) offer a highly productive development environment for building enterprise-class web applications. JDeveloper offers visual development using Model-View-Controller architecture. ADF Business Components (formerly known as BC4J) is a wizard-driven commercial O-R mapping framework from Oracle which is tightly integrated with JDeveloper.

The ValueObjects extension for JDeveloper 10g recursively generates the code for inter-dependent ValueObjects by parsing and analyzing XML mapping files.

Here is a typical use case for the extension:

  1. Developer clicks on the View Object and select "Generate ValueObject ..."

  2. The wizard parses the XML for the View Object and all related View Objects, Entity Objects and View Links.

  3. Developer customizes the valueobject attributes and SOAP-translation.

  4. Wizard generates/re-generates all the valueobject source files and adds them to the JDeveloper project.

  5. Developer can customize the source files for added behavior or attributes.

  6. Developer writes a Java class that takes the valueobject as a parameter or returns a valueobject, right clicks on the class and clicks "Create J2EE Web Service" to expose it as an RPC-style web service.

See the screenshots of ValueObjects JDeveloper 10g Extension.

Getting started

Follow the links on the left to download the developers guide and the ValueObjects source/binaries package.