EJB and Flex Integration

I am currently writing a demonstrator application for MAX 2006, where I will be presenting on security. As part of my application I want to show the propagation of the user’s identity from the Web container, in which Flex executes, and the EJB container, where business logic could be executing. Rather than write a remote Java object that acts as a business delegate I have written an EJB factory for Flex that is now available for download on the Flex Exchange. The EJB factory allows Flex to call an EJB directly.

Many enterprise applications encapsulate their business logic in stateless session beans so it is executed in the EJB container. The benefits of such an architecture include pooling of EJBs, declarative transactions, declarative security and improved scalability through transparent clustering. In addition it allows the EJBs to be called from other clients, not just the web.

However, I would always advocate that you encapsulate your business logic in POJOs so it can be executed in any container, for example this flexibility means you can execute your POJOs in your Web container by calling them directly in Flex as remote objects or they can be wrapped in a stateless session beans to permit execution in the EJB container. This sort of approach can aid scalability where it is not always cost effective to invest in a mid-tier in the early stages of an application’s life – with success comes investment.

Download the ZIP from the Flex Exchange and follow the instructions in the README.txt to call EJBs from your Flex applications.