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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章