Hot Deployable Cocoon Blocks with OSGi Daniel Fagerström [email_address]
Overview <ul><li>Why? </li></ul><ul><li>How? </li></ul><ul><ul><li>Bundelization </li></ul></ul><ul><ul><li>Component wiri...
Why? <ul><li>OSGi is the standard plugin framework </li></ul><ul><ul><li>Reuse bundles from other projects </li></ul></ul>...
Deja vú? <ul><li>Earlier attempts with OSGi </li></ul><ul><li>Focused on the Servlet Service FW </li></ul><ul><li>OSGi mor...
Modularization in 2.2 <ul><li>Packaging </li></ul><ul><li>Spring Beans everywhere </li></ul><ul><li>Servlet Service FW </l...
How?
OSGi <ul><li>Felix – OSGi Framework </li></ul><ul><li>Maven Bundle - Plugin for packaging </li></ul><ul><li>Spring-OSGi – ...
What is a block? <ul><li>A packaged application (or part) containing: </li></ul><ul><ul><li>Libraries and resources </li><...
What is a Block? What is a Block? Classes,resources Components Sitemap Export packages Import packages Registered services...
Block Structure myBlock/ META-INF/ manifest.mf   # bundle manifest cocoon/ spring/ components.xml  # spring components spr...
Component Wiring <ul><li>Using Spring-OSGi </li></ul><ul><li>One web application context per block </li></ul><ul><li>Expor...
Spring-OSGi vs. Declarative Services <ul><li>Spring-OSGi </li></ul><ul><ul><li>+ Spring </li></ul></ul><ul><ul><li>-  Not ...
Exporting a Bean <!-- cocoon-xml-impl --> <bean name=&quot; org.apache.cocoon.core.xml.SAXParser &quot; class=&quot;org.ap...
Importing a Bean <!-- cocoon-pipeline-components --> <osgi:reference id=&quot; org.apache.cocoon.core.xml.SAXParser &quot;...
Bean Map <ul><li>Whiteboard pattern </li></ul>
Bean Map <!-- cocoon-expression-language-impl --> <osgi:service ref=&quot; org.apache.cocoon.el.ExpressionCompiler/js &quo...
Bean Map <!-- cocoon-expression-language-impl --> <bean id=&quot; org.apache.cocoon.el.ExpressionFactory &quot; class=&quo...
Service Events <ul><li>Fine grained control of addition and removal of services </li></ul>
Service Events <!-- cocoon-servlet-service-demo1 --> <osgi:service  ref=&quot;org.apache.cocoon.servletservice.demo1.servl...
Service Events <!-- cocoon-servlet-service-impl --> <osgi:reference id=&quot; httpService &quot;  interface=&quot;org.osgi...
Tunnelling a Prototype <ul><li>No correspondence to prototype scope in OSGi </li></ul><ul><li>Export a factory bean instea...
Tunnelling a Prototype <!-- cocoon-pipeline-components --> <bean name=&quot; org.apache.cocoon.generation.Generator/file &...
Tunnelling a Prototype <!-- cocoon-core-main-sample --> <cosgi:reference name=&quot; org.apache.cocoon.generation.Generato...
Service Manager? <ul><li>A sitemap may need many beans </li></ul><ul><li>Many service imports </li></ul><ul><li>Let the bu...
Cocoon-OSGi Architecture <ul><li>Http Service </li></ul><ul><li>Servlet container embedding? </li></ul><ul><li>Other servi...
Cocoon-OSGi Architecture Blocks /editor / Http Service Dispatcher
Deployment architecture Cocoon platform Blocks Blocks repository (Maven 2) Blocks discovery (OBR) Deployment service
When? <ul><li>One man show this far </li></ul><ul><li>Can live together with ”ordinary” Cocoon </li></ul><ul><li>Spring-OS...
Conclusion <ul><li>Standard plugin </li></ul><ul><li>Classloader isolation </li></ul><ul><li>Hot deployable blocks </li></ul>
Upcoming SlideShare
Loading in...5
×

Cocoon OSGi CocoonGT2007

1,111

