A document has been updated:
http://cocoon.zones.apache.org/daisy/documentation/1291.html
Document ID: 1291
Branch: main
Language: default
Name: Modularize Cocoon apps (Using blocks) (unchanged)
Document Type: Cocoon Document (unchanged)
Updated on: 5/28/07 1:10:35 PM
Updated by: Reinhard Pötz
A new version has been created, state: draft
Parts
=====
Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name: (unchanged)
Size: 3755 bytes (previous version: 787 bytes)
Content diff:
(2 equal lines skipped)
<p>In the basic tutorial
<a
href="http://cocoon.zones.apache.org/daisy/cdocs/g2/g1/g2/1159.html">"Your
--- first Cocoon application using Maven 2"</a> you have created your first
block.
--- Cocoon 2.2 introduced the concept of blocks because it should help you to
split
--- your application into smaller parts. This increases the maintainability and
+++ first Cocoon application using Maven 2"</a> you created your first block.
Cocoon
+++ 2.2 introduced the concept of blocks because it should help you to split
your
+++ application into smaller parts. This increases the maintainability and
reusability by orders of magnitude.</p>
<p>In this tutorial you will</p>
(7 equal lines skipped)
<h1>Create a second block</h1>
--- <p class="fixme">TBD</p>
+++ <p>For this purpose move into the <tt>getting-started-app</tt> directory
and use
+++ the Maven 2 archetype again:</p>
+++ <pre>mvn archetype:create
+++ -DarchetypeGroupId=org.apache.cocoon
+++ -DarchetypeArtifactId=cocoon-22-archetype-block
+++ -DarchetypeVersion=1.0.0-RC1
+++ -DgroupId=com.mycompany
+++ -DartifactId=<strong>myBlock2</strong> </pre>
+++
+++ <p>The result is a second block and you should find following directory
+++ structure:</p>
+++
+++ <pre>getting-started-app
+++ <tt> +-</tt><tt>myBlock1
+++ | +-pom.xml
+++ | +-src
+++ | +-[...]</tt>
+++ <tt> +-</tt><tt>myBlock2
+++ +-pom.xml
+++ +-src
+++ +-[...]
+++
+++ </tt></pre>
+++
+++ <p>Then run</p>
+++
+++ <pre>mvn install eclipse:eclipse</pre>
+++
+++ <p>in order to make it ready for be imported in Eclipse and to put it into
the
+++ local Maven repository. Then you can import the project into Eclipse.</p>
+++
<h1>Connect two blocks</h1>
--- <p class="fixme">TBD</p>
+++ <p>Let's assume that you want to use a pipeline defined in <tt>block2</tt>
from
+++ within <tt>block1</tt>. You have to establish the connection between the two
+++ blocks. Edit
+++
<tt>getting-started-app/<strong>myBlock1</strong>/src/main/resources/META-INF/cocoon/spring/servlet-service.xml:</tt>
+++ </p>
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
+++ <beans xmlns="http://www.springframework.org/schema/beans"
+++ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+++ xmlns:servlet="http://cocoon.apache.org/schema/servlet"
+++ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+++ http://cocoon.apache.org/schema/servlet
http://cocoon.apache.org/schema/servlet/cocoon-servlet-1.0.xsd">
+++
+++ <bean id="com.mycompany.myBlock1.block"
class="org.apache.cocoon.sitemap.SitemapServlet">
+++ <servlet:context mount-path="/myBlock1"
context-path="blockcontext:/myBlock1/">
+++ <strong> <servlet:connections>
+++ <entry key="block2" value-ref="com.mycompany.myBlock2.block"/>
+++ </servlet:connections></strong>
+++ </servlet:context>
+++ </bean>
+++
+++ </beans>
+++ </pre>
+++
+++ <p>Additionally add the new block as dependency to the block's Maven project
+++ descriptor
(<tt>getting-started-app/<strong>myBlock1</strong>/pom.xml</tt>):</p>
+++
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
+++ <project>
+++ [...]
+++ <dependencies>
+++ [...]
+++ <strong> <dependency>
+++ <groupId>com.mycompany</groupId>
+++ <artifactId>myBlock2</artifactId>
+++ <version>1.0-SNAPSHOT</version>
+++ </dependency></strong>
+++ </dependencies>
+++ [...]
+++ </project>
+++ </pre>
+++
+++ <p>If you use the RCL goal of the Cocoon Maven plugin, you will also want
to add
+++ the location of the new block to the configuration file of block1. This has
the
+++ advantage that you can work on block2 and the changes take effect
immediatly.
+++ Open getting-started-app/myBlock1/rcl.properties and add</p>
+++
+++ <pre>com.mycompany.myBlock1.block%classes-dir=./target/classes
+++
+++ <strong>com.mycompany.myBlock2.block%classes-dir=../myBlock2/target/classes
+++ %exclude-lib=com.mycompany:myBlock2</strong>
+++ </pre>
+++
<h1>Use a pipeline fragment</h1>
<p class="fixme">TBD</p>
(3 equal lines skipped)