`
hgfghww
  • 浏览: 40685 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

The architecture of Flex and Java applications two (Flex 和 Java 应用程序架构 2)

 
阅读更多

  Flex and Java applications use a multi-tier architecture where the presentation tier is the Flex application, the business or application tier is the Java EE server and code, and the data tier is the database. You can write the back-end code just as you normally would for a Java application, modeling your objects, defining your database, using an object-relational framework such as Hibernate or EJB 3, and writing the business logic to query and manipulate these objects. The business tier must be exposed for access via HTTP from the Flex application and will be used to move the data between the presentation and data tiers.  Flex和Java应用程序使用一个多层架构,其中的表现层是在Flex应用程序,业务或应用层是Java EE服务器和代码,数据层是数据库。
  你可以写后端代码就像一个Java应用程序通常会,建立对象模型,确定您的数据库,使用诸如Hibernate或EJB 3对象关系框架,编写业务逻辑去查询和操纵这些对象。业务层必须是通过HTTP公开访问的Flex应用程序,而且将被用于在表项层和数据层之间移动数据。
  Typical HTML applications consist of multiple pages and as a user navigates between them, the application data must be passed along so the application itself (the collection of pages and functionality it consists of) can maintain state. In contrast, Flex applications, by nature, are stateful. A Flex application is embedded in a single HTML page that the user does not leave and is rendered by Flash Player. The Flex application can dynamically change views and send and retrieve data asynchronously to the server in the background, updating but never leaving the single application interface (see Figure 1) (similar to the functionality provided by the XMLHttpRequest API with JavaScript.) 
  典型的HTML应用程序包含多个页面,为用户之间的导航,应用程序的数据必须通过沿因此应用程序本身(该网页的集合和功能它包括)能够保持状态。相比之下,Flex应用程序,本质上是有状态的。一个Flex应用嵌入在一个HTML页面,该用户不离开,是由Flash Player的呈现。 Flex应用程序可以动态改变的显示页面,发送和检索数据异步在后台服务器,更新,但从来没有离开单一的应用程序接口(见图1)(类似于用JavaScript的XMLHttpRequest的API提供的功能。)
  
  Figure 1. The client/server architecture. Flex applications can communicate with back-end servers using either direct socket connections or more commonly, through HTTP. The Flex framework has three remote procedure call APIs that communicate with a server over HTTP: HTTPService, WebService, and RemoteObject. All three wrap Flash Player's HTTP connectivity, which in turn, uses the browser's HTTP library. Flex applications cannot connect directly to a remote database. Flex应用程序可以与后端服务器通信,可以使用直接socket连接或更常见的服务器通过HTTP。 Flex框架有三个远程过程调用的API,通过HTTP与服务器通信:HTTPService,WebService,和RemoteObject。所有这三个包Flash播放器的HTTP连接,这反过来,使用浏览器的HTTP库。 Flex应用程序不能直接连接到远程数据库。
  You use HTTPService to make HTTP requests to JSP or XML files, to RESTful web services, or to other server files that return text over HTTP. You specify the endpoint URL, listener functions (the callback functions to be invoked when the HTTPService request returns a successful or unsuccessful response), and a data type for the returned data (what type of data structure it should be translated into once received in the Flex application). You can specify the data to be handled as raw text and assigned to a String variable or converted to XML, E4X, or plain old ActionScript objects. If you get back JSON, you can use the Adobe Flex corelib package of classes to deserialize the JSON objects into ActionScript objects. To make calls to SOAP based web services, you can use the HTTPService API or the more specialized WebService API, which automatically handles the serialization and deserialization of SOAP formatted text to ActionScript data types and vice versa. 
  您可以使用HTTP服务,使HTTP请求到JSP或XML文件,以REST风格的Web服务,或到其他服务器上的文件通过HTTP返回文本。您指定的端点URL,监听功能(回调函数被调用时,HTTP服务请求返回成功或失败的反应),并为返回的数据(什么类型的数据结构应该成为一次收到的数据类型转换Flex应用程序)。您可以指定要处理的数据为原料文本和分配给一个字符串变量或转换到XML,E4X的,或普通的旧的ActionScript对象。如果你回来的JSON,您可以使用Adobe Flex的班corelib包反序列化到JSON对象的ActionScript对象。打电话到基于SOAP的Web服务,您可以使用HTTP API或更专门的WebService的API,它会自动处理的序列化和反序列化的SOAP格式的文本到ActionScript数据类型,反之亦然。
  The third option for making remote procedure calls is to use the RemoteObject API. It makes a Flash Remoting request to a method of a server-side Java class that returns binary Action Message Format over HTTP. When possible, use Flash Remoting whose binary data transfer format enables applications to load data up to 10 times faster than with the more verbose, text-based formats such as XML, JSON, or SOAP (see Figure 2). To see a comparison of AMF to other text-based serialization technologies, see James Ward's Census RIA Benchmark application.
  远程过程调用的第三种选择是使用RemoteObjectAPI。它使一个Flash Remoting的请求到一个服务器端Java类方法返回的二进制消息格式通过HTTP行动。如果可能,使用Flash Remoting的传输的二进制数据格式使应用程序来加载数据高达10倍的速度比更详细,如XML,JSON的,或SOAP基于文本的格式(参见图2)。要查看AMF的相对于其他基于文本序列化技术,
  
  Figure 2. Methods for connecting Flex and Java.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics