|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=CLASS) @Target(value=TYPE) public @interface FactoryConfigurationAdapterService
Annotates a class that acts as a Factory Configuration Adapter Service. For each new Config Admin
factory configuration matching
the specified factoryPid, an instance of this service will be created.
The adapter will be registered with the specified interface, and with the specified adapter service properties.
Depending on the propagate
parameter, every public factory configuration properties
(which don't start with ".") will be propagated along with the adapter service properties.
Like in @ConfigurationDependency
, you can optionally specify the meta types of your
configurations for Web Console GUI customization (configuration heading/descriptions/default values/etc ...).
Here, this is the same example as above, but using meta types:@FactoryConfigurationAdapterService(factoryPid="DictionaryServiceFactory", updated="updated") public class DictionaryImpl implements DictionaryService { /** * The key of our config admin dictionary language. */ final static String LANG = "lang"; /** * The key of our config admin dictionary values. */ final static String WORDS = "words"; /** * We store all configured words in a thread-safe data structure, because ConfigAdmin * may invoke our updated method at any time. */ private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>(); /** * Our Dictionary language. */ private String m_lang; protected void updated(Dictionary<String, ?> config) { m_lang = (String) config.get(LANG); m_words.clear(); String[] words = (String[]) config.get(WORDS); for (String word : words) { m_words.add(word); } } ... }
@FactoryConfigurationAdapterService( factoryPid="DictionaryServiceFactory", propagate=true, updated="updated", heading="Dictionary Services", description="Declare here some Dictionary instances, allowing to instantiates some DictionaryService services for a given dictionary language", metadata={ @PropertyMetaData( heading="Dictionary Language", description="Declare here the language supported by this dictionary. " + "This property will be propagated with the Dictionary Service properties.", defaults={"en"}, id=DictionaryImpl.LANG, cardinality=0), @PropertyMetaData( heading="Dictionary words", description="Declare here the list of words supported by this dictionary. This properties starts with a Dot and won't be propagated with Dictionary OSGi service properties.", defaults={"hello", "world"}, id=DictionaryImpl.WORDS, cardinality=Integer.MAX_VALUE) } ) public class DictionaryImpl implements DictionaryService { /** * The key of our config admin dictionary language. */ final static String LANG = "lang"; /** * The key of our config admin dictionary values. */ final static String WORDS = "words"; /** * We store all configured words in a thread-safe data structure, because ConfigAdmin * may invoke our updated method at any time. */ private CopyOnWriteArrayList<String> m_words = new CopyOnWriteArrayList<String>(); /** * Our Dictionary language. */ private String m_lang; protected void updated(Dictionary<String, ?> config) { m_lang = (String) config.get(LANG); m_words.clear(); String[] words = (String[]) config.get(WORDS); for (String word : words) { m_words.add(word); } } ... }
Optional Element Summary | |
---|---|
String |
description
A human readable description of the PID this annotation is associated with. |
String |
factoryMethod
Sets the static method used to create the adapter instance. |
String |
factoryPid
Returns the factory pid whose configurations will instantiate the annotated service class. |
String |
heading
The label used to display the tab name (or section) where the properties are displayed. |
PropertyMetaData[] |
metadata
The list of properties types used to expose properties in web console. |
boolean |
propagate
Returns true if the configuration properties must be published along with the service. |
Property[] |
properties
Adapter Service properties. |
Class<?>[] |
provides
The interface(s) to use when registering adapters. |
String |
updated
The Update method to invoke (defaulting to "updated"), when a factory configuration is created or updated |
public abstract Class<?>[] provides
public abstract Property[] properties
public abstract String factoryPid
public abstract String updated
public abstract boolean propagate
public abstract String heading
public abstract String description
public abstract PropertyMetaData[] metadata
public abstract String factoryMethod
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |