-
Notifications
You must be signed in to change notification settings - Fork 6
Why Declarative Service Annotations
When you develop OSGi services using declarative services (DS), you have implement a component class as well as a component description in form of a XML document.
The Plug-in Development Environment (PDE) supports the development of declarative services by providing a specialised editor (the component description editor) that is part of the PDE since Eclipse 3.5:
The component description editor simplifies the development of declarative service components, but manually editing the xml-based component description is still inconvenient for several reasons:
- You have to switch beetween the Java editor and the component description editor. Refactorings (e.g. moving or renaming a type) cause invalid component descriptions as referenced types and/or methods are not updated automatically.
- Typos in method names (activate, activate etc.) cause that the affected component are not excuted in the intended way.
- The information in the XML may be duplicate of information in the source code.
To provide a solution to this issues, the OSGi alliance specified several annotations (@Component, @Reference etc.) to simplify the development of declarative service components. Using these annotations the component description can be automatically generated from the underlying component class at buildtime: