Cocoon Blocks ApacheCon US 2005

855 views

Published on

Talk given at ApacheCon US 2005.

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
855
On SlideShare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cocoon Blocks ApacheCon US 2005

  1. 1. Cocoon Blocks Daniel Fagerström [email_address]
  2. 2. Motivation <ul><li>Cocoon is great but … </li></ul><ul><li>Monolithic </li></ul><ul><ul><li>Huge download </li></ul></ul><ul><ul><li>Complicated configuration </li></ul></ul><ul><ul><li>Steep threshold </li></ul></ul><ul><ul><li>Few third party applications and components </li></ul></ul><ul><ul><li>” Classloading hell” </li></ul></ul>
  3. 3. Blocks <ul><li>A plugin architecture is needed </li></ul><ul><li>Designed by Stefano and the rest of the community 3+ years ago </li></ul><ul><li>Compile time blocks for a few years, but no external contracts </li></ul><ul><li>Much work and discussion, but less progress until the last half year </li></ul><ul><li>Essentially back compatible, a new integration level: package and reuse applications </li></ul>
  4. 4. Overview <ul><li>The big picture </li></ul><ul><li>Architecture </li></ul><ul><ul><li>Examples </li></ul></ul><ul><li>Current state and next steps </li></ul>
  5. 5. 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>Sitemap 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 </li></ul>
  6. 6. What is a Block? Classes,resources Components Sitemap Export packages Import packages Registered services Used services
  7. 7. Deployment architecture Cocoon platform Blocks Blocks repository (Maven 2) Blocks discovery Deployment service
  8. 8. Block Architecture <ul><li>Built upon OSGi (same as Eclipse 3+) </li></ul><ul><li>A block is an OSGi bundle </li></ul><ul><ul><li>Class loader isolation </li></ul></ul><ul><ul><li>Packaging format </li></ul></ul><ul><ul><li>Services </li></ul></ul><ul><ul><li>Security </li></ul></ul><ul><ul><li>Hot deployment possible </li></ul></ul>
  9. 9. OSGi
  10. 10. OSGi <ul><li>Standardized, component oriented, computing environment for networked services </li></ul><ul><li>Since 1998 </li></ul><ul><li>100+ members </li></ul><ul><li>R4 </li></ul><ul><li>10+ implementations </li></ul><ul><li>Smart phones, home automation, BMW 5, Eclipse </li></ul>
  11. 11. OSGi Overview <ul><li>Secure execution environment </li></ul><ul><li>Bundles (applications) </li></ul><ul><li>Life cycle management </li></ul><ul><li>Service architecture </li></ul><ul><li>Standard services </li></ul>
  12. 12. Bundles <ul><li>Applications </li></ul><ul><li>JAR containing </li></ul><ul><ul><li>Compiled code </li></ul></ul><ul><ul><li>Resources </li></ul></ul><ul><ul><li>JARs that the code depend on </li></ul></ul><ul><ul><li>Meta information – manifest.mf </li></ul></ul>
  13. 13. Class sharing <ul><li>Import-Package </li></ul><ul><li>DynamicImport-Package </li></ul><ul><li>Export-Package </li></ul><ul><li>Bundle-Classpath </li></ul>
  14. 14. Activator OSGi Framework Activator BundleCtx Activator BundleCtx
  15. 15. Life cycle
  16. 16. Manifest.mf Manifest-Version: 1.0 Bundle-Name: cocoon_servlet Bundle-Version: 1.0.0 Bundle-Description: Cocoon servlet bundle Bundle-Vendor: Apache Bundle-DocURL: http://cocoon.apache.org Bundle-ContactAddress: http://cocoon.apache.org Bundle-Activator: org.apache.cocoon.service.servlet.impl.Activator Bundle-Category: servlet Import-Package: javax.servlet,javax.servlet.http, org.apache.cocoon.servlet, org.osgi.framework,org.osgi.service.http, org.osgi.service.log,org.osgi.util.tracker
  17. 17. Blocks
  18. 18. Block structure <ul><li>myblock/ </li></ul><ul><li>META-INF/ </li></ul><ul><li>MANIFEST.MF # bundle manifest </li></ul><ul><li>BLOCK-INF/ </li></ul><ul><li>block.xml # block configuration </li></ul><ul><li>myblock.xconf # exported components </li></ul><ul><li>classes/ </li></ul><ul><li>lib/ </li></ul><ul><li>src/ </li></ul><ul><li>sitemap.xmap # block sitemap </li></ul><ul><li>resources/ </li></ul><ul><li>... </li></ul>
  19. 19. Block configuration <ul><li><block xmlns=&quot;http://apache.org/cocoon/blocks/cob/1.0&quot; </li></ul><ul><li>id=&quot;http://cocoon.apache.org/blocks/blog-123&quot;> </li></ul><ul><li><name>blog</name> </li></ul><ul><li><sitemap src=&quot;sitemap.xmap&quot;/> </li></ul><ul><li><components> </li></ul><ul><li><include src=&quot;blog.xconf&quot;/> </li></ul><ul><li></components> </li></ul><ul><li><properties> </li></ul><ul><li><property name=“cmsURL&quot;> </li></ul><ul><li><default>http://mycms.com/test</default> </li></ul><ul><li></property> </li></ul><ul><li></properties> </li></ul><ul><li><requirements> </li></ul><ul><li><requires </li></ul><ul><li>interface=&quot;http://cocoon.apache.org/blocks/editor/1.0&quot; </li></ul><ul><li>name=“editor&quot;/> </li></ul><ul><li></requirements> </li></ul><ul><li></block> </li></ul>
  20. 20. Wiring blog editor: myeditor myblog super: cmsURL: http://mycms.com/... Uses Extends mountPath: /blog/danielf/
  21. 21. wiring.xml <ul><li><wiring xmlns=&quot;http://apache.org/cocoon/blocks/wiring/1.0&quot;> </li></ul><ul><li><block id=&quot;blog-123&quot; location=&quot;file:/blocks/blog-1.4.jar&quot;> </li></ul><ul><li><connections> </li></ul><ul><li><connection name=&quot;editor&quot; block=&quot;editor-234&quot;/> </li></ul><ul><li></connections> </li></ul><ul><li><properties> </li></ul><ul><li><property name=&quot;cmsURL“ </li></ul><ul><li>value=&quot;http://mycms.com/danielf/&quot;/> </li></ul><ul><li></properties> </li></ul><ul><li></block> </li></ul><ul><li><block id=&quot;editor-234&quot; location=&quot;file:/blocks/editor-1.4.jar&quot;/> </li></ul><ul><li><block id=&quot;myblog-345&quot; location=&quot;file:/blocks/myblog/&quot;> </li></ul><ul><li><mount path=&quot;/blog/danielf/&quot;/> </li></ul><ul><li><connections> </li></ul><ul><li><connection name=&quot;super&quot; block=&quot;blog-123&quot;/> </li></ul><ul><li></connections> </li></ul><ul><li></block> </li></ul><ul><li></wiring> </li></ul>
  22. 22. Components in blocks <ul><li>Components only available from the own block and connected blocks </li></ul>
  23. 23. Component bridge Cocoon component manager Cocoon component manager OSGi service
  24. 24. Sitemaps in blocks <ul><li>As usual </li></ul><ul><li>Adds </li></ul><ul><ul><li>Call 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>
  25. 25. Block architecture Blocks /editor / wiring.xml settings Http Service Cocoon Servlet Webapp
  26. 26. 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 </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>
  27. 27. 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>
  28. 28. Sitemap polymorphism blog myblog Extends “ skin.xsl” “ skin.xsl”  read “skin.xsl” Empty
  29. 29. Sitemap polymorphism blog myblog Extends “ skin.xsl” “ skin.xsl”  read “skin.xsl” Override “ skin.xsl”  read “myskin.xsl”
  30. 30. 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”
  31. 31. 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>
  32. 32. 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>Sitemap 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>
  33. 33. Current state <ul><li>Cocoon runs under OSGi </li></ul><ul><li>Sitemap blocks works </li></ul><ul><li>Component bridge implemented </li></ul><ul><li>Above parts are not yet integrated </li></ul><ul><li>Maven 2 build on its way </li></ul>
  34. 34. Next steps <ul><li>2.2 </li></ul><ul><ul><li>Binary distribution of all blocks in M2 repository </li></ul></ul><ul><ul><li>Blocks architecture in experimental version, without OSGi </li></ul></ul><ul><li>3.0 </li></ul><ul><ul><li>OSGi based </li></ul></ul><ul><ul><li>class loader isolation </li></ul></ul><ul><ul><li>partial hot plugablillity </li></ul></ul>

×