OSGi property annotations for remaining apps
Change-Id: I5f87ebeb65eb85ee7161e35a838d9275fde22787
diff --git a/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/NetworkDiagnosticManager.java b/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/NetworkDiagnosticManager.java
index 3a9635c..b787447 100644
--- a/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/NetworkDiagnosticManager.java
+++ b/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/NetworkDiagnosticManager.java
@@ -44,13 +44,21 @@
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.fnl.impl.OsgiPropertyConstants.AUTO_REGISTER_DEFAULT_DIAGNOSTICS;
+import static org.onosproject.fnl.impl.OsgiPropertyConstants.AUTO_REGISTER_DEFAULT_DIAGNOSTICS_DEFAULT;
/**
* Default implementation of the Network Troubleshooting Core Service.
*
* It is simply modularized at present.
*/
-@Component(immediate = true, service = NetworkDiagnosticService.class)
+@Component(
+ immediate = true,
+ service = NetworkDiagnosticService.class,
+ property = {
+ AUTO_REGISTER_DEFAULT_DIAGNOSTICS + ":Boolean=" + AUTO_REGISTER_DEFAULT_DIAGNOSTICS_DEFAULT
+ }
+)
public class NetworkDiagnosticManager implements NetworkDiagnosticService {
/**
@@ -59,9 +67,6 @@
public static final String NTS_APP_NAME =
"org.onosproject.FNL.Network-Troubleshoot";
- private static final String PROPERTY_AUTO_REGISTER_DIAG =
- "autoRegisterDefaultDiagnostics";
-
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY)
@@ -86,9 +91,8 @@
protected LinkService ls;
- //@Property(name = PROPERTY_AUTO_REGISTER_DIAG, boolValue = true,
- // label = "Automatically register all of default diagnostic modules.")
- private boolean autoRegister = true;
+ /** Automatically register all of default diagnostic modules. */
+ private boolean autoRegisterDefaultDiagnostics = AUTO_REGISTER_DEFAULT_DIAGNOSTICS_DEFAULT;
private ApplicationId appId;
@@ -132,19 +136,19 @@
Dictionary<?, ?> properties = context.getProperties();
Boolean autoRegisterEnabled =
- Tools.isPropertyEnabled(properties, PROPERTY_AUTO_REGISTER_DIAG);
+ Tools.isPropertyEnabled(properties, AUTO_REGISTER_DEFAULT_DIAGNOSTICS);
if (autoRegisterEnabled == null) {
log.warn("Auto Register is not configured, " +
- "using current value of {}", autoRegister);
+ "using current value of {}", autoRegisterDefaultDiagnostics);
} else {
- autoRegister = autoRegisterEnabled;
+ autoRegisterDefaultDiagnostics = autoRegisterEnabled;
log.info("Configured. Auto Register is {}",
- autoRegister ? "enabled" : "disabled");
+ autoRegisterDefaultDiagnostics ? "enabled" : "disabled");
}
}
private void autoRegisterDiagnostics() {
- if (!autoRegister) {
+ if (!autoRegisterDefaultDiagnostics) {
return;
}
diff --git a/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/OsgiPropertyConstants.java b/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..9921413
--- /dev/null
+++ b/apps/network-troubleshoot/core/src/main/java/org/onosproject/fnl/impl/OsgiPropertyConstants.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.fnl.impl;
+
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String AUTO_REGISTER_DEFAULT_DIAGNOSTICS = "autoRegisterDefaultDiagnostics";
+ static final boolean AUTO_REGISTER_DEFAULT_DIAGNOSTICS_DEFAULT = true;
+}