Cocoon Blocks CocoonGT2006

848 views

Published on

Talk given at Cocoon GT 2006

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
848
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cocoon Blocks CocoonGT2006

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

×