flex and java integration
DESCRIPTION
Flex And Java IntegrationTRANSCRIPT
Flex and Java Integration
Adobe Flex Meet August09
Ravi Sharma
Flex and Java
Java technology can be used to create both client- and server-side applications.
While the server-side implementation is widely accepted, the browser-based client-side applications have been less successful because the file sizes are large and the installation is bulky.
Flex is a great solution for Java developers because it
enables them to utilize the power of Java servers while creating expressive and interactive interfaces.
Application Flow
Different techniques for accessing existing web application.
HttpServices
WebServices
RemoteObject
Additional Techniques
Direct socket connections:
Flex client can also open a direct socket connection to network services. This is an important tool mainly for streaming media-type applications.
RTMP(Real Time Messaging Protocol) is primarily used to stream data, audio, and video over the Internet to Flash Player. RTMP maintains a persistent connection with an endpoint and allows real-time communication.
Technology for integration
BlazeDS LCDS
WebORB AMFPhp
BlazeDS Overview
BlazeDS provides a set of services that lets you connect a client-side application to server-side data, and pass data
among multiple clients connected to the server.BlazeDS implements real-time messaging between clients.
A BlazeDS application consists of two parts: a client-side application and a server-side J2EE web application.
The client-side application
A BlazeDS client application is typically an Adobe Flex application.
Flex applications use Flex components to communicate with the BlazeDS server, including the RemoteObject, HTTPService, WebService, Producer, and Consumer components.
All these components are part of the Flex Software Development Kit (SDK).
The BlazeDS server
The BlazeDS server runs in a J2EE application server.
Configure an existing J2EE web application to support BlazeDS:-
1. Add the BlazeDS JAR files and dependent JAR files to the WEB-INF/lib directory.
2. Edit the BlazeDS configuration files in the WEB-INF/flex directory.
3. Define MessageBrokerServlet in WEB-INF/web.xml.
Key Services of BlazeDS
The Remoting Service allows our Flex application to directly invoke methods of Java object deployed in our application server.
The Message Service provides a publish/subscribe infrastructure that allows our Flex application to publish messages and subscribe to a messaging destination. That enabling the development of real-time data push and collaborative application.
Contd…
The Proxy Services allows our Flex application to make cross-domain service requests in a secure manner. It allows our Flex application to access a services available on a different domain.
Without having to deploy a crossdomain policy file on the target domain.
Now
Take a look of
Demo Application
Config file setting
Finally, you must add the class destination in WEB-INF/flex/remoting-config.xml,
<destination id="myJavaClass" > <properties> <source>MyRPC</source> <scope>application</scope> </properties></destination>
Description of Config The destination id attribute is referenced when you
invoke the class from Flex.
The <source> node points to the fully qualified name of the Java class. i.e. packageName.className
The <scope> node determines when the Java class will be instantiated, Application means the class will be instantiated once
during servlet initialization. Session means the class is instantiated for each user
session. Request resets the class for each invocation.
Client Side Coding
<mx:RemoteObject id="myService"
destination="myJavaClass">
<mx:Button
click="myService.sayHello()" />
<mx:Label text="{myService.sayHello.lastResult}"
/>
QA SessionN
Thanks