|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=CLASS) @Target(value=METHOD) public @interface ConfigurationDependency
Annotates a method for injecting a Configuration Dependency. A configuration dependency is always required, and allows you to depend on the availability of a valid configuration for your component. This dependency requires the OSGi Configuration Admin Service.
In the following example, the "Printer" component depends on a configuration whose PID name is "org.apache.felix.sample.Printer". This service will initialize its ip/port number from the provided configuration:
package org.apache.felix.sample; @Component public class Printer { @ConfigurationDependency void updated(Dictionary config) { // load printer ip/port from the provided dictionary. } }
This other example shows how to specify a configuration dependency, as well as meta data used to customize the WebConsole GUI. Using these meta data, you can specify for example the default value for your configurations data, some descriptions, the cardinality of configuration values, etc ...
package org.apache.felix.sample; @Component public class Printer { @ConfigurationDependency( heading = "Printer Service", description = "Declare here parameters used to configure the Printer service", metadata = { @PropertyMetaData(heading = "Ip Address", description = "Enter the ip address for the Printer service", defaults = { "127.0.0.1" }, type = String.class, id = "IPADDR", cardinality = 0), @PropertyMetaData(heading = "Port Number", description = "Enter the port number for the Printer service", defaults = { "4444" }, type = Integer.class, id = "PORTNUM", cardinality = 0) } ) void updated(Dictionary config) { // load configuration from the provided dictionary. } }
Optional Element Summary | |
---|---|
String |
description
A human readable description of the PID this annotation is associated with. |
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. |
String |
pid
Returns the pid for a given service (by default, the pid is the service class name). |
boolean |
propagate
Returns true if the configuration properties must be published along with the service. |
public abstract String pid
public abstract boolean propagate
public abstract String heading
public abstract String description
public abstract PropertyMetaData[] metadata
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |