This article lists the reasons why 13 Java programmers should learn flex and blazeds, and discusses why flex and blazeds are one of the best combinations for developing Ria. This combination is one of the best options for highly interactive websites and enterprise applications with Java as the backend. More importantly, this combination can bring both high ROI for developers and enterprises ).
When explaining how Java programmers should learn the 13 Reasons for blazeds, I used a hypothetical soda distribution system to demonstrate how to transform existing Java programs into Ria applications. Through this example, I will also explain different usage of blazeds in existing Java applications or new Java applications.
Reason 1: Open Source
The core of the Flex software development kit (SDK) is an open-source framework designed to develop and maintain Ria applications with the same interfaces in different browsers and operating systems. The release of flex adopts the Mozilla Public License ). The compiled flex application runs on the Adobe Flash Platform.
Blazeds is a connector that connects flex and Java and is an open source technology for remote calls and message transmission. On the Java application server, it exists as a servlet, so it can be used in any standard Java network application. Blazeds is released with the lgpl (lesser GNU Public License) Public License. At the same time as the release of blazeds, Adobe also published the AMF (ActionScript Message format) Specification Description. The blazeds, Java, and flex clients communicate with each other in this concise binary format.
Reason 2: Comprehensive Community Support
The flex community is very active and has contributed a lot to projects. Flex.org, an Adobe Site with community news, has contributed to new communities almost every day. Yahoo! The number of members of the Flex user group on exceeds 11000.
For example, the flexlib project on Google Code has submitted a large number of open-source UI components. The swiz and mate projects contributed to the framework for optimizing event processing, and gorilla logic contributed to the flex monkeym project for automated UI testing.
Reason 3: broad employment prospects
According to Adobe's Flex evangelist James Ward, flex senior developers have a huge market demand and learning FLEX can give you highly competitive development skills.
Reason 4: Higher Business Benefits
In general, developing enterprise web applications is not a simple task, which is basically a well-known fact. Flex and blazeds provide not only powerful development tools, but also relatively simple development technologies. Development efficiency can be greatly improved, so products can be quickly pushed to the market. The user experience brought by flex and flash is also more attractive, and it is helpful for increasing traffic and improving the user conversion rate (conversion rate.
A classic example is the borders bookstore chain. They recently released a new website with "Magic bookshelves", which uses flash interfaces to simulate the Book Borrowing Process. Borders found that this simulated borrowing feature clearly mentions the user conversion rate: "With this flash-driven interface, users can browse the covers of books, DVDs, and CD, the user conversion rate is 62% higher than that of other websites without this function ".
Reason 5: Flex is the first language specifically designed to create a UI
Most languages do not immediately design their UI support. The implementation of the swing package in Java is just a good proof. That is why many simple actions such as bundling data are very painful to implement in swing. The biggest problem with swing is that you must be familiar with its APIs to improve development efficiency.
Instead, Flex is designed specifically for creating web UIS. As Bruce Eckel said, Flex is the first domain-specific language (DSL) for UI development ). Using flex to build a UI is much easier than other technologies such as JSP, JSF, and swing. The language is a combination of data binding, event processing, control layout, and other common UI development skills. Even if you do not have a deep understanding of the language, the development efficiency will not be affected.
Reason 6: The programming style is similar to that of Java
You can continue to use existing Java development tools to develop flex applications. Of course, you can also use the free command line tool included in the SDK, Adobe Flex Builder (an Eclipse plug-in), or the latest intellij idea 8.
Flex provides a stateful environment in which data is loaded from the client. This programming mode is more like developing desktop clients than HTML programming. This style should be quite familiar to developers who have used Java swing programming.
Flex is a combination of mxml (similar to the xml ui Markup Language) and Adobe ActionScript (Object-Oriented parsing language. In view of this combination, flex programming is very similar to Java, because both use well-known object-oriented concepts.
The ideal development environment is to create a flex application in a web deployment folder. In this way, you do not need to redeploy the application after each update, as long as you refresh the application in the browser. After developing with flex and blazeds, the development efficiency is definitely much higher than before.
Reason 7: blazeds can run on any Java Application Server
Currently, multiple versions of blazeds are released. The turnkey version also contains Apache Tomcat configured for blazeds. In this article, I am using a binary release version, which contains a war to demonstrate how to deploy an application to various application servers. Without this war, you can also extract the JAR file from it and put it in your project. For more information about how to install blazeds, see the Wiki of blazeds.
Here is a simple example, for example, to apply blazeds to an existing simple soda distribution system. You only need to put the JAR file in the project folder, and then you can directly use blazeds in the application to deploy anywhere the application can be deployed.
To add blazeds to a project, you only need to complete the following two steps:
- Decompress the content of the blazeds war file: jar xvf blazeds. War.
- Copy all jar files to the project's lib Folder: CP-r WEB-INF/lib/sodasample.
Reason 8: it can be used in existing Java applications
For example, if you want to extend the developed service to allow other flex applications to remotely call this simple soda distribution system. The basic steps for configuring blazeds in a ready-made application are as follows:
- Modify
WEB-INF/flex
The configuration file blazeds under the folder
- Defined in the web. xml file corresponding to the application
MessageBrokerServlet
And session listener
After configuring blazeds, add the soda distribution service to the blazeds remote configuration file, and the flex client can call the service remotely. This process transfers data by defining a destination, one or more channels in the configuration file. The basic AMF channel is defined in the services. xml file. The following configuration defines the destination in the remoting-config.xml ):
<destination id="sodaService" channels="my-amf"><properties> <source>com.gorillalogic.sodaSample.SodaService</source></properties></destination>
By defining an endpoint in the remote call configuration file, the flex client can call any basic java service.
To transfer the Java data model to the flex client, you only need to define the ing between the two in the ActionScript class:
[Bindable][RemoteClass(alias="com.gorillalogic.sodaSample.SodaModel")]
This code tells flex to remotely call the service to returnSodaModel
Ing it to the flexSodaModel
. In this example, the flex client shows how to call this Java service. Call to return a reserved informationSodaModel
:
public function callSodaService():void {var sodaType:String = type.text;var sodaCount:int = parseInt(cnt.text);var flag:Boolean = preOpen.selected;remoteObject.getSoda(sodaType, sodaCount, flag);}private function resultHandler(event:ResultEvent):void { var sodaModel:SodaModel = event.result as SodaModel;}
The result returned by Flex is a common result variable, which can be directly mapped to yourSodaModel
. I will not discuss how to implement ing in depth here, but it is worth mentioning that it should be declared in the compilation configuration.services-config.xml
Path, such:
-locale en_US -services=/nsource/sodaSample/web/WEB-INF/flex/services-config.xml -context-root /
If you do not add this path, your flex client will not find the Java service. In the same way, you can transmit an object from the client to the server. For example, you can send an empty soda model back to the server (Review note: In the original article, the client is written, and the server is determined based on the context ).
Reason 9: Java can be used to expand and modify the blazeds
If you want to add special logs to record the calls of the soda provisioning service, you can extend the standard Java adapter to add the log function.
First, add an inheritedJavaAdapter
Java class:
import flex.messaging.services.remoting.adapters.JavaAdapter.public class TimingJavaAdapter extends JavaAdapter {
Second, reload the invoke () method:
Public object invoke (message) {<br/> remotingmessage = (remotingmessage) message; <br/> string operation = remotingmessage. getoperation (); <br/> string Destination = remotingmessage. getdestination (); </P> <p> logger.info ("calling" + operation + "on destination" + Destination); <br/> Object Data = super. invoke (Message); <br/> return data; <br/>}< br/>In this method, you can see the operation after the call and the call destination (destination ). This method can also be used to handle other problems, such as how long it takes to record the call sent to the server.
Reason 10: HTML and JSP can also call blazeds
You can also call blazeds from HTML and JSP. This call can be implemented in several different ways, such as through browser manager orfflashVars
F. The flex application can readfflashVars
F.
For example, if you want to use the HTML page to send your user name and prepare a predetermined soda type, you can set it on the HTML page as follows:flashVars
:
<object id='SodaSample' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='100%' width='100%'> <param name='src' value='SodaSample.swf'/> <param name='flashVars' value='username=ryan&type=coke'/> <embed name='mySwf' src='SodaSample.swf' pluginspage='http://www.adobe.com/go/getflashplayer' height='100%' width='100%' flashVars='username=ryan&type=coke'/></object>
Then, in the flex application, you can obtain these variables by reading application parameters:
var username:String;if (Application.application.parameters.hasOwnProperty("username")) {username = Application.application.parameters.username;}
Reason 11: the data transmission performance of flex and blazeds is far better than that of other Ajax Solutions
Currently, the AMF binary protocol is used for Remote Procedure Call (RPC) by default. AMF is an open standard and fast. James Ward has compared Multiple Remote Call solutions. Although other Ajax technologies, such as Dojo, have been able to process hundreds of rows of data quickly, using Flex and blazeds can easily handle thousands of rows. (Refer to James Ward's census to evaluate various Ria data loading technologies .)
Reason 12: the Java client can directly call blazeds
The latest release of blazeds contains a Java AMF class, through which you can directly call the blazeds server on the Java client. For unit testing and load testing, this call method of blazeds is very practical.
Reason 13: spring can also be used.
Adobe and spring work together to integrate projects on both sides. The first spring-blazeds integrated version they released demonstrates their painstaking efforts. Spring bean can be called remotely, so many duplicate configuration files can be cleared. For more information, refer to the home page of the project.
Conclusion
The open-source blazeds is created on the basis of Java. It is a good choice for both new and existing Java Server projects. The flex and blazeds technologies provide high-performance remote communication and support object ing between flex and Java. Therefore, they are ideal for RIA development. New developers of flex and blazeds, if they were once Java developers, will find that the entire development process is very efficient and easy to grasp.
Flex plus blazeds is an ideal choice for developing large-scale Java Enterprise applications. In the previous project developed by our group, the application involves more than 50 different interfaces, and thousands of lines of code need to be transmitted regularly between the server and the client. Such applications can hardly be implemented through the traditional Ajax technology. However, after the introduction of flex and blazeds, we released the first version within the year. See, this is what makes dynamic combinations extraordinary for your application development project.