Chapter 5. Working with OSGi services

 

This chapter covers

  • Using dependency injection with OSGi services
  • Registering and referencing services with Spring DM
  • Handling service dynamics with Spring DM
  • Handling service collections with Spring DM

In the previous chapter, we described how Spring DM provides support for managing Spring-powered OSGi components as well as web components. We showed that the framework doesn’t actually use OSGi’s activator feature but instead provides an implementation of the extender pattern to decouple components’ implementation from the enabling technology and to configure bundles globally by providing a single point of management. These mechanisms allow components to use classic Spring features, such as dependency injection, AOP, and support for enterprise applications.

In this chapter, we’ll focus on Spring DM’s support of OSGi services. As we emphasized in chapter 1, services are a key OSGi feature because they allow you to define entry points for component interactions, and they provide a robust way to take into account the dynamic nature of OSGi.

5.1. Dependency injection and OSGi services

5.2. The thread context classloader and its use in OSGi

5.3. Advanced OSGi service configuration

5.4. Handling OSGi service dynamics

5.5. Handling collections of OSGi services

5.6. Programmatic service support

5.7. Summary