Cocoon OSGi CocoonGT2007
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Cocoon OSGi CocoonGT2007

on

  • 1,732 views

Talk given at CocoonGT2007.

Talk given at CocoonGT2007.

Statistics

Views

Total Views
1,732
Views on SlideShare
1,732
Embed Views
0

Actions

Likes
0
Downloads
29
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Cocoon OSGi CocoonGT2007 Presentation Transcript

  • 1. Hot Deployable Cocoon Blocks with OSGi Daniel Fagerström [email_address]
  • 2. Overview
    • Why?
    • How?
      • Bundelization
      • Component wiring
      • Runtime environment
    • When?
  • 3. Why?
    • OSGi is the standard plugin framework
      • Reuse bundles from other projects
      • Other projects can reuse Cocoon bundles
    • Dynamically updateable bundles
      • 24/7
      • Convenient for customer installations
      • Faster development
    • Classloader isolation
      • Possible to use multiple versions of the same library
  • 4. Deja vú?
    • Earlier attempts with OSGi
    • Focused on the Servlet Service FW
    • OSGi more mature for enterprise apps now
  • 5. Modularization in 2.2
    • Packaging
    • Spring Beans everywhere
    • Servlet Service FW
    • Deployment in global classloader and global Spring factory
    • No dynamics
  • 6. How?
  • 7. OSGi
    • Felix – OSGi Framework
    • Maven Bundle - Plugin for packaging
    • Spring-OSGi – Component wiring
    • Services from Felix, Spring-OSGi, Equinox, OPS4J
  • 8. 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 (only partly in 2.2)
  • 9. What is a Block? What is a Block? Classes,resources Components Sitemap Export packages Import packages Registered services Used services
  • 10. Block Structure myBlock/ META-INF/ manifest.mf # bundle manifest cocoon/ spring/ components.xml # spring components spring/ osgi-services.xml # spring-osgi – exports & imports org/ apache/ cocoon/ ... # classes COB-INF/ sitemap.xmap ... # resources
  • 11. Component Wiring
    • Using Spring-OSGi
    • One web application context per block
    • Exporting and importing beans as OSGi services
  • 12. Spring-OSGi vs. Declarative Services
    • Spring-OSGi
      • + Spring
      • - Not released yet
    • DS
      • + Standard
      • + Several Releases
      • - More container dependencies in the code
      • - More work to integrate with Spring
  • 13. Exporting a Bean <!-- cocoon-xml-impl --> <bean name=&quot; org.apache.cocoon.core.xml.SAXParser &quot; class=&quot;org.apache.cocoon.core.xml.impl.JaxpSAXParser&quot; scope=&quot;singleton&quot;> <property name=&quot;validate&quot; value=&quot;false&quot;/> </bean> <osgi:service ref=&quot; org.apache.cocoon.core.xml.SAXParser &quot; interface=&quot; org.apache.cocoon.core.xml.SAXParser &quot;/>
  • 14. Importing a Bean <!-- cocoon-pipeline-components --> <osgi:reference id=&quot; org.apache.cocoon.core.xml.SAXParser &quot; interface=&quot; org.apache.cocoon.core.xml.SAXParser &quot;/> <bean name=&quot;org.apache.cocoon.generation.Generator/file&quot; class=&quot;org.apache.cocoon.generation.FileGenerator&quot; scope=&quot;prototype&quot;> <property name=&quot;parser&quot; ref=&quot; org.apache.cocoon.core.xml.SAXParser &quot;/> </bean>
  • 15. Bean Map
    • Whiteboard pattern
  • 16. Bean Map <!-- cocoon-expression-language-impl --> <osgi:service ref=&quot; org.apache.cocoon.el.ExpressionCompiler/js &quot; interface=&quot; org.apache.cocoon.el.ExpressionCompiler &quot;/> <osgi:service ref=&quot; org.apache.cocoon.el.ExpressionCompiler/jexl &quot; interface=&quot; org.apache.cocoon.el.ExpressionCompiler &quot;/> <osgi:service ref=&quot; org.apache.cocoon.el.ExpressionCompiler/jxpath &quot; interface=&quot; org.apache.cocoon.el.ExpressionCompiler &quot;/> <osgi:service ref=&quot; org.apache.cocoon.el.ExpressionCompiler/default &quot; interface=&quot; org.apache.cocoon.el.ExpressionCompiler &quot;/>
  • 17. Bean Map <!-- cocoon-expression-language-impl --> <bean id=&quot; org.apache.cocoon.el.ExpressionFactory &quot; class=&quot;org.apache.cocoon.el.impl.DefaultExpressionFactory&quot;> <property name=&quot;expressionCompilers&quot;> <cosgi:map interface=&quot; org.apache.cocoon.el.ExpressionCompiler &quot;/> </property> </bean> <osgi:service ref=&quot; org.apache.cocoon.el.ExpressionFactory &quot; interface=&quot;org.apache.cocoon.el.ExpressionFactory&quot;/>
  • 18. Service Events
    • Fine grained control of addition and removal of services
  • 19. Service Events <!-- cocoon-servlet-service-demo1 --> <osgi:service ref=&quot;org.apache.cocoon.servletservice.demo1.servlet&quot; interface=&quot; javax.servlet.Servlet &quot;> <osgi:service-properties> <prop key=&quot;mountPath&quot;>/test1</prop> </osgi:service-properties> </osgi:service> <!-- cocoon-servlet-service-demo2 --> <osgi:service ref=&quot;org.apache.cocoon.servletservice.demo2.servlet&quot; interface=&quot; javax.servlet.Servlet &quot;> <osgi:service-properties> <prop key=&quot;mountPath&quot;>/test2</prop> </osgi:service-properties> </osgi:service>
  • 20. Service Events <!-- cocoon-servlet-service-impl --> <osgi:reference id=&quot; httpService &quot; interface=&quot;org.osgi.service.http.HttpService&quot;/> <osgi:collection id=&quot;servletService&quot; interface=&quot; javax.servlet.Servlet &quot;> <osgi:listener bind-method=&quot; setServlet &quot; unbind-method=&quot; unsetServlet &quot; ref=&quot; servletListener &quot;/> </osgi:collection> <bean id=&quot; servletListener &quot; class=&quot;org.apache.cocoon.servletservice.osgi.Activator&quot;> <property name=&quot;httpService&quot; ref=&quot; httpService &quot;/> </bean>
  • 21. Tunnelling a Prototype
    • No correspondence to prototype scope in OSGi
    • Export a factory bean instead
  • 22. Tunnelling a Prototype <!-- cocoon-pipeline-components --> <bean name=&quot; org.apache.cocoon.generation.Generator/file &quot; class=&quot;org.apache.cocoon.generation.FileGenerator&quot; scope=&quot;prototype&quot; > <property name=&quot;parser&quot; ref=&quot;org.apache.cocoon.core.xml.SAXParser&quot;/> </bean> <cosgi:service ref=&quot; org.apache.cocoon.generation.Generator/file &quot; interface=&quot; org.apache.cocoon.generation.Generator &quot; factory-export=&quot;true&quot; />
  • 23. Tunnelling a Prototype <!-- cocoon-core-main-sample --> <cosgi:reference name=&quot; org.apache.cocoon.generation.Generator/file &quot; interface=&quot; org.apache.cocoon.generation.Generator &quot; factory-export=&quot;true&quot; />
  • 24. Service Manager?
    • A sitemap may need many beans
    • Many service imports
    • Let the bundle local Spring context fall back to the OSGi service registry?
      • Will that work with declarative wiring?
  • 25. Cocoon-OSGi Architecture
    • Http Service
    • Servlet container embedding?
    • Other services?
      • Config
      • Log
      • ...
  • 26. Cocoon-OSGi Architecture Blocks /editor / Http Service Dispatcher
  • 27. Deployment architecture Cocoon platform Blocks Blocks repository (Maven 2) Blocks discovery (OBR) Deployment service
  • 28. When?
    • One man show this far
    • Can live together with ”ordinary” Cocoon
    • Spring-OSGi expected to release 1.0.0 in December
    • http://svn.apache.org/repos/asf/cocoon/whiteboard/osgi/
  • 29. Conclusion
    • Standard plugin
    • Classloader isolation
    • Hot deployable blocks