Java Web Framework Summary

xiaoxiao2021-03-05  21

Java Web Framework Summary

0. Introduction

This article introduces the basic working principle of Java Web Framework, and some common open source Web MVC Framework (Struts, Web Work, Tapestry, Echo, JSF, MAVERICK, Spring MVC, Turbine, Cocoon, Barracuda).

The most important basic work of web development is http; the most important basic work developed by Java Web is servlet specific. HTTP and Servlet Specification are critical protocol specifications for the development implementation of Web Server and Web Framework.

Applications and profiling open source Web Framework, helping to understand HTTP & Servlet Specification, also help to understand some modern B / S Web framework design ideas, such as MVC, event handling mechanism, page components, IOC, AOP, etc. In this modern tide, even if the servlet specification itself does not help but also introduces modern frame design patterns such as Filter, Listener. This is the same as the JSF from Sun.

About the basic knowledge of the MVC model, project introduction, configuration file, entry example, has a large number of repetitive information information on the Internet, this article is no longer described.

Some relevant open source projects will be mentioned, and some programming ideas, if necessary, you can search online with the relevant keywords, get basic background knowledge.

This effort is simple, highlighting. Focusing on other information is not mentioned, or rarely mentioned more important content, such as operating principles, mainstream usage, related knowledge, key features, etc.

1. Java web program working principle

The web request path to the host local file path is defined in the server.xml file. For example,

Let's take a look at the process of HTTP Request-Response Cycle.

HTTP Request URL is generally divided into three paragraphs: Host, Context, Path.

Such as http: //yourhost/yourapp/en/index.html this URL, divided into host = yourhost, context = yourapp, path = en / index.html. The context portion is obtained by request.getContext (), and the PATH section is obtained by request.getServletPath () (the return result is "/en/index.html").

The Tomcat Web Server running on your YourHost host receives this URL. According to Context definition, map yourapp this network path to yourapp_dir / webApp, and locate the EN / INDEX.html file in this directory, return to the client.

If we replace this URL to http: //yourhost/yourapp/en/index.jsp, this time Tomcat will try to compile the yourapp_dir / webapp / en / index.jsp file into servlet, and call the running servlet.

We will replace this URL to http: //yourhost/yourapp/en/index.do.

Note that drama occurs at this time, the most important class requestdispatcher in the servlet specification debut. RequestDispatcher calls the corresponding servlet to process the corresponding servlet based on the definition of the web-inf / web.xml configuration file. Assume that there is such a definition in Web.xml.

DispatchServlet

Yourapp.dispatchServlet

DispatchServlet

*. do

Then, RequestDispatcher calls the yourapp.dispatchServlet class to process this path.

If Web.xml does not define a servlet that corresponds to EN / INDEX.DO, then Tomcat returns "The resources you requested do not exist".

RequestDispatcher is used in Web Server, or it can also be used in the application for processing steering, resource positioning. For example, we call in the code that handles en / index.do,

Request.getRequestDispatcher ("cn / index.jsp"). Forward (Request, Response), you can transfer additional resource CN / INDEX.JSP.

Almost all Web Frameworks need to define a servlet for its DISPATCH, and call RequestDispatcher for steering processing.

Read the web framework source code, there are two main clues, (1) Find the corresponding servlet class according to Web.xml; (2) Search for code files that contain "RequestDispatcher".

We see, request, response these two parameters, transferred by RequestDispatcher between various servlets (JSP is also servlet). Therefore, the REQUEST's setAttribute () and getAttribute () methods are the main ways of transmitting data between servlets.

In the MVC structure, the general processing flow is as follows:

Processing the basic unit of HTTP Request is generally referred to as Action, is a much more lightweight interface definition than servlet, usually only one or two methods, such as Execute (Perform), Validate, etc.

We know that URL-> Servlet mappings are defined in the web.xml configuration file, but the MVC framework usually has another configuration file that defines the URL-> Action mapping.

The entry Dispatcher Servlet forwards the request to the Action according to the mapping between the URL -> Action.

