Enabling modularization through OSGi and SpringDM

Uploaded on


More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Enabling Modularization through OSGi and SpringDynamicModules Mukul Kumar System Software Engineer India Software Labs IBM, INDIA [email_address]
  • 2. Agenda
    • OSGi as Service Platform
    • Spring Dynamic Modules
    • Summary
    • Q & A
  • 3. OSGi as Service Platform
    • Limitations with conventional Java applications
    • What is OSGi ?
    • OSGi Framework Architecture
    • SOA Infusion
    • Demo
  • 4. Limitations with conventional Java applications
    • JAR Hell ( limitations caused by JAR files )
    • No Runtime boundaries between the JAR files.
    • Information hiding only at class level but not at modular level.
    • No versioning
    • Classloading
    • Dependency on other JAR(s)
  • 5. JSR 277 – Java Module System
    • Module is a deployment abstraction.
    • Defines a distribution format (i.e. Java Module) and a repository for collections of Java code and related resources. It also defines the discovery, loading, and integrity check mechanism at runtime.
    • JSR 277 defines a static module system. There is no dynamic loading and unloading of modules/bundles, any change will require to reboot the JVM.
  • 6. What is OSGi ?
    • OSGi stands for Open Service Gateway Initiative.
    • OSGi is Dynamic Module System for Java.
    • OSGi framework implements a complete service oriented and dynamic module system.
    • OSGi specification also enables modules/bundles to hide their implementation from other modules/bundles.
  • 7. OSGi Framework Architecture http://www.osgi.org
  • 8. Module Layer
    • Packaging: Reusable bundles contains application code and libraries.
    • Code Security: Supports code hiding and explicit sharing.
    • Versioning : Different versions of same JAR can be used in single VM.
    • Classloading : Advance classloading schemes.
    bundle bundle bundle bundle bundle bundle
  • 9. Life Cycle Layer
    • Offers an API for bundle life cycle management that manages modules at runtime.
    • These dynamics are generally not part of applications and fully protected with security mechanism.
    installed resolved uninstalled active stopping starting start stop install uninstall uninstall
  • 10. Bundles
    • A bundle mainly consists of a group of Java classes and a metadata descriptor, MANIFEST.MF file.
  • 12. Activator
    • Bundle is started by BundleActivator class.
    • Interface has 2 methods.
      • start(): initialize and return immediately
      • stop(): clean up
    • BundleContext gives access to framework functions.
    • Framework functions enables us to start/stop the group of applications.
  • 13. Service Layer
    • Provides an In-VM service Model
      • Discover services based on their interface or properties.
      • Bind to one or more services.
    OSGi Service Registry Bundle A Bundle B registers get
  • 14. SOA Infusion
    • Based on contract (interface)
    • Separate the contract form implementations.
    • Dynamically discover and bind alternate implementations inside a Java VM.
    • Components are reusable.
    Service Contract Component provides uses courtesy:
  • 15. DEMO
    • Hello OSGi
    • Service Registration
    • Service Tracker
  • 16. Service Registration
    • Exporting Service
        • Export-Package : com.eclipseday.osgi.employee.service
    • Importing Service
        • Import-Package : com.eclipseday.osgi.employee.service
    • This is also called Bundle Dependency Management, facilitated by OSGi Framework Module Layer.
  • 17. Service Registration
  • 18. Service Tracker
    • Extend from class org.osgi.util.tracker.ServiceTracker
  • 19. Service Tracker
  • 20. Spring Dynamic Modules
    • Spring Framework
    • What is SpringDM ?
    • Extender Pattern
    • Spring Application Context
    • Demo
  • 21. Spring Framework
    • Lightweight Container
      • Manages through the bean lifecycle
    • Provide support for IOC
      • Declarative support for beans wiring
    • Provide support for AOP
      • Advice can be applied declaratively
    • Integration with Web frameworks
      • Spring MVC, Struts, JSF…
    • Spring JDBC support and ORM integration
  • 22. Without Dependency Injection
  • 23. With Dependency Injection
    • Based on Interface, not coupled to implementation.
    • Reusable
    • Easily testable
  • 24. What is SpringDM ?
    • SpringDM brings OSGi benefits in to Java EE application development.
    • An OSGi Service can be imported and exported as if it were a Spring bean.
    • SpringDM is also at the heart of springsource dm server.
    • Download SpringDM from: http://www.springframework.org/osgi
  • 25. Extender Pattern: org.springframework.osgi.bundles.extender
    • Checks for the spring enabled bundles to be installed and create application/module context for those bundles.
    • Spring enabled bundle:
      • META-INF/ spring/*.xml
      • Spring-Context header in MANIFEST.MF
  • 26.  
  • 27. Spring Application Context
    • For each spring enabled bundle, Spring Application Context (or Module Context ) will be created.
    • Application Context will be created when bundle is started and destroyed when bundle is stopped.
    • A Spring Bean can be published as if it were an OSGi Service .
    • An OSGi Service can be imported as if it were a Spring Bean in that Application Context.
    • Spring Beans/ OSGi Services communicate via OSGi Service Registry.
    • Saves interaction with low level OSGi Framework API.
  • 28. DEMO
    • Exporting a Spring Bean as OSGi Service
    • Importing an OSGi Service as Spring Bean
    • Using Service/Bean
  • 29. Service Export Service Import
  • 30. Using the Service
  • 31. Summary
    • OSGi benefits modular application development via:
      • Versioning
      • Modularity
      • Life Cycle Management
      • Service Registry
    • SpringDM supports modular application development by bringing OSGi benefits and Spring IOC support together.
      • No need to work with low level OSGi framework API.
      • Manages the service dynamics internally.
  • 32.
    • Q & A
  • 33.
    • Further Queries, Feedback, Suggestions …
    • are welcome @
    • [email_address]
  • 34.
    • Thank you !