The Artima Developer Community
Sponsored Link

Java Community News
Using Flex with Spring

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Using Flex with Spring Posted: Oct 19, 2006 12:05 PM
Reply to this message Reply
Summary
In a recent tutorial, Adobe's Christophe Coenraets gives a Java-friendly introduction to Flex, and shows how Flex can serve as a rich-client front-end to a Spring-based Java application.
Advertisement

Earlier this year, Adobe released Flex 2 with the hope of providing an easy-to-use alternative to do-it-yourself JavaScript-based Ajax clients. In an interview with Artima, Adobe chief Flex evangelist Christophe Coenraets bemoaned the limitation of a typical Ajax client to invoking only XML-based back-end services, and pointed to a Flex client's ability to communicate with a greater variety of back-end interfaces:

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...

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... 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.

Coenraets recently expatiated upon Flex's ability to invoke a large variety of enterprise back-ends in an article, Using Flex with Spring. He points to four different ways a Flex client can converse with a back-end service:

  • You can use the HTTPService component to send HTTP requests to a server, and consume the response... The Flex HTTPService is similar to the XMLHttpRequest component available in Ajax.
  • You can use the WebService component to invoke SOAP-based web services.
  • You can use the RemoteObject component to directly invoke methods of Java objects deployed in your application server, and consume the return value...
  • In addition to the RPC-type services described above, the Flex Data Management Services provide a ... virtually code-free approach to synchronize data between the client application and the middle-tier.

In the article, Coenraets focuses on the last two methods, and illustrates how to take advantage of Flex's ability to invoke remote Java methods on a Spring back-end:

The whole idea behind Spring IoC is to let the container instantiate components (and inject their dependencies). By default, however, components accessed remotely by a Flex client are instantiated by Flex destinations at the server-side. The key to the Flex/Spring integration is therefore to configure the Flex destinations to let the Spring container take care of instantiating Spring beans.

The Flex Data Services support the concept of factory to enable this type of custom component instantiation. The role of a factory is simply to provide ready-to-use instances of components to a Flex destination (instead of letting the Flex destination instantiate these components itself).

Coenraets' article also provides a good introduction to Flex's programming model to Java developers:

The Flex programming model is made of...

  • ActionScript, an ECMAScript compliant, object-oriented programming model. With some syntactical differences, ActionScript looks and feels similar to Java, and supports the same object-oriented constructs: packages, classes, inheritance, interfaces, strong (but also dynamic) typing etc.
  • MXML: an XML-based language that provides an abstraction on top of ActionScript, and allows parts of an application (typically the View) to be built declaratively.
  • An extensive set of class libraries. The online API documentation is available here in a Javadoc-like format.

The Flex source code (.mxml and .as files) is compiled into Flash bytecode (.swf) that is executed at the client-side by the Flash virtual machine using a Just-In-Time compiler.

Coenraets pointed out in his comments to Artima that Flex's EcmaScript-like language provides a segue into the next generation of JavaScript, EcmaScript 4:

Many developers coming to Ajax from Java are often surprised when they start looking for classes and Java-like OO concepts in JavaScript... JavaScript, as it is delivered today in Web browsers, has very different notions of objects... However, EcmaScript 4, which effectively defines the latest version of Javascript, provides classes, interfaces, and a development experience much more familiar to a Java developer.

What do you consider as the biggest challenge today in developing rich interfaces to an enterprise application? The UI? Communication between client and server? Keeping data in sync between client and server data models? To what extent do you believe Flex helps solve those challenges?

Topic: Using Flex with Spring Previous Topic   Next Topic Topic: Clustering with JBoss Messaging 1.2


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us