webx--Borrow Petstore Quick Start __web

Source: Internet
Author: User
Tags error handling git clone
Preface

This blog record to Ali Internship's first task –WEBX framework learning, will continue to update learning experience. Configure the corresponding environment to run Petstore through the official website to the command line method, to run Petstore Petstore is Java EE Classic learning case, download link how to run it. See the official website to guide: WEBX official website

git clone https://github.com/webx/citrus-sample.git
cd citrus-sample/petstore
mvn clean install
CD Web
MVN Jetty:run-war

MAVEN is a huge project management tool, similar to C + + makefile, will look back on the use of MAVEN specific. The following is a summary of the problems encountered in performing the above:

Download configuration maven: Download the MAVEN link, note that Maven runs require JDK, not just JRE, otherwise prompts for corresponding error;
MVN Jetty:run-war, execution error, see posts: MVN Jetty:run-war Error Resolution
Jetty ran through the following link to access: Http://localhost:8081/?home use Eclipse to run petstore download Java EE Eclipse, unzip to use, This version of Eclipse has its own maven, no configuration, and with the previous command-line operation, you've got a war package to import the war package into eclipse. The path to the war package is: D:\code\maven\citrus-sample\petstore\web\target\petstore.war. Configure Tomcat to run the Petstore. First go to the official website to download a tomcat:http://tomcat.apache.org/download-80.cgi configured environment, you need to embed Tomcat in eclipse: Windows–preference-server –runtime environment in the configuration. See posts: Tomcat is embedded in Eclipse and runs a JSP file so that you can run Petstore in Eclipse. Supplemented by the above way although can run petstore, but found through the war into the project, and can not read *.java source code. Here, through the command line: MVN eclipse:eclipse, convert the MAVEN project into an Eclipse-aware project, and then import it again in Eclipse, see posts: Eclipse Import maven Project Use eclipse to establish a rapid WEBX project

Through the above steps already can begin to analyze Petstore, facing a new frame, analysis this is still a bit tricky, so, I chose to start from Hello,world project. Here, in Ali Learning, found a WEBX learning video, listen to several times, just slowly understand, Link: Ali learn-webx share. Through this video, the fast-established WEBX project can be effectively studied. install archetype for Eclipse

New MAVEN Project
In the selection archetype interface, the lower right corner has an add archetype, webx-archetype information, warehouse address
At this point, you can quickly build a WEBX project by Webx-archetype-quickstart, and there are basic learning examples, with the previous video tutorials, repeated viewing and operation can be simple and quick to understand the concept. in Eclipse, let the VM template syntax highlight

*VM template file can not be syntax highlighting and automatic completion, write more painful, an installation plug-in address: Veloeclipse plug-in address, during the installation process will encounter errors:

An error occurred while installing the "Items Session": (Profile=epp.package.jee, phase= Org.eclipse.equinox.internal.p2.engine.phases.Install, operand=null–>

[R]com.googlecode.veloeclipse.ui 2.0.8, action=).

Failed to prepare partial IU: [R]com.googlecode.veloeclipse.ui 2.0.8.

At this point, reference posts: Installation Veloeclipse encountered problems solving imitation write a hello,world page driver: On the INDEX.VM homepage, add a HelloWorld hyperlink; Create a screen underneath the Com.zy.first.app1.module.screen.simple package to return to a page that doesn't need to be rendered (refer to the Sayhi.java file). To this point, there is a general understanding of WEBX. Learn WEBX by Petstore Project

Through the previous Webx-quickstart generated example tutorials, you can quickly get started with WEBX. Personally, it is more suitable to understand WEBX concept and running process than Petstore. But Petstore can be called a comprehensive project, and a lot of things are involved. So here, use Petstore to learn some important concepts in WEBX. Many of these things come from the webx3_guide_book.pdf webx level.

WEBX encourages hierarchical design, and the framework itself is hierarchical. The hierarchy is shown in the following illustration:

which

Springext: Provides the ability to extend components based on spring. It is the foundation of the entire framework.

WEBX Framework: Provides basic services based on the servlet API, such as initializing spring, initializing logs, receiving requests, error handling, development patterns, and so on. The WEBX framework is only relevant to servlet and spring-it does not care about some of the services common in the web framework, such as action processing, form processing, template rendering, and so on. So, in fact, you can use the WEBX framework to create multiple styles of web frameworks.

WEBX Turbine: Based on the WEBX Framework, to achieve specific Web page functions, such as: Action processing, form processing, template rendering and so on. Springext

This part is still to be learned, and we know that Springext is completely compatible with the concept and style of spring's original schema, but it can be extended as a schema like program code. WEBX is built entirely on the basis of Springext. This foundation determines that WEBX is a highly scalable framework, and its configuration is flexible, yet easy and intuitive. Springext provides a common extension mechanism. WEBX Framework

The WEBX framework is the first level to really involve web technology. WEBX Framework This level of tasks:

Initializing Spring container

In the Web.xml configuration file, WEBX uses Webxcontextloaderlistener to initialize spring. The WEBX framework will automatically search the XML configuration files in the/web-inf directory and create cascading spring containers. It is a good development practice to decompose a large application into several small application modules and make their configuration files relatively independent. initializing the log system

In Web.xml, WEBX uses Logconfiguratorlistener to initialize the log system. WEBX Response Request

As shown in the following illustration:


*. First, it enhances the functionality of the request, response, and session, and packs them into a RequestContext object that is easier to use. The Request-contexts service can be configured in Webx.xml.
*. Second, it calls the pipeline of the corresponding child application and uses it for further processing.
*. If an exception occurs in the above procedure, the WEBX framework is triggered to handle the exception.
The PIPLINE:WEBX framework gives developers great freedom to customize the process of processing requests. As shown in the figure:

The process of supplementing –webxframeworkfilter processing a Web request, as shown in the following illustration:
WEBX Turbine Design Concept: page drivers and conventions are better than configurations. The agreed rules are as follows:

Let's look at the page layout:

screen, which represents the main body of the page.
Layout, representing the layout of the page.
Control, which represents the fragment of a page embedded in screen and layout. Next, take a look at the process of the page with specific examples:

The process of the page is defined in Pipeline.xml, the following is a http://localhost:8080/petstore/URL to describe the process of the page, webx the framework of the process, Receive requests from Webxframeworkfilter and get to pipeline smoothly. Then pipeline begins to execute its valves in turn. :
*Analyzeurl-Parse URL: Get target, there is no path information, Analyzeurl valve provides an optional parameter "homepage";
* EnterChoose-Multiple branches: Here homepage has no suffix, "homepage" satisfies the first attached condition: target-extension-condition extension= "null";
* Enter this condition:performaction-Execution action,action is used to execute form requests, local requests, and no action, so skip;
*Performtemplatescreen-Find and execute screen. There is a rule to look up screen, and if you find the screen class, do it, the screen class function, usually read the database, and then put the template needed objects into the context. If you can't find it, it doesn't matter--that's "page first": A home page like homepage, which usually doesn't have business logic, so you don't need the screen class, you just have to have a template.
*rendertemplate-Render template. Here are two rules: target maps to screen template, and target maps to layout template. If the screen template is not found, report a 404 error, and if found, follow certain rules to find the layout template, and if so, embed screen in the layout template.
*breakunlesstargetredirected-Internal redirection. Internal redirection is essentially thebreakunlesstargetredirectedImplemented--exit if no redirect tag is in place, otherwise loop toLoopLabel.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.