RIA Integration: Bits and Pieces. Part 1.

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 ndash; 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 rdquo;.

That “s ” all there is to it. I “ve included “Part 1 rdquo; in the title of this blog, because hoping that this will become a series of writeups on integrating Flex and Java EE.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s