Current popular J2EE web application architecture analysis

xiaoxiao2021-03-06  80

Current popular J2EE web application architecture analysis

1. Architecture Overview The J2EE system includes Java Server Pages (JSP), Java Servlet, Enterprise Bean, Web Service, etc. The emergence of these technologies provides a very competitive choice for the development of web applications in the era of e-commerce. How to combine these techniques to form a stable architecture that adapts to the project is a very important step in the project development process. Completing this step can form a main milestone baseline. There are many benefits to forming this baseline: various factors initially determine to form a framework baseline, the architect designer should screen the techniques in the platform (system), and the trade-off of all kinds of pros and cons. Often architect designers should read a lot of technical information in this process, listen to the recommendations of the project team members, consider the needs of the domain experts, consider the sponsors cost (including development costs and operating maintenance costs). Once the architecture is reviewed, these factors have initially have a positioning of the projects in the process of the project. Directional Technical Training Once the architect design has been approved, the technology used by baseline, project development and operation is basically determined. Many project managers are worried about the technical skills of the preparatory project team; they need training sectors, but the project manager will not provide a clear technical training needs on the technology ocean facing the architect. How can you not train all techniques in the system! With architectural milestones, the project manager can determine what technology will be used this project, which is the most accurate training needs. However, in the actual project development, technical training can be designated concurrently with the architecture before the baseline determination. The role is divided into a good architecture blueprint, we can accurately divide work. Such as web design, JSP tag processing class design, servlet design, session bean design, and various implementations. These tasks can be clearly labeled out on the architecture blueprint so that project group members can locate their own tasks well. A good architecture blueprint can also standardize tasks, which can be divided into several categories, which are the same or similar to the task of tasks in the same category. This workload is estimated to have a very good foundation. Operation and maintenance says that each task has a better positioning on the architectural diagram. Anyone can quickly locate the error point when it is quickly familiar with the operation of the entire project. In addition, with a clear architecture map, project version management also has a good version of the tree tors. Scalability architecture is like a trunk of a gorgeous tree, as long as the roots of the torso are tie, the tree is thick, long, plus some leaves, easy to mention. Similarly, there is a stable structure that is actuated, increasing one or two business components are very fast and easy. Everyone knows these benefits and wants to form a such J2EE application architecture (just like MFC in the Windows platform). In this journey, two big phases have been experienced: 1.1. Model 1 Model 1 is actually not a stable architecture, even talking about the formation. The foundation of the model 1 is a JSP file. It extracts parameters from HTTP requests, calls the corresponding business logic, handles HTTP sessions, and finally generate HTTP documents. A series of such JSP files form a complete model 1 application, of course, there may be other auxiliary class or files. Early ASP and PHP technology belong to this situation. In general, the advantage of this model is simple, but it mixes business logic and performance in a piece. This disadvantage is that this disadvantage is tolerant. 1.2. Model 2 After a practice, and widely borrowed and summarized the lessons, J2EE applications finally ushered in MVC (Model-View-Control) mode. The MVC mode is not a newly disciplined J2EE industry, so I talked to Guangfa. The core of the MVC is to do three or even multi-layer loose coupling.

This is a J2EE system that constantly expands based on components, and is really evangelism and savior. It is inserted into a control component between the browser (herein, the customer agent) and JSP or servlets. This control component sets the distribution logic of HTTP requests from the browser, that is, it will send the request to the corresponding Web layer JSP according to the URL of the HTTP request, input parameters, and the internal state of the current application. Servlet. In addition, it is also responsible for choosing the next view (in J2EE, JSP, servlet generates an HTML back to the browser to form a view). Concentrated control components are also conducive to security verification, log records, and sometimes also package request data to the following Web Tier layer. This set of logic has formed an application framework like the MFC, where is shown in Figure: 1.3. Multi-layer application The picture shows a typical multi-layer application model in the J2EE system. The Client Tier client is generally a browser or other application. The client is generally supporting the HTTP protocol, also known as the customer agent. The web tier web application layer is in J2EE, which is run by the web container, which includes web parts such as JSP, Servlet. EJB Tier Enterprise Component Layer Enterprise Component Layer is run by EJB container, supports EJB, JMS, JTA and other services and technology. EIS Tier Enterprise Information System Layer Enterprise Information System includes traditional information systems such as finance, CRM, etc., and is characterized by support for database systems. The application framework is currently focused on the Web layer, which is designed to regulate the development of this layer of software. In fact, enterprise component layers can also achieve this model, but currently exist in the form of design patterns. And some frameworks can be expanded, with the participation of corporate component layer components, the framework will look more compact, more natural, and the efficiency will be higher. 2. Currently, the framework of the model 2 is also emerging, and the more famous framework is listed below. 2.1. Apache Struts Struts is a free open source application framework, Apache Software Fund is committed to the development of Struts. The Struts is highly configurable, and there is a list of growing feature. A front-end control component, a series of action classes, action mappings, processing XML utility classes, server-side Java beans, supported Web forms, international support, generating HTML, realize the performance logic and template composition Struts soul. 2.1.1. The purpose of Struts and MVC model 2 is the same, so the model 2 can be equal to MVC equivalent. The figure below reflects the operation mechanism of Struts: 2.1.1.1. Control is shown in the figure, its main component is a universal control component. This control component provides an entry point that processes all HTTP requests sent to Struts. It intercepts and distributes these requests to the appropriate action classes (these action classes are subclasses of the Action class). In addition, the control assembly is also responsible for populating the from bean with the corresponding request parameters, and transmit it to the action class. Action class implements core business logic, which can access Java Beans or call EJB. The last action class transmits the control right to subsequent JSP files, and the latter generates a view. All of these control logics are configured with a struts-config.xml file. 2.1.1.2. Model model exists in the form of one or several Java Beans. These beans are divided into three: Form Beans, which saves the data from HTTP POST requests, in Struts, all Form Beans are subclasses of the ActionFrom class. Business logic Beans is dedicated to handle business logic. System status Beans It saves session information across multiple HTTP requests, and system status.

