Adobe just released Flex 2. In an interview with Artima, Adobe's Christophe Coenraets explains how server-side, as well as client-side, developers can benefit from Flex 2, and why Flex 2 may ease the way into Ajax development as well.
Adobe released Flex 2, the latest generation of its application development and runtime technology targeting the Flash platform. The new release includes the freely available Flex SDK as well as FlexBuilder 2, a development environment built on Eclipse.
In addition, Adobe complemented its client-side offering with server-side technologies to provide a more seamless development and deployment model. The new server-side component, Flex Data Service 2, provides data synchronization capabilities between the client and server sides of an object model, and includes a Hibernate plug-in.
"Flex is a framework for creating all kinds of rich Internet applications targeting the Flash player," said Adobe Technical Evangelist James Ward in an interview with Artima at JavaOne 2006. "We sort of hijacked the browser and Flash Player to create applications that not only take advantage of, but also go beyond Flash’ traditional roles in multimedia."
Ward noted that "Flash Player is deployed in 98% of the PCs world-wide, and new versions of Flash Player are adopted much faster than any other platform or browser... Over 80% of Flash Players are upgraded to the latest version within about 9 months of a new release."
The latest Flash Player is version 9, the target platform for Flex 2 applications. Flash Player 9 is currently available for Windows and the Mac, with a Linux version in the works.
"We see [Flex] as a better view in the traditional MVC model" than offered by other solutions, observed Coenraets, and pointed to support for SOA-based enterprise applications as one example. "Developers often think that when they’re done with the server-side of an SOA application, they’re done building [that] application. But if you [at that point] tell your client-side developers [to] just access the new Web service, client-side developers will come back to say that their toolkits don’t support easy access to that Web service."
One reason is that few client-side toolkits provide built-in capabilities to invoke SOAP-based Web services, and support instead the more general task of allowing XML document transport over HTTP. "As a client-side developer, you will have to go back to your server-side colleagues and have them develop some sort of an adapter to adapt a Web service [interface] to the user interface’s requirements. But the capabilities of the client should not have to dictate the way [an SOA] application exposes data on the server-side," adds Coenraets.
Such adapters are often necessary whether the client is JSP or Ajax. "With an Ajax client, you can connect to a back-end to [receive and send] mostly XML over HTTP. That means that on the server, you have to transform output [from the service interfaces] to an XML format suitable to the client."
"We think of Flex as a 'better' view because via Flex you can directly invoke SOAP-based Web services. In addition, you can expose a POJO as a service, and invoke methods on that POJO from a Flex client across the network." Such remote method invocations take place via Adobe’s Action Message Format (AMF) binary protocol.
Another challenge that Flex aims to solve is what Coenraets called the problem of distributed MVC. "When you think of MVC, you mostly think of the separation of model, view, an controller in the user interface or on the server... However, in a rich-client application, you often have a distributed data model because the server and client each has copies of objects." Those copies can evolve separately if, for instance, users from separate clients update the state of a business object. Not only do those object states have to be managed by both client and server, but they also have to be periodically synchronized.
Flex 2 attempts to solve the distributed MVC problem with a product Adobe calls the Flex Data Server. "The Flex Data Server is a data synchronization product," says Coenraets. "As the client retrieves data from the server, and the user makes changes to that data, the [Flex] client is smart enough to track changes occurring in the client. The client can notify the middle tier automatically of those changes, so [as a developer] you don’t have worry about keeping those object states in sync." The Flex Data Server includes a Hibernate adapter that persists changes arriving from a client to a database via the popular O/R mapper.
In our interview with Coenraets, we noted that the ability to use the same object model on both the client and server shares some of the goals of the JBoss Seam project (see Gavin King Explains JBoss Seam.) "It may be that we’re all seeing the same problem," noted Coenraets. "When you introduce a real [object] model on the client, you are going to have one additional layer in your application" that you must deal with.
Flex’s initial audience was Java developers, and with Flex 2 Adobe may be taking a page from Sun’s Java developer playbook, too. Coenraets pointed out that the Flex 2 SDK, which includes the Flex libraries, runtime, a compiler, and a debugger, is now available as a free download, similar to how Sun and other JVM vendors make available their Java developer kits gratis.
For a more streamlined developer experience, Adobe released FlexBuilder 2, an Eclipse-based payware IDE. "We had a Flex IDE based on DreamWeaver, but developers told us they wanted something built on top of Eclipse... FlexBuilder 2 has a deep integration with other technologies that exist in Eclipse. For instance, you can set breakpoints in your Flex code as as well as your server-side Java code, and thereby created an integrated debugging session."
Flex is a much better way to build web applications. You can take advantage of features like: - Free SDK & non-clustered FDS - Consistent & Ubiquitous Cross OS / Browser Runtime - High Performance VM (JIT Compiler) - Great programming model (ECMAScript, E4X, Strong & Dynamic Typing, Component Model, Object Oriented) - Real debugger (step through, stack traces, breakpoints, watches, etc) - Beautiful / Functional out of the box components