OSGi property annotations for remaining apps
Change-Id: I5f87ebeb65eb85ee7161e35a838d9275fde22787
diff --git a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java
index a3bb6ef..cce6102 100644
--- a/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java
+++ b/apps/influxdbmetrics/src/main/java/org/onosproject/influxdbmetrics/DefaultInfluxDbMetricsReporter.java
@@ -37,12 +37,23 @@
import java.util.Dictionary;
import java.util.concurrent.TimeUnit;
+import static org.onosproject.influxdbmetrics.OsgiPropertyConstants.METRIC_NAMES;
+import static org.onosproject.influxdbmetrics.OsgiPropertyConstants.METRIC_NAMES_DEFAULT;
+import static org.onosproject.influxdbmetrics.OsgiPropertyConstants.MONITOR_ALL;
+import static org.onosproject.influxdbmetrics.OsgiPropertyConstants.MONITOR_ALL_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
* A Metric reporter that reports all metrics value to influxDB server.
*/
-@Component(immediate = true, service = InfluxDbMetricsReporter.class)
+@Component(
+ immediate = true,
+ service = InfluxDbMetricsReporter.class,
+ property = {
+ MONITOR_ALL + ":Boolean=" + MONITOR_ALL_DEFAULT,
+ METRIC_NAMES + "=" + METRIC_NAMES_DEFAULT
+ }
+)
public class DefaultInfluxDbMetricsReporter implements InfluxDbMetricsReporter {
private final Logger log = getLogger(getClass());
@@ -50,7 +61,7 @@
private static final TimeUnit REPORT_TIME_UNIT = TimeUnit.MINUTES;
private static final String DEFAULT_PROTOCOL = "http";
- private static final String DEFAULT_METRIC_NAMES = "default";
+
private static final String SEPARATOR = ":";
private static final int DEFAULT_CONN_TIMEOUT = 1000;
private static final int DEFAULT_READ_TIMEOUT = 1000;
@@ -67,15 +78,11 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ClusterService clusterService;
- //@Property(name = "monitorAll", boolValue = true,
- // label = "Enable to monitor all of metrics stored in metric registry " +
- // "default is true")
- protected boolean monitorAll = true;
+ /** Enable to monitor all of metrics stored in metric registry default is true. */
+ protected boolean monitorAll = MONITOR_ALL_DEFAULT;
- //@Property(name = "metricNames", value = DEFAULT_METRIC_NAMES,
- // label = "Names of metric to be monitored in third party monitoring " +
- // "server; default metric names are 'default'")
- protected String metricNames = DEFAULT_METRIC_NAMES;
+ /** Names of metric to be monitored in third party monitoring server; default metric names are 'default'. */
+ protected String metricNames = METRIC_NAMES_DEFAULT;
protected String address;
protected int port;
@@ -224,11 +231,11 @@
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
- String metricNameStr = Tools.get(properties, "metricNames");
- metricNames = metricNameStr != null ? metricNameStr : DEFAULT_METRIC_NAMES;
+ String metricNameStr = Tools.get(properties, METRIC_NAMES);
+ metricNames = metricNameStr != null ? metricNameStr : METRIC_NAMES_DEFAULT;
log.info("Configured. Metric name is {}", metricNames);
- Boolean monitorAllEnabled = Tools.isPropertyEnabled(properties, "monitorAll");
+ Boolean monitorAllEnabled = Tools.isPropertyEnabled(properties, MONITOR_ALL);
if (monitorAllEnabled == null) {
log.info("Monitor all metrics is not configured, " +
"using current value of {}", monitorAll);