OSGi property annotations for remaining apps
Change-Id: I5f87ebeb65eb85ee7161e35a838d9275fde22787
diff --git a/apps/routing/common/src/main/java/org/onosproject/routing/impl/DirectHostManager.java b/apps/routing/common/src/main/java/org/onosproject/routing/impl/DirectHostManager.java
index da62a5b..9348665 100644
--- a/apps/routing/common/src/main/java/org/onosproject/routing/impl/DirectHostManager.java
+++ b/apps/routing/common/src/main/java/org/onosproject/routing/impl/DirectHostManager.java
@@ -64,12 +64,20 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.packet.IpAddress.Version.INET6;
+import static org.onosproject.routing.impl.OsgiPropertyConstants.ENABLED;
+import static org.onosproject.routing.impl.OsgiPropertyConstants.ENABLED_DEFAULT;
/**
* Reactively handles sending packets to hosts that are directly connected to
* router interfaces.
*/
-@Component(immediate = true, enabled = false)
+@Component(
+ immediate = true,
+ enabled = false,
+ property = {
+ ENABLED + ":Boolean=" + ENABLED_DEFAULT
+ }
+)
public class DirectHostManager {
private Logger log = LoggerFactory.getLogger(getClass());
@@ -89,11 +97,8 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
- private static final boolean DEFAULT_ENABLED = false;
-
- //@Property(name = "enabled", boolValue = DEFAULT_ENABLED,
- // label = "Enable reactive directly-connected host processing")
- private volatile boolean enabled = DEFAULT_ENABLED;
+ /** Enable reactive directly-connected host processing. */
+ private volatile boolean enabled = ENABLED_DEFAULT;
private static final String APP_NAME = "org.onosproject.directhost";
@@ -120,7 +125,7 @@
@Modified
private void modified(ComponentContext context) {
- Boolean boolEnabled = Tools.isPropertyEnabled(context.getProperties(), "enabled");
+ Boolean boolEnabled = Tools.isPropertyEnabled(context.getProperties(), ENABLED);
if (boolEnabled != null) {
if (enabled && !boolEnabled) {
enabled = false;
diff --git a/apps/routing/common/src/main/java/org/onosproject/routing/impl/OsgiPropertyConstants.java b/apps/routing/common/src/main/java/org/onosproject/routing/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..ca4643f
--- /dev/null
+++ b/apps/routing/common/src/main/java/org/onosproject/routing/impl/OsgiPropertyConstants.java
@@ -0,0 +1,28 @@
+/*
+ * 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.routing.impl;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String ENABLED = "enabled";
+ static final boolean ENABLED_DEFAULT = false;
+}