Comparison between JIVE3.0 Webwork and Jute1.0 Action Mapping

zhaozj2021-02-17  54

Today downloaded JIVE 3.0 to try, prepare to study the new features of Jive, and do some reference for Jute next development. The discovery in the study will be collected with everyone to share. Title: Comparison of between Jive3.0 Webwork and Jute1.0 Action Mapping: Rainmanzhu Time: 2002-11-29 from: http: //www.cjsdn.com content: Jive3.0, the framework includes a webwork of Look at naming, it is understood that it is used to handle web links to complete a series of related tasks. Because the HTTP protocol is stateless, if the task is to perform step-by-step execution, it is necessary to define the protocol to put multiple link strings (chain), and the task processing will have an error or successful branch, such as the new topic such a task. If the article is too long, you need to display the error page to the user; if you join the topic, you need to prompt the user to post success, in Jive, this action is defined in Actions.xml: attach! default.jspa doredirect.jspa? URL = {last} postform.jsp postform.jsp loginform.jsp ViewPreview.jsp postform.jsp Spell! default.jspa postform-success.jsp < / View> You can see that this action has many branches, and some branches are chain (bold places), such as Attach.

Of course, ATTACH Actions are also defined in Actions.xml: attachform.jsp attachform.jsp postform-success.jsp post! default.jspa Error.jsp < / View> CANCEL action makes it possible to return to the posting action. Action's Name is actually a class of JIVE definitions, so the logic of the action is implemented in this class. The base class of the Action class is com.jivesoftware.webwork.Action.Action, with an abstract excute () method. Action's distribution unified through com.jivesoftware.webwork.dispatcher.servletdispatcher, servletdispatcher is looking for the corresponding action through the URL (* .jspa -jsp action?), then set the actionContext (action environment, all parameters pass this class to pass) Action, the transfer is based on the same thread, the method is very good!), finally executing an Excute () method of action, the method returns a value of VIEW (such as Attach, Cancel ...), while the view corresponding to the Actions. XML is also defined! ServletDispatcher is forwarded to the JSP page via requestdispatcher, and the application server performs JSP generation HTML. The above is a little analysis, what is the webwork in Jive, in fact, this article is the most important thing about why JIVE wants to introduce Webwork? From the history of JIVE development, 1.0's JIVE is a mode with JavaBean JSP. There is no fixed connection between the two JSPs, and it is stacked in a root directory, so maintenance is very bad, and Jive also supports Skin at the time. But you can see that every Skin has written a bunch of such JSP, almost no reuse! In fact, this model is 2 layers, lack of control layer, if it is determined that the user login status, each need, there is a call API, and a lot of Java code has occurred in JSP, so each JIVE upgrade can be seen. The previous JSP is almost unrecognizable. This is a very obstacle factor for a rapidly developing project. At that time, the JIVE focus on the design of the data layer may be a reason. I seem to have seen it after 2.0, I found that there is no big change in design. However, JIVE3.0 has a three-layer structure of Make Sense, and the data layer is still constant, the intermediate layer is Action, and the performance layer is a simplified JSP using the label. I think this is a truly meaningful design.

By the way, WebWork defines a set of labels for JSP: such as the homepage: <% - print info message if the exist -%> <% @ include file = "info-messages.jsp"%>

by using a tag, the controllability of the interface becomes good jive up. I will focus later to analyze the performance of Webwork, I hope to learn some good ways to learn. Jute 1.0 is also a very mature three-layer structure. The intermediate layer uses servlet mapping action mapping to distinguish between different functional groups through the URL prefix, select the new servlet or select a new Action according to the complexity of the function. To separate the code. Using inheritance and abstract methods to reuse code, Jute All servlets are inherited from JuteServlet. In fact, other servlets are defined actions! Each servlet has Perform (CONTEXT CONTEXT, CGI CGI) method, is default action; then other Actions can be defined to complete different action, Jute's CGI class similar to Jive's ActionContext, Request, Cookie, Session through CGI objects Get, in order to improve performance, the CGI class is created by object pool; Jive creates new actionContext each time, and saves in Threadlocal! This is what I didn't think of it before, and later studied. The CONTEXT class of Jute is actually a TemplateContext or to save the control layer state, but more to provide data to the interface layer. There is an ExcuteAction method in the base class JuteServlet. After the method is executed, return the interface template, this is very similar to JIVE! ! ! But the difference is also very big! Jive is a static mapping action, and Jute is a running moment, and the event is to speed up the action by cache, but the jive can define various views of Action Chain, and Action, and save the previous action, for Errors generated during the Action implementation can also be saved in the action and configured the configuration extension. Jute's action mapping can save the last state through the CGI class, similar to the viewState in ASP.NET. When you create an action chain, you should pay attention to saving the previous state of each process, and this URL has become very long! JIVE defaults can nested 10 floors. JIVE can write this: "> Go back to get the previous URL. I think in the future, I can modify the JUTE to improve the HTTP status. Jute's return interface does not use the mapping method as JIVE, but directly written in the respective action method, because the interface and the Action relationship is close, generally cannot transform, but in the interface template can be embedded into sub-templates.

转载请注明原文地址:https://www.9cbs.com/read-28536.html

New Post(0)