Published on

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,111
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cocoon OSGi CocoonGT2007

  1. 1. Hot Deployable Cocoon Blocks with OSGi Daniel Fagerström [email_address]
  2. 2. Overview <ul><li>Why? </li></ul><ul><li>How? </li></ul><ul><ul><li>Bundelization </li></ul></ul><ul><ul><li>Component wiring </li></ul></ul><ul><ul><li>Runtime environment </li></ul></ul><ul><li>When? </li></ul>
  3. 3. Why? <ul><li>OSGi is the standard plugin framework </li></ul><ul><ul><li>Reuse bundles from other projects </li></ul></ul><ul><ul><li>Other projects can reuse Cocoon bundles </li></ul></ul><ul><li>Dynamically updateable bundles </li></ul><ul><ul><li>24/7 </li></ul></ul><ul><ul><li>Convenient for customer installations </li></ul></ul><ul><ul><li>Faster development </li></ul></ul><ul><li>Classloader isolation </li></ul><ul><ul><li>Possible to use multiple versions of the same library </li></ul></ul>
  4. 4. Deja vú? <ul><li>Earlier attempts with OSGi </li></ul><ul><li>Focused on the Servlet Service FW </li></ul><ul><li>OSGi more mature for enterprise apps now </li></ul>
  5. 5. Modularization in 2.2 <ul><li>Packaging </li></ul><ul><li>Spring Beans everywhere </li></ul><ul><li>Servlet Service FW </li></ul><ul><li>Deployment in global classloader and global Spring factory </li></ul><ul><li>No dynamics </li></ul>
  6. 6. How?
  7. 7. OSGi <ul><li>Felix – OSGi Framework </li></ul><ul><li>Maven Bundle - Plugin for packaging </li></ul><ul><li>Spring-OSGi – Component wiring </li></ul><ul><li>Services from Felix, Spring-OSGi, Equinox, OPS4J </li></ul>
  8. 8. 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 (only partly in 2.2) </li></ul>
  9. 9. What is a Block? What is a Block? Classes,resources Components Sitemap Export packages Import packages Registered services Used services
  10. 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. 11. Component Wiring <ul><li>Using Spring-OSGi </li></ul><ul><li>One web application context per block </li></ul><ul><li>Exporting and importing beans as OSGi services </li></ul>
  12. 12. Spring-OSGi vs. Declarative Services <ul><li>Spring-OSGi </li></ul><ul><ul><li>+ Spring </li></ul></ul><ul><ul><li>- Not released yet </li></ul></ul><ul><li>DS </li></ul><ul><ul><li>+ Standard </li></ul></ul><ul><ul><li>+ Several Releases </li></ul></ul><ul><ul><li>- More container dependencies in the code </li></ul></ul><ul><ul><li>- More work to integrate with Spring </li></ul></ul>
  13. 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. 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. 15. Bean Map <ul><li>Whiteboard pattern </li></ul>
  16. 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. 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. 18. Service Events <ul><li>Fine grained control of addition and removal of services </li></ul>
  19. 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. 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. 21. Tunnelling a Prototype <ul><li>No correspondence to prototype scope in OSGi </li></ul><ul><li>Export a factory bean instead </li></ul>
  22. 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. 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. 24. Service Manager? <ul><li>A sitemap may need many beans </li></ul><ul><li>Many service imports </li></ul><ul><li>Let the bundle local Spring context fall back to the OSGi service registry? </li></ul><ul><ul><li>Will that work with declarative wiring? </li></ul></ul>
  25. 25. Cocoon-OSGi Architecture <ul><li>Http Service </li></ul><ul><li>Servlet container embedding? </li></ul><ul><li>Other services? </li></ul><ul><ul><li>Config </li></ul></ul><ul><ul><li>Log </li></ul></ul><ul><ul><li>... </li></ul></ul>
  26. 26. Cocoon-OSGi Architecture Blocks /editor / Http Service Dispatcher
  27. 27. Deployment architecture Cocoon platform Blocks Blocks repository (Maven 2) Blocks discovery (OBR) Deployment service
  28. 28. When? <ul><li>One man show this far </li></ul><ul><li>Can live together with ”ordinary” Cocoon </li></ul><ul><li>Spring-OSGi expected to release 1.0.0 in December </li></ul><ul><li>http://svn.apache.org/repos/asf/cocoon/whiteboard/osgi/ </li></ul>
  29. 29. Conclusion <ul><li>Standard plugin </li></ul><ul><li>Classloader isolation </li></ul><ul><li>Hot deployable blocks </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×