《计算机系 Java EE 外文翻译 外文文献 英文文献.doc》由会员分享,可在线阅读,更多相关《计算机系 Java EE 外文翻译 外文文献 英文文献.doc(22页珍藏版)》请在三一办公上搜索。
1、外文科技资料翻译英文原文The Java EE Platform is the leading enterprise web server. The Adobe Flash Platform is the leader in the rich Internet application space. Using both, developers can deliver compelling, data-centric applications that leverage the benefits of an enterprise back-end solution and a great use
2、r experience.In this article, you learn about the architecture of applications built using Flex and Java including:(1) An overview of the client/server architecture. (2) The different ways the client and server can communicate. (3) An introduction to Flash Remoting and why and how you use it. (4) Ho
3、w to integrate a Flex application with your security framework. (5) An overview of how to build Flex applications using events, states, MXML components, and modules. (6) An introduction to developing a Flex application with real-time server data push. (7) How to boost productivity developing data-in
4、tensive applications using the Data Management service in LiveCycle Data Services. (8) An overview of model driven development using Flash Builder and LiveCycle Data Services to generate client and server-side code. (9) How to deploy a Flex application on a portal server. (10) Be sure to also watch
5、the video Introduction to Flex 4 and Java integration.(11) To learn more about the technologies used to build these applications, read The technologies for building Flex and Java applications article.Client/server architecture Flex and Java applications use a multi-tier architecture where the presen
6、tation 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 framew
7、ork 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. Typical HTML applications consist of multip
8、le 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 p
9、age 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 prov
10、ided by the XMLHttpRequest API with JavaScript.) Figure 1. The client/server architecture.Client/server communicationFlex 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
11、that communicate with a server over HTTP: HTTPService, WebService, and RemoteObject. All three wrap Flash Players HTTP connectivity, which in turn, uses the browsers HTTP library. Flex applications cannot connect directly to a remote database.You use HTTPService to make HTTP requests to JSP or XML f
12、iles, 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
13、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 cl
14、asses 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 v
15、ice versa. 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 app
16、lications 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 Wards Census RIA Benchmark application.Figure 2. Methods for connecting Flex and
17、 Java.Flash Remoting Flash Remoting is a combination of client and server-side functionality that together provides a call-and-response model for accessing server-side objects from Flash Platform applications as if they were local objects. It provides transparent data transfer between ActionScript a
18、nd server-side data types, handling the serialization into Action Message Format (AMF), deserialization, and data marshaling between the client and the server.Flash Remoting uses client-side functionality built in to Flash Player and server-side functionality that is built in to some servers (like C
19、oldFusion and Zend) but must be installed on other servers (as BlazeDS or LiveCycle Data Services on Java EE servers, WebORB or FluorineFX on .NET servers, the Zend framework or amfphp on PHP servers, and more). See the technologies for building Flex and Java applications article for more details ab
20、out BlazeDS and LiveCycle Data Services.BlazeDS and LiveCycle Data Services use a message-based framework to send data back and forth between the client and server. They provide Remoting, Proxying, and Messaging services, and for LiveCycle, an additional Data Management service. The Flex application
21、 sends a request to the server and the request is routed to an endpoint on the server. From the endpoint, the request is passed to the MessageBroker, the BlazeDS and LiveCycle Data Services engine that handles all the requests and routes them through a chain of Java objects to the destination, the J
22、ava class with the method to invoke (see Figure 3).Figure 3. Flash Remoting architecture.AMFAMF is a binary format used to serialize ActionScript objects and facilitate data exchange between Flash Platform applications and remote services over the Internet. Adobe publishes this protocol; the latest
23、is AMF 3 Specification for ActionScript 3. You can find tables listing the data type mappings when converting from ActionScript to Java and Java to ActionScript here. For custom or strongly typed objects, public properties (including those defined with get and set methods) are serialized and sent fr
24、om the Flex application to the server or from the server to the Flex application as properties of a general 0bject. To enable mapping between the corresponding client and server-side objects, you use the same property names in the Java and ActionScript classes and then in the ActionScript class, you
25、 use the RemoteClass metadata tag to create an ActionScript object that maps directly to the Java object. Here is an example Employee ActionScript class that maps to a server-side Employee Java DTO located in the services package on the server.package valueobjects.Employee Bindable RemoteClass(alias
26、=services.Employee) public class Employee public var id:int; public var firstName:String; public var lastName:String; (.) Installing BlazeDS or LiveCycle Data ServicesTo use Flash Remoting with BlazeDS or LiveCycle Data Services, you need to install and configure the necessary server-side files. For
27、 BlazeDS, you can download it as a WAR file which you deploy as a web application or as a turnkey solution. The turnkey download contains a ready-to-use version of Tomcat in which the the BlazeDS WAR file has already been deployed and configured along with a variety of sample applications. Similarly
28、, for LiveCycle Data Services, the installer lets you choose to install LiveCycle with an integrated Tomcat server or as a LiveCycle Data Services web application.In either scenario a web application called blazeds or lcds (usually appended by a version number) is created. You can modify and build o
29、ut this application with your Java code, or more typically, you can copy the JAR files and configuration files the blazeds or lcds web application contains and add them to an existing Java web application on the server (see Figure 4). Figure 4. The required BlazeDS or LiveCycle Data Services files.M
30、odifying web.xmlIf copying the files to a different web application, you also need to modify the web.xml file to define a session listener for HttpFlexSession and a servlet mapping for MessageBroker, which handles all the requests and passes them off to the correct server-side Java endpoints. You ca
31、n copy and paste these from the original blazeds or lcds web application web.xml file. flex.messaging.HttpFlexSession MessageBrokerServlet MessageBrokerServlet flex.messaging.MessageBrokerServlet services.configuration.file /WEB-INF/flex/services-config.xml 1 MessageBrokerServlet /messagebroker/* Op
32、tionally, you may also want to copy and paste (and uncomment) the mapping for RDSDispatchServlet, which is used for RDS (Remote Data Service) access with the data service creation feature in Flash Builder 4 that introspects a server-side service and generates corresponding client-side code. See the
33、model driven development section for more details. RDSDispatchServlet RDSDispatchServlet flex.rds.server.servlet.FrontEndServlet useAppserverSecurity false 10 RDSDispatchServlet /CFIDE/main/ide.cfm Reviewing services-config.xmlFor Flash Remoting, the client sends a request to the server to be proces
34、sed and the server returns a response to the client containing the results. You configure these requests by modifying the services-config.xml and remoting-config.xml files located in the /WEB-INF/flex/ folder for the web application. The services-config.xml file defines different channels that can b
35、e used when making a request. Each channel definition specifies the network protocol and the message format to be used for a request and the endpoint to deliver the messages to on the server. The Java-based endpoints unmarshal the messages in a protocol-specific manner and then pass the messages in
36、Java form to the MessageBroker which sends them to the appropriate service destination (youll see how to define these next). (.) Defining destinationsIn the remoting-config.xml file, you define the destinations (named mappings to Java classes) to which the MessageBroker passes the messages. You set
37、the source property to the fully qualified class name of a Java POJO with a no argument constructor that is located in a source path, usually achieved by placing it in the web applications /WEBINF/classes/ directory or in a JAR file in the /WEBINF/lib/ directory. You can access EJBs and other object
38、s stored in the Java Naming and Directory Interface (JNDI) by calling methods on a destination that is a service facade class that looks up an object in JNDI and calls its methods.You can access stateless or stateful Java objects by setting the scope property to application, session, or request (the
39、 default). The instantiation and management of the server-side objects referenced is handled by BlazeDS or LiveCycle Data Services. services.EmployeeService application You can also specify channels for individual destinations. Lastly, you use these destinations when defining RemoteObject instances
40、in a Flex application. Security In many applications, access to some or all server-side resources must be restricted to certain users. Many Java EE applications use container managed security in which user authentication (validating a user) and user authorization (determining what the user has acces
41、s towhich is often role based) are performed against the Realm, an existing store of usernames, passwords, and user roles. The Realm is configured on your Java EE server to be a relational database, an LDAP directory server, an XML document, or to use a specific authentication and authorization fram
42、ework. To integrate a Flex application with the Java EE security framework so that access to server-side resources is appropriately restricted, you add security information to the BlazeDS or LiveCycle Data Services configuration files (details follow below) and then typically in the Flex application
43、, create a form to obtain login credentials from the user which are passed to the server to be authenticated. The user credentials are then passed to the server automatically with all subsequent requests. Modifying services-config.xmlIn the BlazeDS or LiveCycle Data Services services-config.xml file, you need to specify the login command for your application server in the tag. BlazeDS and LiveC