Action gets the input parameters, calls business logic, and returns the result data and the View Identity to the Dispatcher Servlet.

Dispatcher servlets are positioned according to this View identifier, and the corresponding View Template path is positioned to transcribes the processing to View (JSP Taglib, Velocity, Free Marker, XSL, etc.). View typically obtains results data via request.getattribute () and is displayed to the client. As for who sets the result data to the Request.attribute, there are two possibilities: Action or Dispatcher Servlet.

2. Struts

http://struts.apache.org/

Struts is currently the largest user base, developing vendors support the most open source web framework.

Struts has high hard work, making an indelible contribution to the popular MVC framework. The promising prestige tends to aging the thick structure, making Struts a lot of modern web framework, challenges.

The Struts application mainly includes 3 things: configure the struts-config.xml file, implement the Action class, implement view; there are some advanced extensions. The following is described below.

1. Configure the struts-config.xml file:

Struts supports multi-level configuration files, specific usage, and restrictions, see the Struts documentation. The contents of the mainstream configuration of Struts-Config.xml here are discussed here. :-)

(1) Map of URL PATH to ACTION.

Such as

The entrance servlet for Struts is an ActionServlet.

ActionServlet Requires this information to call the URL PATH to call the corresponding Action class.

During the Struts run, a URL PATH exists only a corresponding Struts Action instance. All requests for this URL PATH have been processed by this same Struts Action instance. So Struts Action must thread security.

Think about it, in fact, this requirement is not too far, Action is just a handler, and should not save status data across HTTP requests. It should be made to make threads.

(2) Mapping of Template Name to View Template Path.

Action class returns a template name, ActionServlet obtains the corresponding View Template path based on this template name, and then call

Request.getRequestDispatcher ("View Template Path"), the servlet corresponding to the steering path. In this example, it is a servlet that turns to /pages/welcome.jsp.

Let's take a look at a Velocity.

Web.xml definitions are as follows

velocity

org.apache.velocity.tools.view.servlet.velocityViewServlet

velocity

*. VM

At this time, Request.getRequestDispatcher ("/ pages / welcome.vm") calls VelocityViewServlet, which is responsible and drives run /pages/welcome.vm this template file by VelocityViewServlet.

There is a problem in this, if the dispatchRequester.include () method is called, how can I pass the Pages / Welcome.vm to VelocityViewServlet?

As mentioned earlier, the parameters transmitted by RequestDispatcher have only two, request and response. Then you can only pass the Request Attribute. It is to solve this problem, after servlet2.3 specification, joined Javax.Servlet.include.Servlet_path properties.

See the VelocityViewServlet code (Velocity-Tool open source project)

// if we get here from requestdispatcher.includ (), getServletPath ()

// Will Return The Original (WRONG) URI Requested. The Following Special

// Attribute Holds The Correct Path. See Section 8.3 of The Servlet

// 2.3 specification.

String path = (string) Request.getaTRibute ("javax.servlet.include.servlet_path");

From here we can see why the Servlet Specification is critical to the WEB FRAMEWORK.

(3) definition of Form Bean

Such as

Struts form bean needs to inherit the Actionform class.

The Form Bean class has three main functions:

[1] According to the definition of beans, the REFLECTION mechanism is used to automatically convert the Request parameter to the required data type, and fill in the properties of the bean. Although the Actionform class name has form, but not only gets the HTTP POST parameters submitted after the Form, or you can get the HTTP GET parameters of the URL suffix.

[2] Enter verification. Users can configure validation.xml to define verification rules for each property.

[3] is used as View Object. Users need to master the usage of struts HTML Taglib to display the properties of the Form Bean correctly.

(4) Other definitions. See the Struts documentation for details. No longer.

2. Implement an action.

The Action class gets the input parameters from the Form bean or directly from the Request, calls the business logic, put the result data (may be packaged into view object), put it in Request.SetAttribute (), and finally returns a Template packaged with Forwardmapping class. Name.

3. Implement View.