2.1.1.3. View Control Components Renew the HTTP request to the JSP file that implements the view. JSP can access Beans and generate results documents feedback to our customers. Struts provides JSP tag libraries: HTML, Bean, Logic, Template, etc. to achieve this, and facilitate separate performance logic and program logic. 2.1.2. Struts Details Analysis 2.1.2.1. View - Control - Model Users issued a * .do's HTTP request, after receiving this request, find the action map for this request, and then check if it has created the corresponding Action object (Action instance), if not, call ActionMApping to generate an action object, the control component saves this action object for later use. The method of calling an actionMApping is called to get an ActionForm object. The ActionForm is then transmitted to the Perform method of the action object. This method will return to the control component an ActionForward object. Control components then get the path and redirect properties of the next view from this object. If you call the httpservletReponse method to redirect, the next view is displayed, otherwise, RequestDispatcher, the method of servletContext is successively transmitted to the next view. Error messages may occur when the action object runs the Perform method. The action object can save these error messages into an Error object, then call the SaveErRors method to save this error to the properties of the Request object. Then the action object calls the getInput method of the actionMapping object to obtain the input parameter from the action map, which is generated by the input view, and generates an ActionForward object to the parameter with this INPUT. This INPUT parameter is usually available in the JSP of this INPUT: ErrorS custom tag to read these error messages and displayed on the page.

