OSGi property annotations for cip app
Change-Id: I62a7afb0eaa469de173934cf4c19ccafd9935f51
diff --git a/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java b/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java
index 17259fd..fd8bb40 100644
--- a/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java
+++ b/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java
@@ -39,6 +39,12 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_ADAPTER;
+import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_ADAPTER_DEFAULT;
+import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_IP;
+import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_IP_DEFAULT;
+import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_MASK;
+import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_MASK_DEFAULT;
/**
* Manages cluster IP address alias.
@@ -54,7 +60,14 @@
* This will make sure that if the process is killed abruptly, the IP alias
* will be dropped upon respawn.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ ALIAS_IP + "=" + ALIAS_IP_DEFAULT,
+ ALIAS_MASK + "=" + ALIAS_MASK_DEFAULT,
+ ALIAS_ADAPTER + "=" + ALIAS_ADAPTER_DEFAULT
+ }
+)
public class ClusterIpManager {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -75,17 +88,14 @@
private NodeId localId;
private boolean wasLeader = false;
- // By default there is no IP; this has to be configured
- //@Property(name = "aliasIp", value = "", label = "Alias IP address")
- private String aliasIp = "";
+ /** Alias IP address. */
+ private String aliasIp = ALIAS_IP_DEFAULT;
- public static final String DEFAULT_MASK = "255.255.0.0";
- //@Property(name = "aliasMask", value = DEFAULT_MASK, label = "Alias IP mask")
- private String aliasMask = DEFAULT_MASK;
+ /** Alias IP mask. */
+ private String aliasMask = ALIAS_MASK_DEFAULT;
- public static final String ETH_0 = "eth0:0";
- //@Property(name = "aliasAdapter", value = ETH_0, label = "Alias IP adapter")
- private String aliasAdapter = ETH_0;
+ /** Alias IP adapter. */
+ private String aliasAdapter = ALIAS_ADAPTER_DEFAULT;
@Activate
protected void activate(ComponentContext context) {
@@ -114,9 +124,9 @@
protected void modified(ComponentContext context) {
log.info("Received configuration change...");
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
- String newIp = get(properties, "aliasIp");
- String newMask = get(properties, "aliasMask");
- String newAdapter = get(properties, "aliasAdapter");
+ String newIp = get(properties, ALIAS_IP);
+ String newMask = get(properties, ALIAS_MASK);
+ String newAdapter = get(properties, ALIAS_ADAPTER);
// Process any changes in the parameters...
if (!Objects.equals(newIp, aliasIp) ||
diff --git a/apps/cip/src/main/java/org/onosproject/cip/OsgiPropertyConstants.java b/apps/cip/src/main/java/org/onosproject/cip/OsgiPropertyConstants.java
new file mode 100644
index 0000000..c6bcb52
--- /dev/null
+++ b/apps/cip/src/main/java/org/onosproject/cip/OsgiPropertyConstants.java
@@ -0,0 +1,31 @@
+/*
+ * 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.cip;
+
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String ALIAS_IP = "aliasIp";
+ static final String ALIAS_IP_DEFAULT = "";
+
+ static final String ALIAS_MASK = "aliasMask";
+ static final String ALIAS_MASK_DEFAULT = "255.255.0.0";
+
+ static final String ALIAS_ADAPTER = "aliasAdapter";
+ static final String ALIAS_ADAPTER_DEFAULT = "eth0:0";
+}