Download - Cocoon Blocks CocoonGT2006
![Page 2: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/2.jpg)
Same talk as last year?
• Changed architecture 3 times since last time and rewritten the implementation a couple of times
• The latest incarnation is based on the Spring framework and the servlet set of APIs
• What I will describe is now part of Cocoon 2.2
![Page 3: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/3.jpg)
Motivation
• Plugin architecture• Webapp reuse• Isolated internals in the blocks• Simplify using Cocoon together with other
Servlet frameworks
![Page 4: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/4.jpg)
Overview
• The big picture• Architecture
– Focus on the webapp reuse part– Examples
• Current state and next steps
![Page 5: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/5.jpg)
Blocks
• A plugin architecture is needed• Designed by Stefano and the rest of the
community 4+ years ago• Compile time blocks for a few years, but no
external contracts• Several prototypes the last 1.5 years• Essentially back compatible, a new integration
level: package and reuse applications
![Page 6: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/6.jpg)
What is a block?
• A packaged application (or part) containing:– Libraries and resources– Components– Webapp functionality
• Configurable at deploy time• Might depend on other blocks• Isolated internals (only partly in 2.2)
![Page 7: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/7.jpg)
What is a Block?
Classes,resources
Components
ServletsExported
componentsUsed
components
![Page 8: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/8.jpg)
Deployment architecture
Cocoon platform
Blocks
Blocks repository (Maven 2)
Blocks discovery
Deployment service
![Page 9: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/9.jpg)
Block Architecture
• Built upon Spring and Maven• A block is a Maven module
– Packaging format– Components– Servlet(s)– Resources– Libraries
![Page 10: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/10.jpg)
Block structuremyblock/ META-INF/ legacy/ components.xconf # Avalon conf properties/ component.properties spring/ components.xml # Spring conf (incl block servlet) COB-INF/ # webapp resources sitemap.xmap # block sitemap resources/ ... org/apache/cocoon/myblock/ # classes foo.class ...
![Page 11: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/11.jpg)
Components in blocks
• Exported to and managed in a global Spring container
• Now the component configurations are copied from the blocks to the global Spring configuration by cocoon:deploy
• Reading the configuration from the block would be preferable
![Page 12: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/12.jpg)
Webapps in blocks
• As usual• Spring managed Servlets• Adds
– Call servlets (sitemaps) in connected blocks– Use block deploy time attributes– Extend blocks (with polymorphism)
![Page 13: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/13.jpg)
Block architecture
DispatcherServlet
Block Servlets
/editor
/
Configured in web.xml
Spring container
![Page 14: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/14.jpg)
Based on the Servlet API
• No new API• The BlockServlet is a Spring managed
Servlet that sets up a minimal Servlet container for an embeded Servlet (e.g. SitemapServlet)
• Block properties --> Servlet init params• Block connections --> named dispatchers• Can be used with any servlet, nothing
Cocoon specific
![Page 15: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/15.jpg)
Wiringblog
editor:
myeditor
myblog
super:
cmsURL: http://mycms.com/...
Uses
Extends
mountPath: /blog/danielf/
![Page 16: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/16.jpg)
BlockServlet configuration<beans xmlns="http://www.springframework.org/schema/beans"> <bean id="org.apache.cocoon.blocks.blog" class="org.apache.cocoon.blocks.BlockServlet"> <property name="mountPath" value="/test1"/>
<property name="blockServletClass" value="org.apache.cocoon.sitemap.SitemapServlet"/>
<property name="properties"> <map> <entry key="cmsURL" value="http://mycms.com/test"/> </map> </property>
<property name="connections"> <map> <entry key="editor" value-ref="org.apache.cocoon.blocks.editor"/> </map> </property> </bean></beans>
![Page 17: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/17.jpg)
Deployment configuration# blog.properties## configure the blog blockorg.apache.cocoon.blog.properties.cmsURL=
http://mycvs.com/danielforg.apache.cocoon.blog.connections.editor=
com.mycms.myeditor
## configure my extended versioncom.mycms.myblog.mountPath=
/blog/danielfcom.mycms.myblog.connections.super=
org.apache.cocoon.blog
![Page 18: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/18.jpg)
Block protocol
block:/foo.xml– root sitemap in current block
block:./bar.xml– current sitemap in current block (not yet)
block:editor:/foo.xml– root sitemap in editor block
block:super:/foo.xml– root sitemap in extended block
![Page 19: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/19.jpg)
Block properties, paths
{block-property:cmsURL}- Block property in sitemap (input module)
{cmsURL}- Block property in component configuration
{block-path:myblog:/start}--> /blog/danielf/start- “Absolutizes” block protocol URIs to mounted URIs, used in link transformer
![Page 20: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/20.jpg)
Sitemap polymorphismblog
myblog
Extends
“skin.xsl”
“skin.xsl” read “skin.xsl”
Empty
![Page 21: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/21.jpg)
Sitemap polymorphismblog
myblog
Extends
“skin.xsl”
“skin.xsl” read “skin.xsl”
Override“skin.xsl” read “myskin.xsl”
![Page 22: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/22.jpg)
Sitemap polymorphismblog
myblog
Extends
“start.xml”
“skin.xsl” read “skin.xsl”
“*.xml” generate “{1}” transform “block:/skin.xsl” serialize
“skin.xsl” read “myskin.xsl”
![Page 23: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/23.jpg)
Scenario
• Download blog block• Deploy with parameters (or use default)
– Test• Create empty extension (Maven archetype)
– Test• Override some default or example rule
– Test• …
![Page 24: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/24.jpg)
Summary
Blocks gives us:• Binary application packages
– Classes & resources– Components– Webapp functionality
• Parameterizable applications• Reusability by extension• Dependency handling between applications
![Page 25: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/25.jpg)
Current state
• Implementation in Cocoon 2.2• Stabilize it, use it for the samples
![Page 26: Cocoon Blocks CocoonGT2006](https://reader035.vdocuments.us/reader035/viewer/2022070522/58ee6ca31a28ab041c8b45e3/html5/thumbnails/26.jpg)
Next steps
• 3.0– OSGi based– Uses ”official” Spring-OSGI bridge– class loader isolation– partial hot plugablillity