Your SlideShare is downloading. ×
Cocoon OSGi CocoonGT2007
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Cocoon OSGi CocoonGT2007

1,079
views

Published on

Talk given at CocoonGT2007.

Talk given at CocoonGT2007.

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,079
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

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