The standard implementation method of Struts View is JSP Struts Taglib, where the most important thing is Struts HTML Taglib. HTML: Form TAG is the core of the entire HTML TAG, others such as HTML: INPUT, HTML: SELECT, etc., are included in HTML: Form Tag.

HTML: Form Tag is used to map Form Bean (you can also map other Beans by proper definition, but there will be a lot of troubles). HTML: Form TAG includes other Struts HTML TAGs to map the properties of the Form Bean.

The use of Struts Bean Taglib is bloated, in general, can be replaced with JSTL. Of course, if you need to use Bean: Message Tag to achieve internationalization, then it is another matter.

Struts Tile Taglib is used for page layout. Open Source Portal Project Liferay uses Struts Tile Taglib as layout control.

4. Advanced extension usage

Users can overload some of the control classes of Struts to introduce some of their custom classes. See the Struts documentation for details.

This article is not a struts topic, only tells the most important mainstream usage, other side angle, no longer repeat it.

3. Webwork

http://www.opensymphony.com/webwork/

Webwork is popular with many senior programmers due to flexible pluggable features. It seems that it is likely that it is popular.

The WebWork project is built on the XWork project. The entrance servlet is the servletdispatcher defined in the WebWork project, and the Action is defined in the XWork project.

The Execute () method of the XWork Action interface does not have a parameter, unlike Struts Action, accept the request, response parameter, so XWork Action can be directly called from the Web environment and facilitate unit testing.

