This intensive 4-day course on will give you a thorough grounding in the core principles of OSGi, the Dynamic Module System for Java.
We start by introducing OSGi and describing how it meets the challenge of building modular, scalable applications in Java. Next we review the three main open-source implementations of OSGi, running them up and installing our first bundles (modules), before focussing principally on one of them (Equinox). Then we dive into the construction of OSGi bundles, how to describe dependencies between bundles and manage multiple versions of each.
Then we move onto the dynamic aspects of OSGi, starting with basic bundle lifecycle concerns before moving on to "services", which are OSGi's solution to dynamic late binding. After covering the nuts and bolts of services in some depth we take a side look at the concerns of concurrent programming in Java and how this subject affects OSGi in particular. Then we take a look at two of the most important patterns used for constructing real applications out of services, namely the "whiteboard" pattern and "extender model".
After this we move up an abstraction level and look at how to achieve component-oriented design and development with OSGi; starting with a definition of what a "component" is and reviewing the three main component frameworks built on top of OSGi (Declarative Services, Spring-DM and iPOJO).
Next we review some of the more practical aspects of developing with OSGi, including the tools we have available, how to adapt popular build tools such as ANT and Maven to build OSGi bundles, and how to do unit and system testing of bundles.
Finally we take a brief look at advanced topics such as the use of legacy Java code under OSGi, integrating native libraries, embedding an OSGi framework in a larger application, and what the future holds for OSGi.
OSGi Basics
The Challenge of Modularity
- The State of the Art in Standard Java
- "JAR Hell"
- The Failure of J2EE
- What Is a Module?
OSGi Bundles
- Nuts and Bolts: What Does a Bundle Look Like?
- Building our First Bundle
- Exporting and Importing
- Keeping Internals Hidden
OSGi Implementations
- Overview of Equinox, Knopflerfish and Felix
- Getting Equinox
- Launching Equinox
- Using the OSGi Console
Dependencies and Version Management
- Importing Packages vs Requiring Bundles
- Versioning of Bundles and Packages
- Version Ranges
- Managing Versions
- Bundle Repositories
The Resolver
- The Class Resolution Process
- Using JRE Packages
- Execution Environments
- Class Space Consistency and "Uses" Constraints
Dynamic Modules
Bundle Lifecycle
- Installation and Uninstallation
- Resolving
- The Active State
- Bundle Activators
Introduction to Services
- Late Binding in Java
- Dependency Injection
- Dynamic Services
- Registering and Unregistering a Service
- Looking up a Service
- Listening to Services
Tracking Services
- Introduction to ServiceTracker
- Extending the ServiceTracker Class
- Cardinality and Selection Rules
Service Properties
- Registering Service Properties
- Filtering on Properties
Concurrency
- The Price of Freedom
- Review of Java Concurrency Practices
- Safe Publication in OSGi
- Avoiding Deadlock
- GUI Development
The Whiteboard Pattern and Event Admin
- Review of the Classic Observer Pattern
- Problems with the Observer Pattern
- Fixing the Observer Pattern
- Overview of the Whiteboard Pattern
- Registering Listeners
- Sending Events
- Overview of Event Admin
- The Event Object
- Receiving Events
- Synchronous vs Asynchronous Delivery
Extending Without Code
- The Extender Model
- Inspecting Bundles
- Tracking Bundles
- Synchronous and Asynchronous Bundle Listeners
- The Eclipse Extension Registry
Component-Oriented Development
Introduction to Components
- Definition of a Component
- Environment-Aware Components
- Review of Component Frameworks for OSGi
Declarative Services
- Simple Components
- Service Dependencies
- Cardinality
- Activation
- Component Properties
Configuration Admin
- Managed Services
- Managed Service Factories
- Creating and Updating Configurations
- Building a Configuration Agent
- Declarative Services and Configuration Admin
Other Component Frameworks
- Spring Dynamic Modules
- iPOJO
- Interoperablity of Component Frameworks
OSGi in Practice
Building OSGi Bundles
- Review of Approaches to Builing Bundles
- How BND Works
- Using BND with Maven
- Eclipse PDE
Testing Bundles
- Unit Testing with JUnit
- System Testing
- Testing Frameworks
Advanced Topics
- Integrating Legacy Code
- Using the Extender Model to Impersonate Bundles
- Embedding OSGi in a Java Application
- Using OSGi in an Application Server
- Using Native Libraries
- The Future of OSGi