Spring Dynamic Modules


Published on

Spring Dynamic Modules: OSGi meets the Spring Framework

Introductive presentation about Spring DM and OSGi presented at the Spring Framework Italian Group in Cagliari, September 2009

Published in: Technology, Business

Spring Dynamic Modules

  1. 1. Spring Dynamic Modules OSGi meets the Spring Framework Filippo Diotalevi <filippo@diotalevi.com> Spring Framework Italian Meeting, Cagliari, September 12th 2009
  2. 2. About OSGi and Java Enterprise consultant Java User Group Milano founder and coordinator Apache Felix committer http://www.diotalevi.com filippo@diotalevi.com
  3. 3. http://www.osgilook.com http://www.jaxitalia.com
  4. 4. Summary OSGi Spring Dynamic Modules for OSGi What’s next
  5. 5. OSGi A dynamic module system for Java (Demo)
  6. 6. Module System Clear boundaries Dependencies Metadata Lifecycle
  7. 7. Lifecycle of bundle
  8. 8. Service System Service Oriented Architecture in the JVM
  9. 9. Service System Service Registry Register Retrieve Service Service Bundle Provider Bundle Consumer
  10. 10. What’s an OSGi Application? A collection of bundles interacting via Service interfaces Bundles developed and installed independently Bundle and services can appear and disappear
  11. 11. What’s behind the demo Register Service Circle Registry Register Bundle Circle Listen for Triangle and Provide the Circle retrieve implementation Shapes Bundle Host Bundle Triangle Provide the Frame and Provide the Triangle define the Shape interface implementation
  12. 12. Why Spring DM? OSGi in NOT about user interfaces OSGi is about building modular and service oriented applications Enterprise applications need modularity and SOA
  13. 13. Spring Dynamic Modules Part of the Spring open source portfolio Formerly known as Spring-OSGi Works with every OSGi container Allows you to implement Spring applications on top of any OSGi framework
  14. 14. Spring DM idea Application Application Context Context Bundle B Bundle A Application Context Bundle C Spring + Spring DM Imported Service Exported Service OSGi Container Spring Bean Java Virtual Machine
  15. 15. Bundles & Spring One application context per bundle When a bundle is started, its application context is discovered and instantiated Bundles can export Spring beans as OSGi services Bundles can import OSGi services
  16. 16. Beans as OSGi Services <beans> <bean name="customerService" class="demo.customerservice.impl.CustomerServiceImpl"/> <osgi:service id="customerServiceOsgi" ref="customerService" interface="demo.customerservice.CustomerService"/> </beans>
  17. 17. Importing OSGi services <beans> <osgi:reference id="customerServiceOsgi" interface="demo.osgi.customerservice.CustomerService"/> <bean id="orderService" class="demo.osgi.orderservice.internal.OrderServiceImpl"> <property name="customerService"> <reflocal="customerServiceOsgi"/> </property> </bean> </beans>
  18. 18. Bigger picture Application Context Customer Service Expose Customer Service Service Registry Retrieve Customer Service Application Context Customer Order Service Service use Proxy
  19. 19. Result (Almost) no dependencies on OSGi APIs Everything is a POJO (Spring philosophy) Improved application modularity
  20. 20. Going forward Standardization: OSGi Blueprint Service Enterprise OSGi support in Spring DM Full support for Web Applications and Java EE components Integration with OSGi Remote-Services Inter-JVM services
  21. 21. Questions?
  22. 22. http://www.osgilook.com http://www.jaxitalia.com
  23. 23. Images used: http://www.flickr.com/photos/etringita/2722410302/ http://www.sxc.hu/photo/1124847 http://www.sxc.hu/photo/1222662 http://www.sxc.hu/photo/1038332 http://www.sxc.hu/photo/1039992 http://www.sxc.hu/photo/994582