Remote call enhanced J2EE representation of the J2EE indication layer Source: chinaitlab Collection 2004-7-14 11:45:00
There is a brand new for Macromedia's Flswing. This article investigates the remote call of Flash Remote Tune ASH to make the Java developer's way to build J2EE (Java 2 Plat, explain why it has this effect, except JSP JavaServer Pages) and Form, Enterprise Edition apply and provide an example of how to implement
Select SWING / AWT in any multi-layer system. But also makes it makes it easy to control both relatively small, browser. For these situations, macromed represents layer technology when the application swings. For these cases, Java Developers usually wing Tookit. With JSP, the development of the application is issued when published in different browsers, but requires the user to publish two options for the user's interaction IA Flash: JSP or You can create a very easy-to-publish dynamic, which is not easy to control their operation. Use the installation Java runtime environment. This situation is also available when developers have high controllability.
In general, Macromedia is until the introduction of Remoting MX recently can be used with Java, .NET and ColdFusion cloth, browser-based representation of Flash is rich than publishing interface, with a footglass method can put Flash Application integration changes. Flash Remoting MX provides communication. With the Flash REMO layer, you can perform this program's application for the application's application. Unfortunate into the J2EE system. This situation has made Flash applications Ting with the standard communication layer of Flash, and the developer can be accepted in the J2EE system.
This article will explain why Macro Flash is suitable for how to use the layer to be changed, then compare Flash and is now a solution to the application layer in the N-layer system. I will first investigate the standard, and finally explain how Flash applies to the J2EE system.
Evolution of the application layer:
Creating the first web from Berners-Lee, developers have to develop WEB servers and HTMLs with the server, and developers can send or software platforms. This method is for the application of the data of the developer file, but it is not suitable for a variety of application systems, the representation of the N-layer system has experienced a change. In that close client system. Only basic HTTP protocols that can be utilized, the cloth is based on the document application system, regardless of the hardware they use, there are some basic problems: Although HTML can be successfully transmitted based on text-can be used in real time.
In order to solve these shortcomings, some new features, namely Java and Java table are not related to applications. In fact, Java is equipped with Java runtime environment (Java RUs need to be installed in the client system, especially the Internet's hairdressing workers will start in modern browsers (Netscript. Developers can use the use of applets Did not reach its period NTIME ENVIRONMENT, JRE, in addition to the Java applet, the client also needs to have a very slow connection. After the APE Navigator 2.0, the development of a Web browser platform is released, and the flat-edge value is issued. The Java applet requires the user that the Java plugin has been installed in the Web browser. In addition to the Java applet. These are very time consuming
In addition to this solution, there are three types of HTML (DHTML), Applet / Swing, or the third selection to use rich front ends in client / server applications: Dynamic Solution. Each solution has various advantages and disadvantages.
DHTML:
The following advantages are provided using DHTML to create a rich front end: ??????????????????????????
1. DHTML is open and free ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????
2. Use the application written by DHTML can be configured in any web browser that supports DHTML ????
3. WEB-based applications Its clients are usually composed of text and pictures, which allows for small application scripts.
DHTML is not always a: a good solution; when you choose this technology, you must take some shortcomings.
1. DHTML relies on users' We and versions of multiple B browsers to effectively reflect the user's origin to the app. Because of the browser manufacturer
Therefore, the work area must be embedded in complex applications to make the application can have the same performance in different browsers.
2. Although DHTML makes developers to better control client behavior, this flexibility is limited.
3. Since different browsers have some differences in JavaScript, they must be different on the JavaScript, they must be different.
Different platforms. Join the work area and add the complexity of maintenance applications to the implementation of each reverse. In addition, no
After the new browser is released, the application (or one part of the application) must be re-encoded and tested. ????????????
When the developer explicitly knows that he is only applicable if the company is only applicable to IE6. The standard client configuration is applied 0. When the application logic for the browser can, it is indeed its advantage that DHTML does have its advantage. It is very effective for being processed.
Applet / Swing:
For Java developers, the following advantages: APPLET or SWING-based solutions are another viable solution. it has
1. Creating Java-based applications Whether you are free for users or developers ???????????????????
2. Applets can be configured through most browsers ?????????????????????????????????????????
3. Applets allows users to create a rich user interface ????????????????????????
4. Use Applets to make the client share a part of the server's load ??????????????????????????????????
Choosing Applets-based solutions also installed JRE. Even if they installed, it is not necessarily required to measure it below: developers cannot determine if the user wants.
Applets is the developer in the standard, developers can assume the correct JV accounting client to configure their app to provide a large choice for M versions. For standard client
In addition to using Applet / Swing or DHTML applications, developers have a choice: third-party solution.
Third-party solution: mecromedia flash ????????????????????????????????????????????????????????????????????????
In order to achieve the same effect as DHTML or Applet application, third-party products need to have the following features: ??
1. Can any standard browser use it ???????????????????????????????? ??????
2. The application runs hardly requires the user's interference ????????????????????????????????????????????????????????????????
3. The runtime of the client must be free or at least very cheap ???????????????????????
4. The client should be able to combine with the existing business logic ?????????????????????????????????????????????
There are some third-party solutions together in this area, and Macromedia's Flash Suite. All this can be applied to a web browser-based application ActiveX and QuickTime, Flash is a method of developing a J2EE application server in Java. This means that the business logic can be used without any change, including the Actime, including Apple's QuickTime, Microsoft ActiveX, is available on many users' systems. It doesn't have to pay any price. However, it provides a significant helpful benefit: it allows client applications to call the existing EJB, Servlets, Web Services, and front-end calls in the ASH in the class.
Server-side product Flash Reremoting is supported by two important partial servers and clients. The gateway end support group has become ActionScriptMoting to make the flash client to compose: Used to use local flash objects and applications in standard WAR files (Methods to use J2EE Server by the Flash run and configuration tool. Flash method Map to the gateway of Java objects and methods any J2EE application server configuration. Customer programming language) increased features. To make Flash Remoting, the handle of Flash should (Java object) and call the method. This is connected by a gateway connected to a web application called MX, and the web is used to connect to J2EE Server to get the service it wants to use the ActionScript library (netservices). The following example. Xml file servlet mapping is as follows:
Servlet-mapping> ?????????????????????????????????????????????????????????
// load the netservices ActionScript library
#include "netservices.as" ????????????????????
// Create a connection to the MX Webapp Running On Port 80 on the local
// machine ????????????????????????????????????????? ?????????????
NetServices.SetDefaultgatewayURL ("http: // localhost / mx / gateway";);
// invoke the creategatewayConnec // FunctionAlity To Initialize the Flash Remoting
GatewayConnnection = NetServices.creategatewayConnection ();
// bind the java object: com.tallan.data.providers.FlashDemo
// TO a Service Called TallandAnDataNVice.
TallandaService = GatewayConnnection.getService
("com.tallan.data.providers.flashdemo", this);
// Invoke a Method Called GetReportData on The Service Named
// TallandAseRevice ??????????????????????????????
TallandataService.getReportData (); ??????????
The process of connecting to J2EE Server and calling a method is illustrated. ??????????????
In order to deal with actual work,. All distal calls are in an asynchronous plus callback function. As long as the gateway gets from J2, the ActionScript function getReportData (), the ACT must call in the Flash client and the J2EE Serv method. In order to support the function of the function on the server EE server, the backup name must be named the Ionscript callback function with the called Java method to be named the enterprise resource on the GER. The return value is returned on the transfer parameter, and must be added to the Flash client Was called. In order to support the function back. In the following example, the method is etReportData_Result; function getReportData_Result (Result) ????
{?????????????????????????????????? ???????????????????????????
// Print The Results from the app server to the
// debug window ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????
Trace (result); ??????????????????????????????????????????????????????????????????????????????????????? ?????
} ?????????????????????????????????????????? ???????????????????????????
All methods call information, format (AMF) format passes. The AOBJECT Access protocol is called at a faster speed. Map. Including parameters and return values, both client MF is binary information format, transmitted by http. In the network, the AMF letter Flash Remoting transparently processes the Java and the server side with action Message to be similar to SOAP (SIMPLE-based SOAP information is much smaller, thus allowing the object and the ActionScript object
Make Flash Before J2EE processes the XMLActionScript code on all clients to resolve an important feature that is embedded parsing and DOM (Document.nbspobje to include X and Y coordinates in the 2D graphics. Flash. Born to be able to pass CT MODEL). The following XML document:
Graph> ??????????????????????????????????????? ????????????????
A class that generates a graphical file document on the application server: ??????????????????????????????
PUBLIC CLASS FLASHDEMO ????????????????????????????????????
{?????????????????????????????????? ???????????????????????????
Public FlashDemo () ???????????????????????????????????
{?????????????????????????????????? ???????????????????????????
} ?????????????????????????????????????????? ???????????????????????????
Public document. NBspGetReportData () ????????
{?????????????????????????????????? ???????????????????????????
Document. nbspdoc = NULL; ????????????????????????
TRY ????????????????????????????????????????????????????????????? ???????????????????????
{?????????????????????????????????? ???????????????????????????
System.out.println ("Calling getReportData);
Document. uilder builder = ????????????????????
Document. UilderFactory.newInstance (). NewDocument. Uilder ();
Doc = builder.newdocument. ); ????????????????????????????????????????????
// CREATE A Record as the root element ????
Element element = doc.createElement ("graph");
Element Child1 = Doc.createElement ("Point");
Child1.setttribute ("XValue", "February");
Child1.setttribute ("YVALUE", "20"); ??????
Element.Insertbefore (Child1, Null); ????????
Doc.Appendchild (element); ????????????????????
This simple class will return a document object parsing the Flash client; the following example completes the resolution: ??
// parse the xml document. Nbspreturned by the Server, // Keeping The Results in an Array Called Nodes
Function Parsexml () ??????????????????????????????????????????????????????????
{?????????????????????????????????? ???????????????????????????
// CREATE A New Array Called Nodes ????????????
Nodes = new array (); ??????????????????????????????
// initialize the nodes array to ????????????????
// contain all of thereportxml.nodes; children of the reportXML Document. Br> nodes =
// ChildCounter is used as a counter for the child nodes
Childcounter = 0; ????????????????????????????????????????????????
// ChildNodes Will Contain The Children Of Each Node
Childnodes = new array (); ????????????????????
// Xaxisvalue Will Contain The X-Axis Value to Plot
XAXISVALUE = New Array (); ????????????????????
// YaxisValue Will Contain The Y-Axis Value of The Data Sets
YAXISVALUE = New Array (); ????????????????????
// Iterate Through The First Level Children Of The XML DOC
For (j = 0; j <= nodes.length; j ) ???????????????
{?????????????????????????????????? ???????????????????????????
// Check if the node name is report I.e., The Data Set
// belongs to graph ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
IF (nodes [j] .nodeename == "graph") ????????????
{?????????????????????????????????? ???????????????????????????
// Get the background color of the graph
BGColor = "# 000000"; // snodes [j] .attributes.bgcolor;
// Get the capenial of the graph ???????????????????????????????
Caption = nodes [j] .attributes.caption; ??
// Get the x-axis name ????????????????????????????
XAXISNAME = NODES [J] .attributes.xaxisname; // Get the Y-axis name ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?????
YAXISNAME = NODES [J] .attributes.yaxisname;
// Get the min value of the y-axis ????????????
YAXISMINVALUE = NODES [J] .attributes.yaxismInvalue;
// Get the max value of the y-axis ????????????
YAXISMAXVALUE = Nodes [J] .attributes.yaxismaxValue;
// Now, we get the childnodes ???????????????????????????????????????????????????????????????????????????????????????????????
Childnodes = nodes [j] .nodes; ??????????????
// Iterate Through All of the child nodes, punling OUT
// Their X, Y Values and Storing Them in Arrays
For (k = 0; k <= childnodes.length; k ) ??????
{?????????????????????????????????? ???????????????????????????
// if the node name is set i.e., a graph Data set, Then We Retrieve
// and color the value ??????????????????????
IF (ChildNodes [K] .NodeName == "Point")??
{?????????????????????????????????? ???????????????????????????
// increment counter ??????????????????????????????????????????????????????????????
ChildCounter = childcounter 1; ????????????
// Get the x-axis name ????????????????????????????
XAXISVALUE [ChildCounter] = ChildNodes [k] .attributes.xvalue;
// Get the value ??????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Yaxisvalue [childcounter] = childNodes [k] .attributes.yvalue;
} ?????????????????????????????????????????? ???????????????????????????
} ?????????????????????????????????????????? ???????????????????????????
} ?????????????????????????????????????????? ???????????????????????????
} ?????????????????????????????????????????? ???????????????????????????
} ?????????????????????????????????????????? ???????????????????????????
The above example simply parses the XML document and stores it in each array. ???????? There are many Flash on the world. There are several libraries that can be used to plug the XML sender generated by the application server. Thus, Macromedia's website draws data arrays. By using this document, as shown below: There are a lot of free ActionScript libraries available, you can create a simple app
?
Because Flash is extended in handling rich media, it is conceived a more comprehensive graphics application. These XML documents are coordinate. This data is different from a graphical application in a pleasant way, because the flash application only needs to be called, it allows users to enlarge, drill, or use it very useful when using the CPU's occupancy. of. The power of the server-side load is assigned to the client to hand over the increasing work to the client, so that the server can solve the server, you can easily make a graphics application on the basis of the server on the server. The method to generate a combination of a freely used graphics library, and these coordinates are drawn on the Flash interface. This graphics application is based on the HTML-based graphics in XML format, without having other future data sets for the server. It can be proved that this method is useful in the application of the application as the desktop computer performance is becoming more and more powerful. Flash allows developers to put all XML parsing and graphical operations to handle other requests to achieve the above objectives.
Integrate Flash into your J2EE app
Although the front-end configuration of the DHTML solution is suitable for processing a document driver or a simplified ring, it is meaningful for the J2EE developer. Flash is integrated into a variety of options in the existing J2EE architecture in a multimedia Flash client containing a small number of scripts, but different selection effects are different. HTML and single application. In the SWIGN / Applet scheme, the configuration is configured. However, for some applications, Flash may have an advantage in the client environment. Using remote tools, developers can now be in.