felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre De Rop (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FELIX-4805) Deprecate DM annotation metatypes
Date Sun, 22 Feb 2015 22:56:11 GMT
Pierre De Rop created FELIX-4805:

             Summary: Deprecate DM annotation metatypes
                 Key: FELIX-4805
                 URL: https://issues.apache.org/jira/browse/FELIX-4805
             Project: Felix
          Issue Type: Improvement
          Components: Dependency Manager
    Affects Versions: dependencymanager.runtime-3.2.0, dependencymanager.annotations-3.2.0
            Reporter: Pierre De Rop
            Assignee: Pierre De Rop
            Priority: Trivial
             Fix For: dependencymanager.annotations-4.0.0, dependencymanager.runtime-4.0.0

In the Dependency Manager annotations, the DM metatype annotations should be deprecated and
the nice bndtools metatype annotations should be used instead.

For example, the following Dictionary service is defining configuration metatypes using bndtools
metatype annotations (see http://www.aqute.biz/Bnd/MetaType):

package sample;

import aQute.bnd.annotation.metatype.Meta.AD;
import aQute.bnd.annotation.metatype.Meta.OCD;

@OCD(factory = true, description = "Declare here some Dictionary instances.")
public interface DictionaryConfiguration {
    @AD(description = "Describes the dictionary language.", deflt = "en")
    String lang();

    @AD(description = "Declare here the list of dictionary words.")
    List<String> words();

and Here is the definition of the Dictionary service which is using the "Configurable" bnd
helper that can be used to instantiate the DictionaryConfiguration:

package sample;

import aQute.bnd.annotation.metatype.Configurable;

@FactoryConfigurationAdapterService(factoryPidClass = DictionaryConfiguration.class)
public class DictionaryImpl implements DictionaryService {
    private CopyOnWriteArrayList<String> m_words = 
        new CopyOnWriteArrayList<String>();

    private String m_lang;

    protected void updated(Dictionary<String, ?> config) {
        if (config != null) {
            // We use the bnd "Configurable" helper in order to get an implementation for
our DictionaryConfiguration interface.
            DictionaryConfiguration cnf = Configurable.createConfigurable(
                DictionaryConfiguration.class, config);

            m_lang = cnf.lang();
            for (String word : cnf.words()) {

    public boolean checkWord(String word) {
        return m_words.contains(word);

In addition, a "pidClass" attribute should be added in the ConfigurationDependency annotation,
in order to specify the pid using a class name, instead of a String. The same applies for
the FactoryConfigurationAdapterService annotation (see the example above).

This message was sent by Atlassian JIRA

View raw message