13 Reasons for Java programmers to learn flex and blazeds

Source: Internet
Author: User
Tags apache tomcat

This article outlines the 13 Reasons Why Java programmers shocould learn flex and blazeds. it talks about why flex with blazeds is one of the best choices for developing rich Internet applications (RIAs)-from highly interactive websites to enterprise applications with Java back ends. most importantly, it shows the high return on investment (ROI) that this combination provides, both for developers and for each ISES.

 

Create enterprise-class rich Internet applications with Adobe Flex, a cornerstone of the Adobe Flash Platform, and springsource.

In outlining the 13 Reasons Why Java programmers shoshould learn blazeds, I use a fictitious soda dispenser to show how to morph an existing Java program into an RIA. through the example, I explain the different ways you can use blazeds, either with your existing Java applications or with new Java applications.

Reason 1: It's open source

The core flex software development kit (SDK) is an open source framework used for building and maintaining RIAs that look and feel the same authentication SS different browsers and operating systems. flex is released under the Mozilla Public License. compiled flex applications run in the proprietary Adobe Flash Platform.

For connecting flex to Java, blazeds is an open source technology for remoting and messaging. it runs on Java application servers as a servlet, allowing you to use it in any standard Java Web application. blazeds is licensed under the lesser GNU Public License (lgpl ). along with the release of blazeds, Adobe published The ActionScript Message format (AMF) specification, which allows blzeds and Java to communicate with the flex client using a compact binary format.

Reason 2: it has great Community Support

Flex has a very active community, with a lot of community-contributed projects. flex.org, an Adobe Site with community news, sees almost daily community contributions, and the flex Users Group on Yahoo! Has over 11,000 members.

For example, the flexlib project on Google Code has contributed a large amount of open source user interface (UI) components. the swiz and mate projects have contribute a framework to help handle events. and gorilla logic has contributed flex monkey for automated UI testing.

Reason 3: You can have a job in another six months

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.

Reason 4: Higher Business ROI

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. 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. "This site uses a flash interface to simulate the experience of browsing books. 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 ".

Reason 5: Flex was the first language designed for creating UIS

Most versions ages add support for building UIS as an afterthought. this was particle ly 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. as Bruce Eckel likes to say, Flex is the first domain-specific language (DSL) for UI development. so, it's much easier to create UIS In Flex than in other technologies, such as assumerver pages (JSP), assumerver faces (JSF), and swing. 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.

Reason 6: it has a programming model similar to Java

You can develop with the existing tools used to develop Java. you can also develop flex applications with the free command-line tools embedded in the SDK, with Adobe Flex Builder (an Eclipse plug-in), or most recently, with intellij idea 8.

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.

Flex is programmed using a combination of mxml, a UI Markup Language similar to Extensible Markup Language (XML), and Adobe ActionScript, an object-oriented scripting language. 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.

Reason 7: blazeds runs in any Java Application Server

Multiple versions of blazeds are available, including a turnkey version that includes des a version of Apache Tomcat configured with blazeds. 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. visit the blazeds wiki for information about the various options for installing blazeds.

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.

To add blazeds to your project, complete these steps:

  1. Extract the contents of the blazeds war file jar xvf blazeds. War.
  2. Copy the jar files to your project lib directory: CP-r WEB-INF/lib/sodasample.
Reason 8: You can use it with existing Java applications

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:

  1. Edit the blazeds configuration files in the WEB-INF/flex directory.
  2. DefineMessageBrokerServletAnd a session listener in the Application Web. xml.

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. XML file. use this definition to identify your destination in remoting-config.xml:

<destination id="sodaService" channels="my-amf"><properties><source>com.gorillalogic.sodaSample.SodaService</source></properties></destination>

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:

[Bindable][RemoteClass(alias="com.gorillalogic.sodaSample.SodaModel")]

This code tells flex that when the results from a remote service call return your Java sodamodel, map it to your flexSodaModel. The flex client in the sample shows how to call this Java service. The call returnsSodaModel, Filled with your order:

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;}

Flex returns your results in the genericresultVariable, which you map into yourSodaModel. I won't go into the details here, but one tip is to specify services-config.xml In the compiler configuration, like so:

-locale en_US -services=/nsource/sodaSample/web/WEB-INF/flex/services-config.xml -context-root /

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 can pass the empty soda model back to the client.

Reason 9: You can extend blazeds and modify it with Java

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.

First, add a Java class that extendsJavaAdapter:

import flex.messaging.services.remoting.adapters.JavaAdapter.public class TimingJavaAdapter extends JavaAdapter  {

Then, overload the invoke () method:

public Object invoke(Message message) {   RemotingMessage remotingMessage = (RemotingMessage) message;   String operation = remotingMessage.getOperation();   String destination = remotingMessage.getDestination();Logger.info("calling " + operation + " on destination " + destination);Object data = super.invoke(message);return data;}

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 callto the server are taking.

Reason 10: You can call blazeds from HTML and JSP

You can make this call in several different ways, such as through the browser manager andflashVars.flashVarsCan be set by the HTML page, then read by the flex application.

For example, suppose you wanted to pass your user name and the type of soda you want to order in from your HTML page. You cocould setflashVarsIn your HTML page like so:

<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 your flex application, you can read these variables by getting the application parameters:

var username:String;if (Application.application.parameters.hasOwnProperty("username")) {username = Application.application.parameters.username;}
Reason 11: Flex and blazeds data transfer outperform other Ajax Solutions

By default, all the Remote Procedure CILS (rpcs) in use employ the AMF binary protocol. an open standard, AMF is extremely fast. james Ward put together a sample that shows a comparison with other remoting solutions. although other Asynchronous JavaScript and XML (Ajax) solutions like dojo struggle with a couple of hundred rows, flex with blazeds can easily handle thousands of rows. (see James Ward's census for a benchmark of different Ria data loading technologies .)

Reason 12: You can call blazeds directly from Java clients

The latest release of blazeds extends des a Java AMF class that you can use to make a Java client call the blazeds server. being able to call blazeds this way is extremely useful for unit testing and load testing.

Reason 13: It works with spring

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.

Conclusion

With blazeds being open source and based in Java, it is an ideal choice for new and existing Java Server projects. with high-performance remote communication and object mapping between flex and Java, the flex and blazeds technologies are an ideal choice for RIA development. 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 wocould regularly transfer several thousand rows of data between the server and client. this type of application wowould have been nearly impossible using traditional Ajax technologies. with flex and blazeds, we where able to release an initial version in under a year. see what this dynamic duo can do for your application-development projects.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.