You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pierre De Rop (JIRA)" <ji...@apache.org> on 2015/03/01 15:21:04 UTC
[jira] [Updated] (FELIX-4805) Deprecate DM annotation metatypes
[ https://issues.apache.org/jira/browse/FELIX-4805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre De Rop updated FELIX-4805:
---------------------------------
Component/s: (was: Dependency Manager)
Dependency Manager Runtime
Dependency Manager Annotations
> Deprecate DM annotation metatypes
> ---------------------------------
>
> Key: FELIX-4805
> URL: https://issues.apache.org/jira/browse/FELIX-4805
> Project: Felix
> Issue Type: Improvement
> Components: Dependency Manager Annotations, Dependency Manager Runtime
> Affects Versions: dependencymanager.annotations-3.2.0, dependencymanager.runtime-3.2.0
> Reporter: Pierre De Rop
> Assignee: Pierre De Rop
> Priority: Trivial
> Fix For: org.apache.felix.dependencymanager-r1
>
>
> 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):
> {code}
> 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();
> }
> {code}
> and Here is the definition of the Dictionary service which is using the "Configurable" bnd helper that can be used to instantiate the DictionaryConfiguration:
> {code}
> 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();
> m_words.clear();
> for (String word : cnf.words()) {
> m_words.add(word);
> }
> }
> }
> public boolean checkWord(String word) {
> return m_words.contains(word);
> }
> }
> {code}
> 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
(v6.3.4#6332)