A problem introduced here. Without the request parameter, how do XWork Actions get request parameters as input data? And what bridge (Struts uses request.setttribute to transfer the result data to the View layer?

In Web Work, you can only transfer input parameters and output results through the getter, setter property of the Action itself.

For example, we have such a class that implements the XWork Action interface.

Youraction implements action {

INT productID = NULL;

String productname = NULL;

Public void setProductId (int productID) {this.productid = productId;

Public String getProductName () {return productname;}

Public string execute () {

ProductName = FindNameById (ProductID);

Return "Success";

}

}

The productId in this class will accept the Request input parameter, and the productName is the result of output to the page display.

For example, such requests, http: //yourhost/yourapp/myaction.Action? ProductId = 1

Web Work will fill 1 in the youraction's productID, then execute the execute () method, the statement in JSP will display your youraction's productName on the page. If a Web Framework uses this shielded Action's request, the response parameter design, usually use this action and input output data to integrate a solution. Similar situations are also present in TapeStry and Maverick, will later.

When WebWork Servletdispatcher receives HTTP Request, all related information (including Request, Response, Session, Servlet Config, Servelt Context, All Request Parameters), etc., then generate a youraction according to Interceptor configuration information Dynamic proxy class object. In fact, it is this agent object, like the working mechanism of Servlet Filter, all injected Interceptor methods will run in the ACTIO method.

Let's take a look at the status of Action and Interceptor: Action does not have a parameter, and the actionContext cannot be obtained; and the interceptor accepts an ActionInvioication parameter has all important information including ActionContext.

This kind of power distribution is not equally, and it is destined to have a very limited role, limited to the calling business logic, and then returns a success or not. All the external Web World is derived, coordinating the burden of internal workflows, all on the shoulders of Interceptor.

We can imagine an extreme example. We declare a batch of empty Actions that do not do anything, we just need their empty-shell class; we make a group of corresponding interceptor, all forwarding control, business logic is implemented on Interceptor, then impart Interceptor to correspond Empty Action. This is theoretically feasible.

In the surroundings of the Web Ocean, Action can be less, interceptor is not. Action is an island that can only operate independently in your small range (such as UNIT TEST) in its own small range.

Let's take a look at how the action works under Interceptor's full supervision.

In Webwork, we need to configure xwork.xml as follows.

Youraction.jsp

The relevant definition inside WebWork-Default.xml is as follows:

As can be seen from the above configuration information, youraction executes the execute () method before and after

The three Intercepter interception defined by DefaultStack. One of these Interceptor tasks is to set the input parameter to the corresponding attribute of the action.

If we need to join the verification feature of the property of your analog, you can add the validation interceptor in the above definition to the defaultstack. Of course, the actual work is not so simple. In general, it is necessary to configure a validation.xml for each Action that performs attribute verification.

XWork Interceptor can intercept the intercept at the Package and Action level.

Servlet FILTER can intercept at the URL Patten level. Although in fact, servlet filter is servlet, but in some cases, the same effects of Action can be reached and intercepted.

For example, in the Web Work, we can add an interceptor for all admin package, when checking to the current session without admin privilege, unified returns a warning page: You don't have enough permissions to perform this action. We can also define a servlet filter for all URL Pattern's URLs "admin / *. Action", when checking to the current session without admin privileges, unified returns a warning page: You don't have enough permissions to perform this action .

WebWork's Interceptor configuration is quite flexible, equivalent to Action AOP. Interceptor is equivalent to Aspect, base class AroundInterceptor's Before (), and after () method is equivalent to Advice.

In addition, XWork also provides mechanisms for assembling Components from an XML configuration file, equivalent to IOC for Component.

Refer to AOP and IOC, and more words will be said. Spring AOP can intercept all Interface, not limited to a particular interface; Spring framework supports all types of IOCs, not limited to a specific type.

To know, AOP, IOC is the most fashionable thing now, don't miss it. : D

Related concepts (if needed, search the network with the following keyword):

AOP - Aspect Oriented Programming - Aspects of programming.

IOC - Inversion of Control - Control reverse

Dynamic Proxy - Dynamic Agent, the characteristics introduced by JDK1.4. It is also possible to further refer to open source projects such as CGLIB, ASM.

Webwork directly supports all mainstream view - XSL, Velocity, FreeMarker, JSP. Webwork also provides its own taglib. "Direct support" means that it is also necessary to introduce auxiliary bridge velocity-tool when using Velocity like Struts.

Used in WebWork and XPath-like objects for imperfective language ONGL is an open source project. ONGL is also used in the TapeStry project to be described below.

There is also a SiteMesh project under OpenSymphony, controlling the layout through the Servlet Filter mechanism. Can be used in combination with WebWork.

4. Tapestry

http://jakarta.apache.org/tapestry/

Tapestry has recently been suddenly fired, making me feel surprised. Perhaps the Page Component trend brought by JSF has begun to pay attention to and chase TapeStry.

One of Tapestry's important ideas is Page Component.

As mentioned earlier, XWork automatically maps the Request parameter to the properties of the Action. Tapestry is far more, and can even map to the Action (TapeStry, called page), and map the request parameter to the parameters required by the PAGE method to perform the correct call. In this way, Tapestry not only outputs the input data, but also binds the event method to the top of the Page.

In the Tapestry framework, the concept of action is very blurred, replaced with the concept of page. Tapestry Page is a page component with attributes and events, where the event processing unit is equivalent to the responsibility of the Action, and the attribute part plays a model role.

In addition to using Page and other TapeStry page components, users can customize page components.

The programming model of this page component / attribute event is welcomed by some programmers. Of course, this programming model is not free, and each TapeStry template file requires a corresponding .page file. These.page files define the properties, events, validator, etc. of the page components.

Let's take a look at the B / S structure, the basic principles of the event, event, and HTTP Request binding. A page component (such as Link and Button) that can be issued, when you output your own HTML, you need to output some special information to mark the properties / events of this component, which will take this information next time. Bring back so that Web Framework is identified to identify and send it to the correct Page Component process.

These special information are typically included in the URL parameter or HIDDEN INPUT, and some Java Script needs to be generated when necessary. TapeStry, Echo, JSF is this principle.

The example of TapeStry is as follows:

JSF implements page components with Taglib and also provides similar COMMANDLINK and CommandButton Tag. Where the TAG attribute of the TapeStry Listener is an action. It will explain it later.

Tapestry's template label is an extended HTML tag, with a good "see" "", you can directly display directly in your browser, which is also a highlight of Tapestry.

5. echo

http://sourceforge.net/projects/echo

Echo offers a set of Swing page components that generate HTML directly.

From the perspective of programmers, write a web program with Echo, and write Applets with SWING, which belongs to pure faceless component event programming, and the programming model is also in the EVENT / LISTENER structure.

Echo doesn't have Dispatcher Servlet, and there is no configuration file that defines the URL-> Action mapping.

Echo's Action is a servlet that implements an ActionListener interface (parameter ActionEvent).

So, Echo is directly converted by the web server according to the URL -> Servlet configuration of Web.xml.

Echo also has no obvious view layer, and Echo has far farther in page components, all HTML and JavaScript are generated by the framework. You don't have to (nor ways) write HTML, just need (can only) in the Java code, in accordance with Swing programming, generate or operate the user interface. Users can also customize their own ECHO components.

Echo's UI Component is implemented, two important modes. One is the peer (Component -> Componentpeer) mode, one is the UI Component -> Renderer mode.

Although Echo's API is more similar to Swing, it is achieved by PEER mode closer to AWT. Each Component class (representing abstract components, such as Button) has a corresponding Componentpeer class (representative of actual components, such as Button, Linux desktop, HTML Button, etc.) of Windows desktops. Don't worry, this thing is not yet. Although ComponentPeer implements a specific interface control, it is still reluctant to show yourself and further hand over the display work to a renderer.

For example, in echo, the Button class corresponds to a Buttonui class, and this ButtonUI class will handle the final display to ButtonRender.

It is said that it is more than a step, which will make the display control more flexible. For example, the same rendere can handle different UI Component, and the same UI Component can also be handed over to different renderer processing.

The JSF page component also uses the UI Component -> Renderer mode, followed.

6. JSF

http://java.sun.com/j2ee/javaserverfaces/index.jsp

http://wwws.sun.com/software/communitysource/jsf/download source.html Download Source

The central idea of ​​JSF is also a page component / attribute event. In general, JSF's page components are a three-piece {UI Component, Tag, Renderer}.

UI Component is likely to correspond to Model, Event, Listener. TAG contains two properties of ComponentType and Rendrertype, which are used to select the corresponding UI Component and Renderer.

The application core of JSF is undoubtedly JSF Taglib. The JSF Taglib contains Tags corresponding to all important HTML elements, and the input tag can directly contain the Validator Tag or Validator property to define the verification means.

We look at the JSF's processing flow through the Cardemo examples carried by JSF.

(1) Cardetail.jsp has the following:

It can be seen that this Button's Submit Action and Carstore.BuycurrentCar methods are bound together. We have seen similar scenarios in Tapestry.

(2) CARSTORE defines in Faces-Config.cml:

carstore

carstore.carstore

session

(3) The BuycurrentCar method in the CARSTORE.CARSTORE class is as follows:

Public string buycurrentcar () {

getcurrentModel (). getcurrentprice (); return "confirmchoices";

}

(4) Confirmchoices Turn in Faces-Config.cml:

/cardetail.jsp

Any Action That Returns "Confirmchoices" on Cardetail.jsp Should

Cause navigation to confirmchoices.jsp

confirmchoices

/confirmchoices.jsp

(5) Then go to the page CONFIRMCHOICES.JSP.

In addition to Interceptor, JSF has almost all features that modern Web Framework should have: page components, attribute events, IOC (Managedbean), Component -> Renderer, Model-Event-listener similar to Swing Component.

Perhaps the designer believes that numerous patterns ensure that JSF is a successful framework. Portal Open Source Project EXO is built on a JSF framework.

It can be seen that modern Web Framework believes that the state of stateless features and HTML interfaces are required for programming, so as far as possible to simulate the components and event mechanisms of the C / S structure to attract More programmers.

7. MAVERICK

http://mav.sourceforge.net/

MAVERICK is a lightweight and complete MVC Model 2 framework. Maverick's Action is not called Action, and it is called Controller.

Controller only accepts a controllerContext parameter. Enter information such as Request, Response, Servlet Config, ServelT Context is packaged in ControllerContext, and Model also returns through the Model property of ControllerContext. The entire programming structure is clear and soon, appreciating.

But this world is difficult to have perfect things. Since the ControllerContext has only one model attribute to pass data, the programmer must pack all the required data to set to the Model property in an object. This kind of trouble will naturally lead to such a possible usage, directly set the Controller itself as Model, which returns to the Controller (Action) and the Model.

As mentioned earlier, WebWork also wraps all the input information in ActionContext, but Action does not work. In MAVERICK, Controller has full control for ControllerContext, and the status is not synonymous. Of course, since the parameter controllerContext contains request, reponse, this means that MAVERICK Controller cannot run independently from the web environment as Web Environment.

Of course, this does not mean any structural defects. The structure of the program is controlled by yourself, you can completely remove the part of the Unit Test from the web environment, put it in the business layer. Like Webwork, Maverick directly supports all mainstream view. MAVERICK's configuration file mining struts, Cocoon, the main structure of the URL -> Action-> View map is similar to Struts, and the View definition part of the transform is similar to Cocoon. Such as:

8. Spring MVC

http://www.springframework.com/

Spring MVC is the clearest MVC Model 2 I have ever seen.

Action is not called Action, accurately calls the Controller; Controller receives the request, the response parameter, and simply returning ModelandView (where Model is not Object type, but the MAP type).

In other web framework, the Action return value is generally just a view name; Model needs to pass through other channels (such as the request.attribute, the Context parameter, or the attribute data of the ACTION itself).

Spring is in the world with a trick, and its AOP is also in the like. The concept of "Spring produced, must be boutique" has been deeply rooted. I also said more here, I strongly recommend readers to read Spring Doc & Sample & Code itself.

9. Turbine

http://jakarta.apache.org/turbine/

Turbine is a solid framework that provides perfect permission control (Fulcrum sub-projects are their cornerstone). Turbine's personal users, but many company users choose Turbine as a framework, develop some serious applications (I didn't say, using other framework development is not serious ^ _ ^). Portal Open Source Project JetSpeed ​​is built on Turbine.

Turbine uses Rundata to pass the input output data. Like the MAVERICK's ControllerContext, Rundata is the data exchange center of the entire Turbine framework. In addition to basic information such as Request, Response, Rundata directly includes permission control related to User / ACL, and other positioning properties such as Action Name and Target Template Name.

Module is another core class other than Rundata, which is the basic component of the Turbine framework. Action is Module, Screen is also Module. Turbine provides two Actions of Loginuser and Logoutuser as an entrance to the entire system. The permission control of the remaining flow is controlled by a Pipeline control similar to the Servlet Filter mechanism.

Turbine Pipeline programming model and servlet filter: Turbine Pipeline's Valve is equivalent to servlet filter, and ValveContext is equivalent to Filter Chain. There are also more similar examples, and the Tomcat source code also has two classes, not only the same as the model, but also the name. Permission control runs through the Turbine framework. To use good turbine, you should first implement the permissions to achieve the permissions of the Security section of the child project Fulcrum.

Fulcrum Security's permissions include four-user, group, role, permission.

The entity includes {role, permission}, and {group, user, role} two sets of relationships.

{Role, Permission} is multi-to-many relationships, and a role can have a variety of permission; {group, user, role} is multi-to-many relationships, a group can contain multiple USER, and can be assigned to USER Role.

The implementation of the authority model also uses Peer mode, Entity -> EntityPeer, Entity-> Managerpeer.

Entity and EntityManger represent the abstract model concept, while EntityPeer and Managerpeer represent the specific implementation.

The user can provide different implementations, for example, with a memory structure, with the data table structure, combined with the Windows NT permission verification mechanism, combined with OSWORKFLOW, and so on. Among them, the data table structure is used, but also the TORQUE is implemented, or the Hibernate is implemented. (Torque is Turbine's O / R Mapping subproject)

For example, the Falcrum.Property profile contains the following Security Related options:

# ------------------------------------------------- ------------------

# S e c u R I t y s e r v i c e

# ------------------------------------------------- ------------------

Services.securityservice.user.class = org.apache.fulcrum.security.impl.db.Entity.TurBineuser

Services.securityService.user.Manager = org.apache.prum.security.impl.db.dbuserManager

Services.securityService.secure.passwords.algorithm = SHA

# ------------------------------------------------- ------------------

# D A T A B A S e S e r v i c e

# ------------------------------------------------- ------------------

Services.Database.newapp.driver = org.gjt.mm.mysql.driver

Services.Database.newapp.url = jdbc: mysql: //127.0.0.1/newappservices.DatabaseService.Database.newapp.username=turbine

Services.Database.newapp.password = Turbine

This description, the permission control is implemented by the database, and the following data table needs to be created according to the permissions model:

Turbine_user, turbine_role, turbine_group,

Turbine_Permission, Turbine_Role_Permission,

Turbine_user_group_role.

10. Cocoon

http://cocoon.apache.org

The CoCoon project is a framework called good. With the XML XSLT PIPELINE mechanism, the Java program only needs to output XML data, and the CoCoon framework calls the XSL file to convert XML data into HTML, WML and other files.

Cocoon's powerful and flexible XSL Pipeline configuration function, XSLT content / display separation commitment has attracted many programmers Fans. How do I not want to be willing to have a restriction in complexity, speed bottleneck, XSL learning difficulty, Cocoon has always been mainly limited to the field of publication, and continuously evolving to the direction of CMS and PORTAL. In addition, CoCoon developed XSP scripts and Cocoon Form technology.

Cocoon's SiteMap.xmap configuration file is more complicated, and it is very different from other Web Framework.

The main PIPELINES configuration section uses Pattern Match, which is very similar to the XSL syntax, or less than the definition of servlet mapping in Web.xml. For example, a typical URL-> Action map definition looks like this:

Value = "context: //docs/department-form.xml" />

Value = "context: //docs/department-form.xml" />

11. Barracuda

http://barracudamvc.org/Barracuda/index.html

Barracuda is a framework for an HTML Dom Component Event / Listener structure.

Generate static Java classes based on template files or profiles, and use these generated classes in the code, is a major feature of Barracuda.

Barracuda needs to use the XMLC project to store all HTML or WML template files to the DOM structure of the Java class as page components. XMLC will generate a simple operation method of the corresponding DOM node according to the ID definition of the HTML element.

Barracuda's event class also requires the Barracuda Event Builder tool to compile Event.xml into a Java class, introduced into the project. Barracuda directly uses the father and child hierarchy between the inheritance relationship of the Java class. For example, ChildEvent is a subclass of Parentevent.

Barracuda's events are divided into two categories: Request Events (Control Events) and Response Events (View Events).

The Barracuda event handling process is very similar to the processing mechanism of the Windows system message queue.

(1) Barracuda generates request event according to HTTP Request, and places it into the event queue.

(2) EventDispatcher Checks if the event queue is empty, if it is empty, end. If it is not empty, take an event from the event queue in the event queue, according to the advanced first out, according to the type of event, select and call the most suitable EventListener, parameter Event Context contains the event queue.

"According to the event type, select the most appropriate EVENTLISTENER object" is like this: for example,

EventDispatcher takes an event from the time queue, the type is ChildEvent; Barracuda first looks for EventListener registered to listen to ChildEvent, if you can't find it, then go back to ChildEvent's parent class ParenteentEvent, see which EventListener is interested in Parentevent.

See the DEFAULTEVENTDISPATCHER class in Barracuda in detail.

(3) EventListener calls business logic, obtains the results data according to the request information contained in Event Context, and then adds new events into the event queue of Event Context according to different situations.

(4) Control is returned to EventDispatcher and return to step (2).

.

Enjoy.


New Post(0)