Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL



Java easily ranks among the most popular enterprise computing platforms. Adobe Flex is a leading Rich Internet Application (RIA) development framework. The combination of Java and Flex is one of the most compelling propositions for enterprises to create rich and engaging applications to enhance productivity and increase customer satisfaction.

An effective integration of Java and Flex implies that you can leverage robust scalable Java server side applications in conjunction with the superior rendering capabilities of the Flash player. It also means that your investments in Java server back-ends can be reused and leveraged in your new generation applications.

Looking at the integration from the other side, an effective combination of Java and Flex means that your clunky old web 1.0 interfaces and old-style interaction models can be replaced with their more effective new-generation counterparts.

In addition to all the benefits listed above, an effective plumbing between Java and Flex promises Flex's reach to all enterprise resources, including databases, enterprise resource planning systems, authentication systems and organization-wide messaging systems.

Java and Flex integration is achieved with the help of a number of products and tools, including LifeCycle Data Services (LCDS) and BlazeDS from Adobe. LCDS is a commercial product and BlazeDS is an open source alternative to LCDS.

This book is all about combining Java and Flex. The book covers the integration story with BlazeDS as the protagonist. It explores all aspects of BlazeDS and explains its extension points that allow it to be stretched beyond its off-the-shelf capabilities.

This is one of the first few books that addresses the topic of Java and Flex integration using BlazeDS. From the very first draft proposal I have seen a lot of excitement around this topic and this book (at least among all involved in its creation). As I was writing this book over the last few months, BlazeDS and Flex saw a lot of rapid changes and inclusion of newer features and capabilities. It was also the time Spring BlazeDS emerged as a SpringSource and Adobe supported initiatives to integrate Spring and Flex using BlazeDS. I have made every attempt to keep the content up-to-date and relevant. However, some of the pieces of software are in beta phase and will continue to evolve as we work hard to make this book available in your hands. Even though this makes the book susceptible to being outdated on a few rare instances, I am confident the content remains useful and relevant through the next versions of the Flex framework, Java, and BlazeDS.

The book at all times attempts to balance between theory and practice, giving you enough visibility into the underlying concepts and providing you with the best practices and practical advice that you can apply at your workplace right away.

Who This Book Is For

This book is best suited for those developers and architects who leverage Java and Flex to create rich internet applications. Such developers are likely to come from either the Java or the Flex backgrounds, or from a background that includes neither of the two technologies.

For those who are Java experts the book teaches the details of BlazeDS and its applicability in using it to plumb Java and Flex applications together. I understand that some such experts may not have sufficient knowledge of the Flex framework. Therefore I explicitly introduce Flex 3 in Chapter 1 and provide a peek into the upcoming Flex 4 version in the appendix.

For those who are Flex developers and architects the book provides explanations and examples of how they can effectively include BlazeDS in their application stack. I assume much of the conceptual content would be accessible to such developers. It's possible though that some advanced topics on persistence, Spring integration and custom extensions could be difficult for a developer who has little or no knowledge of Java. This book does not attempt to teach Java fundamentals, which is outside its scope. Tools for learning the essentials of Java are widely available and I encourage you take advantage of them to get the most out of this book.

I advise that you read the book from start to finish for an initial understanding and then return to specific chapters to apply detailed and specific recommendations.

What This Book Covers

This book covers Java version 5 and above, Flex version 3.x, BlazeDS version 3.x and 4 beta and Flash Builder version 3.x and 4 beta. The book also introduces Flex 4 beta minimally. The content in this book should be relevant through Flex 4, BlazeDS 4 and Flash Builder 4.

Version 1.0 of Spring BlazeDS and FlexMonkey, JMS 1.1 and Hibernate 3.3.2.GA are covered.

How This Book Is Structured

This book consists of 11 chapters and an appendix. The 11 chapters gradually start from the fundamentals and progress to cover increasingly complex topics. The first chapter introduces the Flex 3 framework. The appendix minimally introduces Flex 4 beta. The rest of the chapters cover the different aspects of BlazeDS, its existing features, and its custom extensions. A majority of the chapters illustrate the proxy, remoting, and messaging capabilities of BlazeDS. For a holistic treatment, chapters on testing and scalability are also included.

As mentioned previously, I recommend that you read the book sequentially from the first to the last chapter. That way your learning curve will be smooth and gradual.

