O'Reilly logo

OSGi and Apache Felix 3.0 by Walid Joseph Gédéon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

iPOJO using annotations

An alternative way of tagging components for iPOJO is to annotate them directly in the Java code. iPOJO provides annotations support through the org.apache.felix.ipojo.annotations library.

Overview

There are some gains in clarity of the code when using annotations and it also simplifies updates by keeping the configuration closer to its target class or field.

For instance, in the previous declaration of the bookshelf service, we could have replaced the configuration entry in the meta.xml file:

<component
classname=
"com.packtpub.felix.bookshelf.service.impl.BookshelfServiceImpl"
name="BookshelfServiceImpl">
<provides />
<requires field="inventory" />
</component>

With annotations to the class BookshelfServiceImpl:

@Component(name="BookshelfServiceImpl") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required