Exporting Spring components as OSGi services

osgi, service, spring

Solution

I assume you're familiar with Eclipse Gemini Blueprint (formerly Spring Dynamic Modules, formerly Spring OSGi)?

You export your beans using the `<service>`-tag. I'm not sure if you can export all `@Component` etc. annotated beans automatically though.

Problem

Is it possible to automatically register a Spring `@Component` (or one of its specifications; e.g. `@Repository`) as an OSGi service? So I can use autowiring and all other benefits of Spring inside one bundle and OSGi Service Registry to communicate between bundles? UPDATE: From this discussion it doesn't seem to be possible using standard Blueprint, only in Eclipse Gemini.

Original source