Http://hedong.3322.org/ Cocoon read [KE'KU: N], the meaning of 茧.
I saw a few articles to talk about Cocoon, because there were too many stars, and after watching the fog, I learned the heart.
I found a lot of Cocoon, IBM: Developerworks, IBM: DeveloperWorks, China. Here is to learn notes, I feel interesting, I will write down.
The following three lines are the command of the source code. CVS -D: PServer: anoncvs@cvs.apache.org: / home / cvspublic login cvs -d: pserver: anoncvs@cvs.apache.org: / home / cvspublic -z3 Checkout -r Cocoon_20_branch XML-Cocoon2 CVS -D: PServer: anoncvs@cvs.apache.org: / home / cvspublic logout pipe consists of some input data and some processing steps thereof. Each processing step accepts the output of the previous step as an input, which is always reached the end of the pipe and produces the final output.
Cocoon contains many conventional pipelines, depending on the roles played in the pipe, they are divided into several completely different types.
Pipe input - generator (such as FileGenerator, HtmlGenerator, DirectoryGenerator), and reader (common to read static file) Processing step-converter (such as XSLT converter) and operating pipe output-serializer (such as XML, HTML, SVG, PDF sequencer) Treatment - Matcher and Selector
Cocoon pipelines are typically consisting of at least a generator and sequencer, but may contain any number of processing steps. Transfer data as a SAX event via Cocoon Pipeline.
The logical period for the receiving request and the service providing service is as follows: 1. Requests from the user. 2. Determine the appropriate pipe used to explain the request and generate a response (using a match). 3. Construct the pipe from the available pre-configured components. 4, indicating that the pipe is a request service. 5. Returns the response generated by the pipeline back to the user, and the results may be cached for the results for later use.
Site Map (SiteMap) Two functions: 1, declaration components; 2. Define pipes.
The XML Server Pages (XSP) compilation process is shown below:
XSP Syntax: 1, XSP: Page element is the root element of each XSP document. It must have a programming language that identifies the page - specifically, "Java" - language properties. This page element may include: any number of XSP: structure elements any number of XSP: logic elements Single user elements This last restriction is very important. "User Elements" means any element that is not in the XSP namespace, including an element without a namespace. This restriction is because user elements become the root element of the XML document created by the XSP page, and the XML document can only have a single root element.
2, XSP: Structure and XSP: include elements are used to provide these additional tips to the code generation process. These two elements are used before, Xsp: structure elements combine many XSP: include elements. Each XSP: Include defines an additional Java package or class to be imported.
3, XSP: logic elements are used to add Java code blocks to XSP. Anywhere in these elements as an XSP: PAGE element (other than, single user elements), this code block should contain methods definitions and / or member variables. This is the existence because the code that appears outside the user element is not included in the generate () method of the generator. Conventional Java grammar rules means that this code must be a member or class (that is, static) variables or methods. XSP: logic elements can also be used elsewhere in the XSP page. In this case, they should include a Java statement that will be added to the generate () method in the compiled generator. This makes the XSP: Logic element similar to the <% ...%> Scriptlet syntax used in the JSP page. 4, CDATA section, it emits signals to the XML parser to do not adopt good format rules for that season.! [Cdata [...]]>
5, XSP: EXPR element is used to encapsulate an expression that will be added directly to the output document. In contrast, the XSP: logic element contains the code of the generator. Therefore, the XSP: EXPR element is equivalent to implementing the <% = ...%> expression syntax of similar roles in JSP. For example:
7, by using XSP: Attribute>
8, XSP: Comment and XSP: PI elements are used to create annotations and processing instructions.
Logic orders are custom-made libraries that can be added to the XSP page, which is implemented by using XSLT conversion. These conversions introduce additional code blocks and / or XSP tags into the XSP document, which extends the ability to generate the Generator class. Each logic is associated with a special namespace. Using logic only involves declaring the corresponding namespace in the XSP document and then adds elements from that name space when needed. Such as
Note that page declares the utility namespace http://apache.org/xsp/util/2.0, and use an additional element without inserting any additional Java code. This page is generated when it evaluates it:
Cocoon 2 provides many pre-defined logic orders, providing a large number of useful features without having to write Java code. Based on these predefined logical orders, they can loose classification: 1, Environmental logic list - provide access to the Cocoon handling environment (for example, requests and responses), and below: 1) Request logic single provides access to request attributes, including access to request parameters, request methods (eg, Get, Post, POST, etc.) and request title. This logical order is particularly useful when the request parameters are used to change the generation of the output document. 2) Response logical order provides restrictions on HTTP response associated with the current request; it only provides access to request titles. The XSP document cannot be performed with the same method as the Java Servlet or JSP page, because the separation problem is the core part of the Cocoon 2 architecture. This feature is described in the website map; the XSP page generates XML content without guiding processing. 3) The session logic single provides access to HTTP session information, including the ability to create and delete sessions, and adding and removing session properties. Obviously, this feature is most useful in Web applications that must be maintained for the context. The session management in Cocoon 2 is exactly equivalent to its JSP opponent. 4) The cookie logic provides the cookie maintenance feature, such as adding and removing the cookie, allowing priority to the user's browser. 2, utility logic single - multi-purpose utility code (for example, files include, logging, sending mail, etc.) have three logic orders, each of which provides some simple utility. 1) Date and time
2) When the log (log) logic manner processes the user request, it allows you to write log messages from the XSP generator. Such as:
3) Send mail (Sendmail) logical list contains a useful element that provides access from the XSP page to JavaMail API, such as
3, Data Operation - Provides access to data verification and access to the database with two logical orders belong to this category, one of which provides more than another significant function.
Form Validator logic will never be used separately. It provides a neat interface to the Cocoon Form Validator Action. This behavior can perform basic authentication operations on data from the HTML form to the Cocoon application, including checking the minimum and maximum values of the integer, check the size of the string, and some parameters provided. A famous function is to test whether the transfer variable matches a given regular expression. The result of the verification is stored in the request parameter. The Validator logic single provides a method of explaining these results from the XSP page. This allows the user to dynamically generate an error message.
After the data is confirmed as valid, the next step is to store the data into the database. ESQL logic provides a way to perform this step and provides more features, including selection, deleting, and updating databases. Essentially, the ESQL logic provides a way to embed the SQL statement directly to the XSP document. This logic then generates the corresponding JDBC code to implement SQL operation, which simplifies the operation and retrieval of database data by using Cocoon 2.