Turbine

zhaozj2021-02-17  159

Originate

JetSpeed ​​is an open source portal system for the Apache Jakarta team. It enables end users to use a wide variety of network resources (such as applications, data, and any network resources other than) through various devices such as WAP phones, browsers, and PDA. Here, JetSpeed ​​played a role of HUB in information and users.

Around 1999, JetSpeed ​​project and started. Soon, JetSpeed's development beyond the initial goals, and it is difficult to imagine the speed of imagination. With the Jakarta group, it is: "The Only Problem is That this was beyond the scope of this project.".

Now, JetSpeed ​​has gradually evolved into a web application engine that is based on Turbine (also masterpieces of the Jakarta Group). "Frameworks).

1.1 JetSpeed

Simply put, JetSpeed ​​is Turbine that adds the portal component. It is both a portlet container, and a large number of practical portlets. In JetSpeed, the management of portlets is mainly completed by the following two files:

l.xReg registration file

l.psml configuration file

.xreg files are typically placed in a webApp-name / web-inf / control directory, file name is not limited. A portlet must be registered with the .xreg file to use in JetSpeed. Each portlet component can be instantiated by the system to output a Java class for a particular web document.

.psml files are typically placed in a webapp-name / web-inf / psml directory, the file name is not limited. .psml sets the display mode of the page content, such as how the page is layout, is divided into many columns, how many panes can each column, the contents of each pane are output from which portlet output.

2. Overview

Turbine is a servlet-based Web Application Frameworks that enables Java developers to build their own web applications quickly and secure.

Turbine is a complete MVC application framework, mainly consisting of the following parts:

l Specification layer: Velocity (also masterpiece of the Jakarta team, a Java-based template engine) or JSP

l Data layer: Torque and Peers

l Control layer: Turbine

l HTML FORM VALIDATION: INTAKE

l Log: Log4J and Turbine2 Logging Service

l Service Frameworks: Turbine (in Turbine3, this section is called fullcrum)

This article mainly introduces the control layer in Turbine, and the rest, please refer to the site mentioned in the respective documentation or reference materials.

3. Foundation

Turbine is mainly composed of five parts, as shown below:

Let's introduce these five parts, and introduce the detailed process of Turbine.

3.1 Action

Action is a module that performs a specific transaction. The SessionValidator in Turbine is a typical action.

When the user submits an HTML form, there is an implicit field that contains the information that will be executed. The Action mechanism allows Java developers to process the data submitted by the user. For example, for "logout" transactions, multiple places in the system may be called; therefore, writing logout transaction flows into a reusable module so that this transaction can be more convenient. This reusable module is an action. Through a variety of activities in the system, each Action handles different information in user data, so that the entire system is more simple and faster, more easy to write, expand and maintain. And, Turbine can make the program process more flexible through the Action mechanism. For example, during the processing of Page, it can be assisted to determine which Screen will be displayed by performing a specific action. At this time, the execution result of the Action can be used as a basis for the judgment of future procedures.

Action is a reusable transaction processing component in the system, which makes Turbine have flexible and clear transaction processes.

3.2 Page

The PAGE module is a module that is first performed during the page generation process, which can be considered an action, layout, screen, and navigation coordinator and organizers.

In general, Page first performs the specified action in the user request; then, according to the SCREEN to be loaded, the corresponding Layout is selected and executed. Please note that at this time, which Screen is executing, it may change because of the Action execution results. Also, Screen's Layout may also change due to the settings of DefaultLayout due to Turbineresources.properties configuration files.

3.3 Screen

The SCREEN module is fundamentally, it is the "torso" of the webpage. This is also where the HTML code is generated in the web page. Screen is the most important representation of the entire TURBINE (VIEW).

Screen is called by Layout.

Please note: At this point, you can call a variety of external modules, such as EJB, to get data to build your HTML page. You can also build the page content by JSP, even using blog.

3.4 Navigation

Under normal circumstances, the website has its own TOP & BOTTOM Navigation; however, they are usually called header or footer. Like Screen, Navigation is also called by Layout.

Not only as Header or Footer, Navigation can also appear in the form of MENU or Tree View.

3.5 Layout

Layout is called by Page, which can be considered to be SCREEN and Navigation containers.

Layout typically define each Navigation, Screen, which is displayed on the page.

It can be seen that the package relationship between the various module objects in Turbine is roughly as shown below:

