I am interested in using OSGI as a means of managing plugins for a project. That is there can be many implemenators of my interface, each appearing in its own / separate OSGI bundle with the implementation class exported…
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Declarative Service should be the way to go.
You can declare your interface as a service
Each implementation of that interface can define Bundle activation and de-activation methods.
But what is really neat is their nature: if you are using the latest SCR (the ‘Service Component Runtime’ which is an ‘extender bundle’ implementing the new and improved OSGi R4.2 DS – Declarative Service – specification), your classes will not import anything from the OSGI model. They remain pure POJO.
Then define another service which depends on your first service:
That service will detect and list all your concrete instances of your first service and deal with them as you intent to.
See the Eclipse Extensions and Declarative Services question for more details.
The presentation: Component Oriented Development in OSGi with Declarative Services, Spring Dynamic Modules and Apache iPOJO, from EclipseCON2009, will provide you with a concrete example.