Here is a logon.jsp code instance: <% @ page language = "java"%> <% @ taglib uri = "/ web-inf / struts-bean.tld" prefix = "bean"%> <% @ taglib URI = "/ Web-inf / struts-html.tld" prefix = "html"%> <bean: message key = "logon.title" /> </ Title> <html: base /> </ head> <body bgcolor = "white"> <html: errors /> <! - If an error will appear here -> <html: form action = "/ Logon "FOCUS =" UserName "> <table border =" 0 "width =" 100% "> <tr> <trh align =" right "> <bean: message key =" prompt.username "/> </ tH> <TD align = "left"> <html: text protety = "username" size = "16" maxlength = "16" /> <tr> <TD> <TR> <TH align = "right"> <bean : message key = "prompt.password" /> </ th> <td align = "left"> <html: password property = "password" size = "16" maxlength = "16" redisplay = "false" /> < / TD> </ tr> <tr> <td align = "right"> <html: submit property = "submit" value = "submit" /> </ td> <td align = "left"> <html: reset /> </ td> </ tr> </ table> 2.1.2.2. Model to the view model to the view refer to the process of loading system data to the view before display. System data is typically information on Java Bean in the model. The schematic representation of the HTML: Form custom label for the JSP of the control component Forward.</p> <p>HTML: Form custom label Processing Objects From Application Scope (Implemented by Querying the properties of the ServletContext object) Get the action mapping of the previously by the control component ActionServlet where the action mapping, by HTML: Form, the Actionform name, type, and range Waiting for information, find an actionform in the corresponding range, if there is, use its information to populate the HTML Form form [The actual fill action in the nesting HTML: Text, etc.]. Otherwise create an ActionForm object within the respective range. 2.1.3. Advantages and Disadvantages: Some developers have begun to adopt and promote this framework as an open source project, there are many advanced realization ideas for large-scale application support, and have a concentrated web navigation definition shortcomings: not the session for development tools It is not complex enough Taglib that requires a longer time to master HTML Form and ActionForm's matching, but this is also its essence. Modify It is recommended to modify the ActionForm properties to modify the method of reading or generating an XML document, then use the XML document with an XML document with an XML document, and adapt to the application of the data structure. 2.2. Jato Jato Application Framework is the old name of the IPlanet application framework. It is a mature, powerful, J2EE-based application framework for developing web applications. Combined with display fields, application events, components hierarchy, and with page-centric development methods, as well as concepts such as MVC and service to worker service-to-workers. Jato can be applied to medium, large, large-scale web applications. But it is not an enterprise-level application framework, that is, it does not directly provide a method of creating EJB, Web Services, etc., but it can construct a customer application access to the corporate layer component. This framework features mainly three parts: IPlanet application framework; iplanet application framework components; iplanet application frame extensions. The application framework core defines the minimum core of the basic interface, object protocol, simple component, and IPlanet application framework. Includes view simple components, model simple components, request distribution components, and reusable command objects. IPLANET Application Frame Components With the basic interfaces, protocols, and components defined by the framework, protocols and components provide high-level reuse components that are both high-level components that are unrelated to a particular visual effect, and they also provide specific utility environments, improve availability. Vertical components. The frame extension implements a method of accessing a non-J2EE environment with a framework. Typically, the extension is used to seamless access to the J2EE container specific feature. The JATO platform stack map clearly expresses this situation. Jato's largest power is: For rapid development users, you can use framework components and extended productivity. For users who require greater flexibility, you can implement interface-supplied interfaces to hold the framework compatibility of the application. This figure represents a JATO application that simply implements the control component module1servlet, view component ListCustomersModuleImpl, and a listCustomers.jsp file that displays the client agent display interface. And clearly indicate the inheritance relationship between these components and the JATO frame assembly. The JATO tag library provides the interface of the View object with the JSP file. The label handler in the library is responsible for implementing the information synchronization and exchange of the VIEW object and JSP generated client documentation. This figure clearly expresses this correspondence 2.2.1. MVC analysis front-end control component receives any request from the user, this can specify the request distribution component in web.xml responsible for view management and navigation, and front-end control components package ApplicationServletBase is implemented together.</p> <p>Application developers need to implement one such inheritance for each subsystem (Human Resources, Finance, CRM, etc.). Request a distribution component distribution request to workers, workers have implemented Command interfaces. Applying developers can implement this interface. JATO provides a default implementation: DefaultRequestHandingCommand, which will transmit the request to the specific event of the view component. The combined view refers to the hierarchical relationship that the view component is displayed to the user: the root view is an object field of a ViewBean class is an object of a DisplayField class. The container view is an object of a ContainerView class. The hierarchical relationship between the view component class is shown in Figure 2.2.2. Advantages of advantages and disadvantages: This framework has a large adaptation range, which provides the underlying interface, and the assembly that is immediately available has similar development concepts similar to the client RAD development. Central (equivalent to VB), event processing, etc. For large-scale applications support better shortcomings: not the business of the industry, there is no support for the development tool (JATO has been prepared for tool support) No defined web navigation Developers specify specific navigation URL modifications in their views in their views, it is recommended to modify numerous View / Model to transfer data to XML document, plus the concentrated web navigation definition 2.3. JSF (JavaServer Faces) JSF is a Sun included The Framework for Developing the Web Application User Interface in the Expert Group, JSF technology includes: a set of APIs, which implements the UI component, the status of the management component, processing events, input verification, definition page navigation, support internationalization and access; JSP custom label library implementation with JSP interface. JSF is very simple and is a defined programming model. With this technique, developers are connected to the data source of these components and applications by combining the available UI components in the page, and the events generated by the client to the server-side event processor are programmed. JSP handles complex work after all the scenes, so that developers focus on application code. 2.3.1. Struts, Jato and JSF compare part of them overlap, but the focus is different. Both Struts and Jato provide an MVC application model, while JSF only provides programming interfaces on the user interface. This means that the previously involved range is wide than the latter. The JSF can be part of the top two in the UI development. The release version of JSF's specification will be released at the end of 2002, and it may be better than this time. In addition, there will be tools to support the application development of this framework. 2.4. WAF WAF is a referusion of Web Application FramWork, which is the application framework proposed in the Sun Blue Book Example. It implements MVC and other good design patterns. 2.4.1. Details Click here to see the big picture 2.4.2. View - Control - The model is as shown in the figure, the two XML configuration files written by the developer define the WAF operation parameters. ScreenDefinition.xml defines a series of screens. Mapping.xml defines the screen that should be displayed after an action, but does not specify the screen to get the data. The user issues an HTTP request (* .screen), received by the TemplateServlet screen control component, it extracts the request information, set the request object CurrentScreen property, and send the request to the template JSP. After the template JSP receives the request, the Template tab in the JSP looks at this current screen and gets the specific parameters of this screen from the screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file (screen definition file)</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-107761.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="107761" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.038</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'jNBK8Pjlq9oBd9bmivZGGTEWv_2B7Qqb_2F6y6fNIh947eHfFVxaRtasjD03f07rrc_2FMh9Een3ZGI5vPjqDYH9oosw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>