Chapter by chapter, this book covers:

  • Flex for Java Developers (Chapter 1)—A brief primer to Flex for Java developers. The chapter teaches Flex fundamentals, providing a few examples in context.

  • Introducing BlazeDS (Chapter 2)—This chapter gently introduces BlazeDS. It explains the BlazeDS architecture, its core features, configuration files and the deployment infrastructure. In addition, the chapter explains the installation processes and peeks into the underlying core.

  • Using BlazeDS as a Server-side Proxy (Chapter 3)—Flex applications can access data and web services from remote destinations if the remote destinations define an appropriate security definition, in a file called crossdomain.xml. The Flash player debars access from sources that lack such a security definition. However, BlazeDS provides server side proxy capabilities to access these sources. The focus here is on the role of BlazeDS as a server-side proxy.

  • Remoting between Flex and POJOs (Chapter 4)—This chapter illustrates the details of remote procedure calls between Flex and Java objects and explains how objects can be streamed between the two using a binary protocol called AMF (Action Message Format).

  • Accessing Spring Beans (Chapter 5)—SpringSource, the makers of the Spring Framework, and Adobe, makers of Flex, combined efforts to create Spring BlazeDS that helps integrate Spring and Flex applications using BlazeDS effectively. This chapter covers the features of this new integration project.

  • Communicating Real-time via Messages (Chapter 6)—BlazeDS supports real-time messaging and data push. In this chapter I start with the essentials of messaging between Flex and Java and highlight the important aspects like AMF long polling and the JMS adapter.

  • Leveraging JPA and Hibernate with Flex (Chapter 7)—Hibernate is the most popular Java persistence framework and JPA is the standard that defines Java EE persistence architecture. Both the product (Hibernate) and the associated specification (JPA) bring benefits of Object relational mapping to the world of Java. This chapter explains how the same features can be extended to Flex applications using BlazeDS.

  • Testing and Debugging Flex and BlazeDS Applications (Chapter 8)—This chapter explains the nuts and bolts of logging, testing, and debugging Flex and BlazeDS applications.

  • Extending BlazeDS with Custom Adapters (Chapter 9)—BlazeDS is a great product off-the-shelf, but the most valuable aspect of its design is that it can be extended easily to adapt to varied server side resources. This chapter will explain the available API and the approach to creating, deploying and using custom adapters.

  • Making BlazeDS Applications Scalable (Chapter 10)—This chapter explains how you could scale BlazeDS using the concepts that involve clustering, data compression, data format optimization, robust connection, service orientation, caching, resource pooling, and workload distribution.

  • CRUD Applications and More (Chapter 11)—This chapter illustrates CRUD application generation using Flash Builder 4 beta. It also illustrates the use of Gas3 for automatic translation from Java to AS3 and auto-population of AS3 objects based on XML content that support XML schema definitions.

  • Introducing Flex 4 (Appendix)—The appendix introduces the fundamentals of Flex 4, the next version of the Flex framework. Currently, Flex 4 is in beta. It will be released only in early 2010. The appendix provides a sneak peek into what's brewing.

What You Need to Use This Book

This book requires that you have the following software installed on your machine:

  • JRE version 5 or above

  • Flex SDK version 3

  • BlazeDS version 3 or above

  • Flex Builder version 3 (not a necessity but convenient)

  • Flash Builder 4 beta (especially to follow along the directions in Chapter 11)

  • JBoss AS or Tomcat (when using Tomcat, please install an external JMS provider like ActiveMQ)

In addition, for specific chapters, you will need the following:

  • Spring BlazeDS

  • FlexMonkey

  • JMS provider (like ActiveMQ)

  • Hibernate

  • JGroups

  • Ruby and FunFX


To help you get the most from the text and keep track of what's happening, we've used a number of conventions throughout the book.

Boxes like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text.


Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.

As for styles in the text:

  • We highlight new terms and important words when we introduce them.

  • We show keyboard strokes like this: Ctrl+A.

  • We show file names, URLs, and code within the text like so:

  • We present code in two different ways:

    We use a monofont type with no highlighting for most code examples.
    We use gray highlighting to emphasize code that is of particular importance in
    the present context.

Source Code

As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is available for download at Once at the site, simply locate the book's title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book's detail page to obtain all the source code for the book.

Because many books have similar titles, you may find it easiest to search by ISBN; this book's ISBN is 978-0-470-46489-2.

Once you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at to see the code available for this book and all other Wrox books.


We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration and at the same time you will be helping us provide even higher quality information.

To find the errata page for this book, go to and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list including links to each book's errata is also available at

If you don't spot "your" error on the Book Errata page, go to and complete the form there to send us the error you have found. We'll check the information and, if appropriate, post a message to the book's errata page and fix the problem in subsequent editions of the book.

For author and peer discussion, join the P2P forums at The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

  1. Go to and click the Register link.

  2. Read the terms of use and click Agree.

  3. Complete the required information to join as well as any optional information you wish to provide and click Submit.

  4. You will receive an e-mail with information describing how to verify your account and complete the joining process.

You can read messages in the forums without joining P2P but in order to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint