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 4:03:41 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: 5391 bytes (previous version: 3763 bytes)
Content diff:
(50 equal lines skipped)
<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 block2 with block1</h1>
+++ <h1>Connect two blocks</h1>
<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
(11 equal lines skipped)
<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"/>
+++ <entry key="myBlock2"
value-ref="com.mycompany.myBlock2.block"/>
</servlet:connections></strong>
</servlet:context>
</bean>
(27 equal lines skipped)
<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>
+++ %exclude-lib=com.mycompany:myBlock2
+++ </strong></pre>
+++
+++ <p>Restart the servlet container by invoking</p>
+++
+++ <pre>mvn jetty:run
</pre>
+++ <p>Now it's time to test connection. For that purpose add a pipeline to the
+++ sitemap of block1
+++
(<tt>getting-started-app/myBlock1/src/main/resources/COB-INF/sitemap.xmap</tt>):
+++ </p>
+++
+++ <pre><?xml version="1.0" encoding="UTF-8"?>
+++ <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+++ <map:pipelines>
+++ [...]
+++ <map:pipeline>
+++ <map:match pattern="callingBlock2">
+++ <map:generate
src="<strong>servlet:myBlock2:/spring-bean</strong>" type="file"/>
+++ <map:serialize type="xml"/>
+++ </map:match>
+++ </map:pipeline>
+++ [...]
+++ </map:pipelines>
+++ </map:sitemap>
+++ </pre>
+++
+++ <p>The file generator of this pipeline uses a special purpose protocol, the
+++ servlet protocol, to access a pipeline defined in the other block. If you
enter
+++ <tt>http://localhost:8888/myBlock1/callingBlock2</tt> shows the output of
the
+++ spring-bean pipeline of <tt>myBlock2</tt> but routed through
<tt>myBlock1</tt>.
+++ <br/>
+++ Though this is a "<em>hello word</em>" style example you might already
imagine
+++ the power of this protocol, e.g. you can move all styling resources and
+++ pipelines to a particular block.</p>
+++
<h1>Use a pipeline fragment</h1>
--- <p class="fixme">TBD</p>
+++ <p>The previous example showed how you can call a pipeline from another
block.
+++ But here is even more you can do! A sitemap can also provide pipeline
fragements
+++ that can be used by other blocks.<br/>
+++ Add this pipeline to <tt>myblock2</tt>. It provides a transformation service
+++ that consists of two XSLT transformation steps:</p>
+++ <pre>TBD</pre>
+++
+++ <p>Now it can be used from myBlock1</p>
+++
+++ <pre>TBD</pre>
+++
+++ <p>...</p>
+++
</body>
</html>