The Swiz and Mate projects have contribute a framework to help handle events. According to James Ward, a Flex evangelist for Adobe, there is still a large need for senior Flex developers. Learning Flex gives you marketable skills that will put you ahead of the competition. In general, developing enterprise web applications has been notoriously difficult.
Flex and BlazeDS provide not only higher-powered tools but are also easier to develop with. The increase in developer productivity allows organizations to get to market more quickly. Flex and Flash also create a more engaging user experience, which can increase traffic and conversion rates.
An ideal example of this is the Borders book store chain, which recently introduced a new website with a "Magic Shelf. Borders found that this greatly increased conversion rates: "Customers who use this Flash-driven interface—which allows visitors to view the covers of books, DVDs, and CDs—convert at about 62 percent higher than those who do not".
Most languages add support for building UIs as an afterthought. This was particularly true for Java with Swing. As a result, simple things in Swing—like wiring data—can be painful and require using Swing-specific data models. The largest problem with Swing is that you have to dig very deep into the application programming interface API to be productive. Flex is the exact opposite: It was designed from the ground up for building web UIs.
Data binding, event handling, component layout, and other, common UI development techniques are built into the language, which allows you to be productive even when you know very little about the language.
You can develop with the existing tools used to develop Java. Flex provides a stateful environment in which data is loaded from the client. The programming model is more like developing a desktop client than Hypertext Markup Language HTML programming, which makes the programming model feel familiar to anyone who has done Java Swing programming.
This combination makes programming Flex similar to programming with Java, because you can use the familiar object-oriented concepts. An ideal way to set up your development environment is to have the Flex application built right in your web deployment directory. That way, you do not need to re-deploy your application after every build: A simple browser refresh reflects the latest changes.
Developing with Flex and BlazeDS is fairly productive as a result. For this article, I used the binary distribution, which comes as a web archive WAR , to show how you can deploy to any application server.
Otherwise, you can extract the Java archive JAR files and use them in your project. This example uses BlazeDS with an existing project—a simple soda dispenser. You just need to add the JAR files to your project, then you can use BlazeDS from within the application, which allows you to deploy it anywhere you can deploy the application. For the soda example, assume that you want to expose your existing soda service so that remote Flex applications can connect to it.
The basic steps to set up BlazeDS with an existing application are:. After you set up BlazeDS, you need to add your soda service to the BlazeDS remoting configuration file, which allows the soda service to be called from a Flex client. You make this addition by defining a destination and one or more channels to transport the data. The basic AMF Channel is defined in the services.
Use this definition to identify your destination in remoting-config. By defining endpoints in the remoting configuration file, you can call any basic Java service from a Flex client. To pass your Java data model to your Flex client, define a mapping between the two in your ActionScript class:. The Flex client in the sample shows how to call this Java service. The call returns a SodaModel , filled with your order:. Flex returns your results in the generic result variable, which you map into your SodaModel.
I won't go into the details here, but one tip is to specify services-config. If not, your Flex client will not be able to find the Java services. In the same manner, you can pass an object from the client back to the server. For example, you could pass the empty soda model back to the client.
Suppose you decide that you want to add special logging anytime the soda service is called. You can extend the standard Java adaptor to add logging. In this method, you can see the incoming operation and the destination for the call. You can use this simple hook for other things, as well—for example, timing how long calls to the server are taking. You can make this call in several different ways, such as through the Browser Manager and flashVars. For example, suppose you wanted to pass your user name and the type of soda you want to order in from your HTML page.
Then, in your Flex application, you can read these variables by getting the application parameters:. An open standard, AMF is extremely fast. James Ward put together a sample that shows a comparison with other remoting solutions. Being able to call BlazeDS this way is extremely useful for unit testing and load testing. Adobe and Spring have teamed up to bring closer integration between the two projects, and the initial release of the Spring—BlazeDS integration shows a lot of promise. By allowing a Spring Bean to become a remote service, duplicate configuration files will be eliminated.
For more information, visit the project's home page. With BlazeDS being open source and based in Java, it is an ideal choice for new and existing Java server projects. Java developers new to Flex and BlazeDS will find the development process highly productive and easy to learn. Flex with BlazeDS is also an ideal choice for large-scale Java enterprise applications. In a previous project, my team wrote an application that contained over 50 different screens and would regularly transfer several thousand rows of data between the server and client.
This type of application would have been nearly impossible using traditional Ajax technologies. Channels are grouped together as channel sets. The flex application tried to connect to the first channel in case if it is not success it goes to next channel in the channel set.
Channels are the low level ends of client application. They are mainly responsible for connecting flex application to the end point of blazeDS on server side. Selection of channels in channel set depends on various factors like type of application we are constructing.
Server - The BlazeDS server is contained in a web application. We will have a move over the server side objects. End Point — BlazeDS end points are inside the servlet container. Client applications use channels to communicate with endpoints. It is very important that message format should be identical in communication. MessageBorkerServlet- MessageBrokerServlet extracts the message from the request once the request is processed at end point and identifies the service it is requesting and sends the message to the service.
Services and Destinations — services are the targets for the client applications where as destinations are services configured in some way.
Consider when we work on a remoting application , we use a RemoteObject to communicate with the Remoting Service.
The mapping between client-side Flex components and BlazeDS services is as follows:. You can configure services and their destinations in the services-config.
Adapters — the last one in the chain are adapters. When a message arrives at the correct destination, it is passed to an adapter that fulfills the request either locally or by contacting a backend system or a remote server such as a JMS server.
All communication between flex and java are done using messages of different types. In other situations, you do not write code for constructing and sending messages. For example, you simply use a RemoteObject component to call the remote method from the Flex application.
In response it receives an AcknowledgeMessage from the server. Sometimes you must create a message to send to the server. For example, you could send a message by creating an AsyncMessage and passing it to a Producer. In this pattern, the Producer publishes a message to a destination defined on the BlazeDS server.
A Flex application uses the client-side messaging API to send messages to, and receive messages from, a destination defined by the server.
BlazeDS lets you access many different persistent data stores and databases including JMS, and other data persistence mechanisms.
A service adapter is responsible for updating the persistent data store on the server in a manner appropriate to the specific data store type.
The adapter architecture is customizable to let you integrate with any type of messaging or back-end persistence system. A Flex client makes a request over a channel and the request is routed to an endpoint on the BlazeDS server. From the endpoint, the request is routed through a chain of Java objects that includes the MessageBroker object, a service object, a destination object, and finally an adapter object.
The adapter fulfills the request either locally, or by contacting a backend system or a remote server such as Java Message Service JMS server. Applications using AMF can eliminate an unnecessary data abstraction layer and communicate more efficiently with servers. Skip to Content. Abdulbasit Gulsen. September 22, 2 minute read.
0コメント