Cocoon Blocks Daniel Fagerstrm danielf@nada.kth.se Motivation - - PowerPoint PPT Presentation

cocoon blocks
SMART_READER_LITE
LIVE PREVIEW

Cocoon Blocks Daniel Fagerstrm danielf@nada.kth.se Motivation - - PowerPoint PPT Presentation

Cocoon Blocks Daniel Fagerstrm danielf@nada.kth.se Motivation Cocoon is great but Monolithic Huge download Complicated configuration Steep threshold Few third party applications and components


slide-1
SLIDE 1

Cocoon Blocks

Daniel Fagerström danielf@nada.kth.se

slide-2
SLIDE 2

Motivation

  • Cocoon is great but …
  • Monolithic

– Huge download – Complicated configuration – Steep threshold – Few third party applications and components – ”Classloading hell”

slide-3
SLIDE 3

Blocks

  • A plugin architecture is needed
  • Designed by Stefano and the rest of the

community 3+ years ago

  • Compile time blocks for a few years, but no

external contracts

  • Much work and discussion, but less progress until

the last half year

  • Essentially back compatible, a new integration

level: package and reuse applications

slide-4
SLIDE 4

Overview

  • The big picture
  • Architecture

– Examples

  • Current state and next steps
slide-5
SLIDE 5

What is a block?

  • A packaged application (or part) containing:

– Libraries and resources – Components – Sitemap functionality

  • Configurable at deploy time
  • Might depend on other blocks
  • Isolated internals
slide-6
SLIDE 6

What is a Block?

Classes,resources Components Sitemap Export packages Import packages Registered services Used services

slide-7
SLIDE 7

Deployment architecture

Cocoon platform Blocks Blocks repository (Maven 2) Blocks discovery Deployment service

slide-8
SLIDE 8

Block Architecture

  • Built upon OSGi (same as Eclipse 3+)
  • A block is an OSGi bundle

– Class loader isolation – Packaging format – Services – Security – Hot deployment possible

slide-9
SLIDE 9

OSGi

slide-10
SLIDE 10

OSGi

  • Standardized, component oriented, computing

environment for networked services

  • Since 1998
  • 80+ members
  • R3, soon R4
  • 10+ implementations
  • Smart phones, home automation, BMW 5, Eclipse
slide-11
SLIDE 11

OSGi Overview

  • Secure execution environment
  • Bundles (applications)
  • Life cycle management
  • Service architecture
  • Standard services
slide-12
SLIDE 12

Bundles

  • Applications
  • JAR containing

– Compiled code – Resources – JARs that the code depend on – Meta information – manifest.mf

slide-13
SLIDE 13

Class sharing

  • Import-Package
  • DynamicImport-

Package

  • Export-Package
  • Bundle-Classpath
slide-14
SLIDE 14

Activator

Activator BundleCtx Activator BundleCtx

OSGi Framework

slide-15
SLIDE 15

Life cycle

slide-16
SLIDE 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:

  • rg.apache.cocoon.service.servlet.impl.Activator

Bundle-Category: servlet Import-Package: javax.servlet,javax.servlet.http,

  • rg.apache.cocoon.servlet,
  • rg.osgi.framework,org.osgi.service.http,
  • rg.osgi.service.log,org.osgi.util.tracker
slide-17
SLIDE 17

Blocks

slide-18
SLIDE 18

Block structure

myblock/ META-INF/ MANIFEST.MF # bundle manifest BLOCK-INF/ block.xml # block configuration myblock.xconf # exported components classes/ lib/ src/ sitemap.xmap # block sitemap resources/ ...

slide-19
SLIDE 19

Block configuration

<block xmlns="http://apache.org/cocoon/blocks/cob/1.0" id="http://cocoon.apache.org/blocks/blog-123"> <name>blog</name> <sitemap src="sitemap.xmap"/> <components> <include src="blog.xconf"/> </components> <properties> <property name=“cmsURL"> <default>http://mycms.com/test</default> </property> </properties> <requirements> <requires interface="http://cocoon.apache.org/blocks/editor/1.0" name=“editor"/> </requirements> </block>

slide-20
SLIDE 20

Wiring

blog

editor: myeditor

myblog

super: cmsURL:

http://mycms.com/...

Uses Extends

mountPath: /blog/danielf/

slide-21
SLIDE 21

wiring.xml

<wiring xmlns="http://apache.org/cocoon/blocks/wiring/1.0"> <block id="blog-123" location="file:/blocks/blog-1.4.jar"> <connections> <connection name="editor" block="editor-234"/> </connections> <properties> <property name="cmsURL“ value="http://mycms.com/danielf/"/> </properties> </block> <block id="editor-234" location="file:/blocks/editor-1.4.jar"/> <block id="myblog-345" location="file:/blocks/myblog/"> <mount path="/blog/danielf/"/> <connections> <connection name="super" block="blog-123"/> </connections> </block> </wiring>

slide-22
SLIDE 22

Components in blocks

  • Components only available from the own

block and connected blocks

slide-23
SLIDE 23

Component bridge

Cocoon component manager Cocoon component manager OSGi service

slide-24
SLIDE 24

Sitemaps in blocks

  • As usual
  • Adds

– Call sitemaps in connected blocks – Use block deploy time attributes – Extend blocks (with polymorphism)

slide-25
SLIDE 25

Block architecture

Http Service OSGi Servlet Webapp

Blocks

/editor / wiring.xml settings

slide-26
SLIDE 26

Block protocol

block:/foo.xml – root sitemap in current block block:./bar.xml – current sitemap in current block block:editor:/foo.xml – root sitemap in editor block block:super:/foo.xml – root sitemap in extended block

slide-27
SLIDE 27

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

slide-28
SLIDE 28

Sitemap polymorphism

blog myblog Extends

“skin.xsl” “skin.xsl”  read “skin.xsl”

Empty

slide-29
SLIDE 29

Sitemap polymorphism

blog myblog Extends

“skin.xsl” “skin.xsl”  read “skin.xsl”

Override

“skin.xsl”  read “myskin.xsl”

slide-30
SLIDE 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”

slide-31
SLIDE 31

Scenario

  • Download blog block
  • Deploy with parameters (or use default)

– Test

  • Create empty extension (skeleton generator)

– Test

  • Override some default or example rule

– Test

slide-32
SLIDE 32

Summary

Blocks gives us:

  • Binary application packages

– Classes & resources – Components – Sitemap functionality

  • Parameterizable applications
  • Reusability by extension
  • Dependency handling between applications
slide-33
SLIDE 33

Current state

  • Cocoon runs under OSGi
  • Sitemap blocks works
  • Component bridge implemented
  • Above parts are not yet integrated
  • Maven 2 build on its way
slide-34
SLIDE 34

Next steps

  • 2.2

– Binary distribution of all blocks in M2 repository – Blocks architecture in experimental version, without OSGi

  • 3.0

– OSGi based – class loader isolation – partial hot plugablillity