没有合适的资源?快使用搜索试试~ 我知道了~
flex dataservice
4星 · 超过85%的资源 需积分: 9 179 下载量 14 浏览量
2009-07-28
18:00:55
上传
评论 2
收藏 1.77MB PDF 举报
温馨提示
试读
44页
flex和java 集成,主要讲述flex获取java的数据服务,包括web service,http,remoteobject等。
资源推荐
资源详情
资源评论
So far, you know how to combine Flex and Java using HTTP and web services. The last
chapter surveyed a bunch of alternative mechanisms to achieve this. Most of these
mechanisms involve loosely coupled text-based data interchange. Most of them
interact by pulling data. Only one of them, Hessian, transmits binary data. Only one,
Hessian again (with additional infrastructure powered by the new Java IO), allows
data push.
Now, we delve into more tightly coupled scenarios and efficient binary data transmis-
sion using AMF (Action Message Format). The AMF specification can be accessed
online at http://opensource.adobe.com. This chapter looks at both pull- and push-
based interactions—using data services and media servers. Adobe offers two alterna-
tives for data services—the commercial LifeCycle Data Services (LCDS) and the open
source BlazeDS—and it offers a suite of products for media servers: Flash Media Server
(FMS) products. There are a few open source alternatives to these as well.
In this chapter, I will analyze these products in the context of their applicability to
rich, engaging enterprise-grade applications. Functionally they can be divided into
the following three topics:
Remoting and RPC
Messaging and data push
Media streaming
257
INTEGRATING VIA DATA AND MEDIA SERVICES
By Shashank Tiwari
Chapter 7
At this point of the book, remoting and RPC should be familiar territory, so let’s start there.
Remoting and RPC
Flex applications can access the Java server side using data services. They can access Java objects and
invoke remote methods on them. The Flex framework includes a client-side component called
RemoteObject. This object acts as a proxy for a data service destination on the server. When config-
ured properly, this object handle can be used to invoke RPCs. Before we get into the nitty-gritty of this
object and destination configuration, let’s step back and look at the data services architecture.
Data services architecture
Figure 7-1 is a pictorial summary of the data services architecture. The view is biased to highlight the
functional elements. It includes technical aspects but skips the internal details in many places. As you
look deeper into the nuts and bolts in this chapter, many of these details will emerge.
As Figure 7-1 depicts, data services includes the following:
Gateway to intercept server-bound calls
Parser to make sense of AMF messages
Serializer and deserializer to transform objects between ActionScript 3.0 (AS3) and Java
Manager to coordinate with and delegate responsibility to server-side objects
Messaging service provider to send and receive messages
By data services, I mean a class of products that enable remoting and messaging over AMF and proto-
cols like Real Time Messaging Protocol (RTMP). RTMP is a proprietary protocol developed by Adobe
Systems for streaming audio, video, and data over the Internet. More information on RTMP can be
found on Wikipedia at http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol and at
http://osflash.org/documentation/rtmp.
As mentioned, there are two data services implementations from Adobe and a few open source alter-
natives. Following are the most popular ones:
LifeCycle Data Services (Adobe): http://www.adobe.com/products/livecycle/dataservices/
BlazeDS (open source from Adobe): http://opensource.adobe.com/wiki/display/blazeds/
Granite Data Services (GDS): http://www.graniteds.org/
WebORB for Java: http://www.themidnightcoders.com/weborb/java/
OpenAMF: http://sourceforge.net/projects/openamf/
OpenAMF is not a very active project at the time of writing. The last release dates back to 2006. This
project’s mission was to port AMFPHP to Java. AMF was a closed specification back then, and AMFPHP
was a reverse-engineered open source option for PHP servers. OpenAMF is closer to Flash remoting
than data services.
This chapter sticks mostly to LCDS and BlazeDS, but the same concepts apply to the alternatives. LCDS
and BlazeDS are quite similar in form and structure and share the same codebase. BlazeDS can be
thought of as a marginally scaled-down version of LCDS.
258
CHAPTER 7
Figure 7-1. Data services architecture: an overview
Data services uses AMF3 (Action Message Format version 3) to transmit binary data between Flex and
Java. The genesis of this product lies in the Flash remoting server, which used to support AMF0 as the
binary protocol. Flash remoting still exists, in many forms, but data services replaces it as a better
alternative.
Whichever data service we choose, it is a web application from a Java server perspective. Let’s dig a bit
deeper to see what this means. (Of course, we are talking only about data services for Java. There are
remoting servers for other technologies, but that is beyond the scope of this book.)
259
INTEGRATING VIA DATA AND MEDIA SERVICES
It’s a web application
Web applications are applications built on the technology that powers the Web. The HTTP protocol
and the associated programming paradigm are a prominent part of this technology set. In Java, the
raw low-level HTTP and related infrastructure is abstracted out as a higher-level API and managed
components. At the heart of this abstraction is the Servlet specification, which wraps HTTP methods
and HTTP protocol handling in objects. Web applications written in Java are packaged with all assets,
associated libraries, class files, and any other resources into a special archive file format: a web appli-
cation archive (WAR). These WAR files are deployed on a servlet container or an application server
(which contains a servlet container).
Most data services, especially LCDS and BlazeDS, are web applications and exist as WAR files. The
remoting gateway is a servlet, and data service elements are web components. A little later, in the sec-
tion “Downloading and deploying the web application,” you will see how deploying LCDS or BlazeDS
is identical to deploying any other web application distributed in a WAR file format.
In both BlazeDS and LCDS, the primary communication responsibilities are handled by a message bro-
ker, which is created on startup by a servlet called the MessageBrokerServlet. The application server’s
standard class loader loads it like any other servlet. This message broker is extremely flexible, and all
types of available services and endpoints can be configured for it fairly easily. All such configurations
reside in an XML configuration file, which I talk about later in the section “Configuring data services.”
Protocols, channels, destinations, and endpoints
One of the primary advantages of data services is their use of AMF to transmit data between Flex and
Java. AMF is a binary protocol, and the Flash Player natively supports it. Therefore, transmission using
AMF is fast and efficient. AMF is a high-level (application layer) protocol that uses HTTP for commu-
nication. Almost all data services dialog happens over HTTP or its secure alternative, HTTPS. AMF spec-
ification is now available under the open source license and is accessible for download at
http://download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf. When remoting, AMF is
marshaled and unmarshaled at both ends (Java and Flex) for the data interchange to work.
The data services messaging module and media server use RTMP. LCDS and FMS support RTMP, but
BlazeDS does not. BlazeDS uses HTTP tunneling and AMF long pooling to achieve a push-based model.
Red5 (http://osflash.org/red5), an open source alternative to Flash Media Server, partially reverse-
engineers RTMP and provides streaming capabilities over this derived protocol.
Apart from AMF over HTTP and RTMP, the Flash Player also supports Transmission Control Protocol
(TCP) over Sockets. TCP is a protocol from the Internet protocol suite that facilitates reliable ordered
delivery of byte streams. Secure versions of the protocol, such as AMF and HTTP over Secure Sockets
Layer (SSL) and RTMP over Transport Layer Security (TLS), can be used as well. Both SSL and TLS are
cryptographic protocols that facilitate secure communication over the Internet. TLS is a newer gener-
ation protocol compared to SSL. Although similar, SSL and TLS are not interchangeable. TLS 1.0 is a
standard that emerged after SSL 3.0. These protocols involve endpoint authentication, message
integrity, and key-based encryption. Both protocols support a bunch of cryptographic algorithms
including RSA. RSA is a popular cryptographic algorithm for public key cryptography, which involves
two different keys, one to encrypt a message and another to decrypt it.
260
CHAPTER 7
剩余43页未读,继续阅读
资源评论
- yinmozhen2012-12-07我以为是安装包呢,下错了~
darius
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
- 基于Python实现的手写数字识别系统源码.zip
- 从网页提取禁止转载的文字
- C语言基础-C语言编程基础之Leetcode编程题解之第32题最长有效括号.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第31题下一个排列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第30题串联所有单词的子串.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第29题两数相除.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第28题找出字符串中第一个匹配项的下标.zip
- 实验报告模板(1).docx
- C语言基础-C语言编程基础之Leetcode编程题解之第26题删除有序数组中的重复项.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功