5.2. Remoting to Spring Beans
Existing and new Spring beans can be exposed as Flex remoting service destinations. Prior to the availability of the Spring BlazeDS project, it was common to write a custom factory to get access to the Spring beans. Spring beans are managed objects and in standard BlazeDS instantiating the beans and maintaining their lifecycle had to be delegated to an external Spring framework container. With Spring BlazeDS, using Spring beans as remoting destinations is considerably simplified.
Let's take a simple example to explain things a bit further. I create a simple Spring bean, which I call BookService. The BookService allows me to perform the create, read, update, and delete (CRUD) operations on a catalog of books. Each book is identified by four simple attributes:
Id (a catalog specific identifier)
Title
Author (I make an assumption that each book in the simple example has only one author)
Price
In a real-life book catalog, you are likely to find other attributes like the name of the publisher, the year of publication, and the two types of ISBN numbers for a book. To keeps things simple and to keep the focus on the core aspects of remoting Spring beans to Flex, all these additional attributes are not included in the simple example.
In the simple example, a Book could be modeled as a POJO, which could be as follows:
package problazeds.ch05; import java.io.Serializable; public class Book implements Serializable { static final long serialVersionUID = 103844514947365244L; ...
Get Professional BlazeDS: Creating Rich Internet Applications with Flex® and Java® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.