From the above figure, we can also see that each element in Turbine is encapsulated, enabling the HTML page in front of us in a template. Why is this this? The Jakarta team is explained to us: "this is no account, the turbine framework is essentially an object oriented representation of the components of an html page." 3.6 Loader

In addition to the five components mentioned above, there is still another component in Turbine: Loader.

Loader is responsible for dynamic loading of five components mentioned above. These Loaders can keep the five components objects in memory to form a cache, speed up the program response.

Loader identifies these components by profile: Turbineresources.properties. Loader is equivalent to ClassLoader in Java; and Turbineresources.properties seems to be "Loader ClassPath", helping Loader recognizes each component. In this way, Turbine can ensure that our Web Application can always be loaded and implemented correctly.

4. Process

So far, I believe that the standard control flow for Turbine has been on the chest:

In Turbine-based Web Application, only one servlet (Turbine Servlet) is used to receive user requests. When this servlet receives the request, by analyzing the data, determines which page of LOAD; if necessary, Page performs the specified action; then loads the specified layout; finally, call Screen and Navigation by the Layout and Navigation to generate the web page .

4.1 Turbine Standard System Flow

In a common Turbine application, Turbine Servlet generally follows the processing flow below:

1. When a new request comes to, Turbine Servlet first checks if the HttpSession instance exists. If there is no HTTPSESSION instance, the "homepage" (this "homepage" (this "HomePage" is directly redirected to this URL is Login Screen. Of course, you can also point it to any of your hopes in Turbineresources.properties.

During the redirection, Turbine also records a unique identifier for this visitors in cookies; if the client browser does not support cookie, Turbine activates "session tracking", so that this user's identity is included in the future URLs. information.

2. After the user session is established, Turbine caches some of the frequently used data to the Rundata instance.

3, then the Turbine Servlet checks if the user is trying to log in. The method is whether the Action defined in the request is "loginuser" (of course, it can still be customized in the Turbineresources.properties file). If so, this action is executed. Unlike other Action, this "loginuser" action must implement a user identity verification, and call the Rundata.Save () method (indicating that you have verified).

4. Whether the user verification is passed or not, Turbine Servlet calls SessionValidator Action. SessionValidator Action Checks if the user is already logged in, if any, update the timestamp of the last login; otherwise redirect to "Login" Page. Here has a trick: If you want your page to have permission protection, you can call SessionValidate Action in the Layout of these pages. Or if your system does not need to log in, you can replace the default version with a simple SessionValidate Action version that only returns NULL. 5, then the Turbine Servlet calls "defaultpage". "DefaultPage" will start a series of transaction: call an action (if any), perform Layout, etc.

6. After the Layout is processed, the system flow ends, the Turbine Servlet returns the requested page information.

5. Rundata

See here, you may have a common question, that is: After such a multi-layer call, how is the data included in the user request? The answer is Rundata.

In the description of the SYSTEM FLOW section, we can see that the Rundata records information through the Rundata.Save () method. In fact, Rundata acts primarily to transmit parameters throughout the framework. The Rundata instance can save database connections, GET / POST / PATH_INFO (GPP) data, Action, and Screen names, and Document instances of output HTML. Also, you can also save information requiring persistence in Rundata.

have to be aware of is:

L Because the Rundata instance is not a thread, the Rundata instance is recreated each time the request is re-created, and will never be saved to the global context.

l In each Request request, there may be only one Rundata instance.

In addition, in turbine2.2, Rundata has become public interface from the Public Class in 2.0. But the method of use is constant.

Reference

1, http://jakarta.apache.org/turbine/, Turbine official site.

2, http://jakarta.apache.org/turbine/fsd.html, functional specification document.

3, http://jakarta.apache.org/jetspeed/, JetSpeed ​​official site.

4, http://jakarta.apache.org/Velocity, Velocity Official Site.

5, http://db.apache.org/torque/, Torque official site.

6, http://jakarta.apache.org/turbine/fulcrum/howto/intake-service.html, intake Introduction.

7, http://jakarta.apache.org/log4j/docs/index.html, log4j official site.

8, http://jakarta.apache.org/turbine/fulcrum/index.html, Fulcrum Official Site.

9, http://www.bluesunrise.com/jetspeed-docs/, JetSpeed ​​Third-party document set.

10, Li Jianhua, "Turbine Exploration", "Programmer" 2003.07.

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

New Post(0)