By Yakov Fain | Article Rating: |
|
December 16, 2010 07:00 AM EST | Reads: |
8,217 |

There are many ways to have various software components to communicate in Java EE enterprise architecture. The same is applicable for integrating rich Internet Applications written in Adobe Flex and Java EE systems. Let’s consider the following scenario:
An application A is being developed using Flex-BlazeDS-Java, and it needs to integrate with a third-party Java-based Web application B, where the users must register, otherwise they can’t continue using the application A.
Of course, to implement this scenario you can engage some of the business process management software packages that will allow you to describe and configure the workflow with minimum or no coding. But the less moving parts are used in the architecture the better. Here’s the pretty simple way to implement our scenario.
Step 1. When the user presses the button on Flex view, the code is being executed inside the virtual machine – Flash Player, which in turn is sitting inside HTML wrapper. So the first goal is to make a call from inside the Flash Player to the outside world. Using the ActionScript class ExternalInterface you can map the internal function, say registerUserAS() to the wrapper’s JavaScript function registerUserJS(). You have to write both of these functions yourself.
Step 2. The JavaScript function registerUserJS() opens the URL of the application B in a separate Web browser window, where the user registers as required by the application B.
Step 3. In the application A, develop and deploy Java servlet, say RegistrationCompleteServlet that can be called by the application B when the user successfully completed the registration. During this call, the application B will pass to the servlet a Data Transfer Object RegistrationInfoDTO, with all required registration details.
Step 4. The RegistrationCompleteServlet and BlazeDS are collocated in the same Java Servlet container(e..g. GlassFish, Tomcat, et al). The RegistrationCompleteServlet initiates a push of the RegistrationInfoDTO to the BlazeDS destination RegistrationDest with the routing to the proper client. How to push the data to the client over the AMF protocol is described in our book Enterprise Development with Flex.
Step 5. Almost forgot to mention that during the startup, our Flex application has created a Consumer subscribed to the messages from the destination RegistrationDest. As soon as the RegistrationInfoDTO is published to this destination, Flex client will receive it and let the user into the next view with a nice greeting, “Thank you, Yakov for registering. Your credit card information has been validated”.
That’s’ all there is to it. I’ve included “Part 1” in the title of this blog, because hoping that this will become a series of writeups on integrating Flex and Java EE.
Published December 16, 2010 Reads 8,217
Copyright © 2010 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Yakov Fain
Yakov Fain is a Java Champion and a co-founder of the IT consultancy Farata Systems and the product company SuranceBay. He wrote a thousand blogs (http://yakovfain.com) and several books about software development. Yakov authored and co-authored such books as "Angular 2 Development with TypeScript", "Java 24-Hour Trainer", and "Enterprise Web Development". His Twitter tag is @yfain
- Secrets Of The Masters: Core Java Job Interview Questions
- A Cup of AJAX? Nay, Just Regular Java Please
- Rich Internet Applications with Adobe Flex 2 and Java
- Teaching Kids Programming: Even Younger Kids Can Learn Java
- Reading Data from the Internet
- Java Basics: Lesson 11, Java Packages and Imports (Live Video Education)
- Java Basics: Introduction to Java Threads, Part 1
- Java Serialization
- Are You Using Abstract Classes, Polymorphism, and Interfaces?
- SYS-CON Webcast: Eclipse IDE for Students, Useful Eclipse Tips & Tricks