Bug 2192 - Part2 - Move getProperty() to a common util module 76/12176/2
authorFlavio Fernandes <ffernand@redhat.com>
Wed, 22 Oct 2014 21:07:34 +0000 (17:07 -0400)
committerFlavio Fernandes <ffernand@redhat.com>
Thu, 23 Oct 2014 21:59:39 +0000 (17:59 -0400)
With this change, the calls to obtain non-default configurations for OVSDB
have been moved to a single function.

Patch 2: Rename utils.common to utils.config
         Remove utils.config dependency from common/parent/pom.xml (not needed by all)

Change-Id: Ibf7e1ee2747c5cafc59da97b5f1f8a4390d95ca2
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
16 files changed:
README
commons/parent/pom.xml
library/pom.xml
library/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java
openstack/net-virt-providers/pom.xml
openstack/net-virt/pom.xml
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/ConfigurationServiceImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java
ovs-sfc/pom.xml
plugin/pom.xml
plugin/src/main/java/org/opendaylight/ovsdb/plugin/OvsVswitchdSchemaConstants.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsVswitchdSchemaConstants.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConfigurationServiceImpl.java
pom.xml
utils/config/pom.xml [new file with mode: 0644]
utils/config/src/main/java/org/opendaylight/ovsdb/utils/config/ConfigProperties.java [new file with mode: 0644]

diff --git a/README b/README
index f7b6cc46fc2ee0d6796080c11979eae6986555fd..c5b249fa6374100bb9339656316a1ffe5782fea6 100644 (file)
--- a/README
+++ b/README
@@ -47,7 +47,7 @@ DIRECTORY ORGANIZATION
   +-- openvswitch : Schema wrapper that represents http://openvswitch.org/ovs-vswitchd.conf.db.5.pdf
   +-- hardwarevtep: Schema wrapper that represents http://openvswitch.org/docs/vtep.5.pdf
 
-- utils : MD-SAL OpenFlow utilities.
+- utils : MD-SAL OpenFlow and OVSDB common utilities.
 
 HOW TO BUILD & RUN
 ==================
index 57ab9a9a4dbb3c1f711b07c36a446812541fa1c1..bb41d309d900acebe25dc80f5e88e529b5aa5f32 100755 (executable)
@@ -33,7 +33,8 @@
     <schema.openvswitch.version>1.1.0-SNAPSHOT</schema.openvswitch.version>
     <schema.hardwarevtep.version>1.1.0-SNAPSHOT</schema.hardwarevtep.version>
     <ovsdb.ofextension.version>1.1.0-SNAPSHOT</ovsdb.ofextension.version>
-    <utils.mdsal.openflow>1.1.0-SNAPSHOT</utils.mdsal.openflow>
+    <ovsdb.utils.config.version>1.1.0-SNAPSHOT</ovsdb.utils.config.version>
+    <utils.mdsal.openflow.version>1.1.0-SNAPSHOT</utils.mdsal.openflow.version>
     <ovsdb.ovssfc.version>0.1.0-SNAPSHOT</ovsdb.ovssfc.version>
     <!-- Skip Coverage and IT by default -->
     <skip.coverage>true</skip.coverage>
index 348ceda8c86fbde28e65cb4f9971ba81ae900377..a2c95bd1ff7e78ef474edfeaf2b2688c30505d36 100755 (executable)
   <packaging>bundle</packaging>
 
   <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.ovsdb</groupId>
+      <artifactId>utils.config</artifactId>
+      <version>${ovsdb.utils.config.version}</version>
+    </dependency>
     <dependency>
       <groupId>ch.qos.logback</groupId>
       <artifactId>logback-classic</artifactId>
                 org.osgi.framework,
                 javax.net.ssl,
                 *</Import-Package>
-            <Bundle-Activator>org.opendaylight.ovsdb.lib.Activator</Bundle-Activator>
+            <Embed-Dependency>utils.config;type=!pom;inline=false</Embed-Dependency>
             <Embed-Transitive>true</Embed-Transitive>
+            <Bundle-Activator>org.opendaylight.ovsdb.lib.Activator</Bundle-Activator>
             <Export-Package>
                 org.opendaylight.ovsdb.lib,
                 org.opendaylight.ovsdb.lib.error,
index 1b752f8a28584bb9ee5ac174c89eda205e9d77c1..326c2ddc82cbcb3f371b3561ab5b838904dade77 100644 (file)
@@ -43,10 +43,8 @@ import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcDecoder;
 import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcEndpoint;
 import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcServiceBinderHandler;
 import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -165,7 +163,7 @@ public class OvsdbConnectionService implements OvsdbConnection {
      * be overridden using the ovsdb.listenPort system property.
      */
     private static void startOvsdbManager() {
-        String portString = getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT);
+        String portString = ConfigProperties.getProperty(OvsdbConnectionService.class, OVSDB_LISTENPORT);
         if (portString != null) {
             ovsdbListenPort = Integer.decode(portString).intValue();
         }
@@ -178,23 +176,6 @@ public class OvsdbConnectionService implements OvsdbConnection {
         }.start();
     }
 
-    // TODO: move getProperty() to a common module
-    private static String getProperty(Class<?> classParam, final String propertyStr) {
-        String value = null;
-        Bundle bundle = FrameworkUtil.getBundle(classParam);
-
-        if (bundle != null) {
-            BundleContext bundleContext = bundle.getBundleContext();
-            if (bundleContext != null) {
-                value = bundleContext.getProperty(propertyStr);
-            }
-        }
-        if (value == null) {
-            value = System.getProperty(propertyStr);
-        }
-        return value;
-    }
-
     /**
      * OVSDB Passive listening thread that uses Netty ServerBootstrap to open passive connection
      * and handle channel callbacks.
index 82fb684dc706ba73b98ff5a9f91410b4b0355ec5..7d20d8f3d895782650e25072110b559d502e010f 100644 (file)
             <groupId>org.opendaylight.ovsdb</groupId>
             <artifactId>openstack.net-virt</artifactId>
         </dependency>
+        <dependency>
+          <groupId>org.opendaylight.ovsdb</groupId>
+          <artifactId>utils.config</artifactId>
+          <version>${ovsdb.utils.config.version}</version>
+        </dependency>
         <dependency>
           <groupId>org.opendaylight.ovsdb</groupId>
           <artifactId>utils.mdsal-openflow</artifactId>
-          <version>1.1.0-SNAPSHOT</version>
+          <version>${utils.mdsal.openflow.version}</version>
         </dependency>
         <dependency>
           <groupId>junit</groupId>
                             org.osgi.framework,
                             *
                         </Import-Package>
-                        <Embed-Dependency>utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
+                        <Embed-Dependency>utils.config,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
                         <Embed-Transitive>true</Embed-Transitive>
                         <Bundle-Activator>org.opendaylight.ovsdb.openstack.netvirt.providers.Activator</Bundle-Activator>
                     </instructions>
index 250342f4c6f704944aa4d8e8db5554c42f62d380..4463a6f0cb553c5f75f409153476149480c7b34b 100644 (file)
       <groupId>org.opendaylight.ovsdb</groupId>
       <artifactId>schema.openvswitch</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.ovsdb</groupId>
+      <artifactId>utils.config</artifactId>
+      <version>${ovsdb.utils.config.version}</version>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
@@ -64,7 +69,9 @@
               org.slf4j,
               org.osgi.framework,
               *</Import-Package>
-              <Export-Package>
+            <Embed-Dependency>utils.config;type=!pom;inline=false</Embed-Dependency>
+            <Embed-Transitive>true</Embed-Transitive>
+            <Export-Package>
                   org.opendaylight.ovsdb.openstack.netvirt.api
               </Export-Package>
             <Bundle-Activator>org.opendaylight.ovsdb.openstack.netvirt.Activator</Bundle-Activator>
index 99b8f4dc650fc8a69dd6e3295c9744a71058643b..97f2e5fd0466c869aab5f0cf7c7e8ac931d40367 100644 (file)
@@ -22,10 +22,8 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -176,7 +174,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
     @Override
     public String getOpenflowVersion(Node node) {
 
-        String configuredVersion = System.getProperty("ovsdb.of.version", "1.3");
+        String configuredVersion = ConfigProperties.getProperty(this.getClass(), "ovsdb.of.version", "1.3");
         if (configuredVersion != null){
             switch (configuredVersion){
                 case "1.0":
@@ -217,24 +215,9 @@ public class ConfigurationServiceImpl implements ConfigurationService {
     @Override
     public String getDefaultGatewayMacAddress(Node node) {
         final String l3gatewayForNode =
-            node != null ? getProperty(this.getClass(), "ovsdb.l3gateway.mac." + node.getNodeIDString()) : null;
-        return l3gatewayForNode != null ? l3gatewayForNode : getProperty(this.getClass(), "ovsdb.l3gateway.mac");
-    }
-
-    // TODO: move getProperty() to a common module
-    private static String getProperty(Class<?> classParam, final String propertyStr) {
-        String value = null;
-        Bundle bundle = FrameworkUtil.getBundle(classParam);
-
-        if (bundle != null) {
-            BundleContext bundleContext = bundle.getBundleContext();
-            if (bundleContext != null) {
-                value = bundleContext.getProperty(propertyStr);
-            }
-        }
-        if (value == null) {
-            value = System.getProperty(propertyStr);
-        }
-        return value;
+            node != null ?
+            ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac." + node.getNodeIDString()) : null;
+        return l3gatewayForNode != null ?
+               l3gatewayForNode : ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac");
     }
 }
index 896fc428a5fa352a4227bfc56feee9df72f52be9..baf1c2a72252ef462fc1e2ff9dbb3a2dc6562d55 100644 (file)
@@ -40,11 +40,9 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.L3ForwardingProvider;
 import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
 import org.opendaylight.ovsdb.openstack.netvirt.api.RoutingProvider;
 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 
 import com.google.common.base.Preconditions;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -97,7 +95,7 @@ public class NeutronL3Adapter {
     private Boolean enabled = false;
 
     void init() {
-        final String enabledPropertyStr = getProperty(this.getClass(), "ovsdb.l3.fwd.enabled");
+        final String enabledPropertyStr = ConfigProperties.getProperty(this.getClass(), "ovsdb.l3.fwd.enabled");
         if (enabledPropertyStr != null && enabledPropertyStr.equalsIgnoreCase("yes")) {
             this.inboundIpRewriteCache = new HashSet<>();
             this.outboundIpRewriteCache = new HashSet<>();
@@ -117,23 +115,6 @@ public class NeutronL3Adapter {
         }
     }
 
-    // TODO: move getProperty() to a common module
-    private static String getProperty(Class<?> classParam, final String propertyStr) {
-        String value = null;
-        Bundle bundle = FrameworkUtil.getBundle(classParam);
-
-        if (bundle != null) {
-            BundleContext bundleContext = bundle.getBundleContext();
-            if (bundleContext != null) {
-                value = bundleContext.getProperty(propertyStr);
-            }
-        }
-        if (value == null) {
-            value = System.getProperty(propertyStr);
-        }
-        return value;
-    }
-
     //
     // Callbacks from OVSDB's northbound handlers
     //
@@ -796,7 +777,7 @@ public class NeutronL3Adapter {
         // TODO: As of Helium, mac address for default gateway is required (bug 1705).
         if (defaultGatewayMacAddress == null) {
             logger.error("ProgramDefaultRoute mac not provided. gatewayIp:{} node:{} action:{}",
-                         defaultGatewayMacAddress, gatewayIp, node, actionForNodeDefaultRoute);
+                         gatewayIp, node, actionForNodeDefaultRoute);
             return new Status(StatusCode.NOTIMPLEMENTED);  // Bug 1705
         }
 
index 0d58e465a4c3f715c7a663b48a5bcb144a6067c9..e04a83db624bebfdbe01199d070fb640603043e6 100644 (file)
             <groupId>org.opendaylight.ovsdb</groupId>
             <artifactId>plugin</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.ovsdb</groupId>
+            <artifactId>utils.config</artifactId>
+            <version>${ovsdb.utils.config.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.ovsdb</groupId>
             <artifactId>utils.mdsal-openflow</artifactId>
-            <version>1.1.0-SNAPSHOT</version>
+            <version>${utils.mdsal.openflow.version}</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.sfc</groupId>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
-                        <Embed-Dependency>utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
+                        <Embed-Dependency>utils.config,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
                         <Embed-Transitive>true</Embed-Transitive>
                         <Include-Resource>
                             /OSGI-OPT/ovs-sfc/53-ovssfc-provider.xml=${project.basedir}/src/main/resources/initial/53-ovssfc-provider.xml,{maven-resources}
index 2f89c64bfee083b0a0c1ec141560c7570ab1c317..416bf8cde7f3dd77373cea85b944bc11d1892330 100755 (executable)
       <groupId>org.opendaylight.ovsdb</groupId>
       <artifactId>schema.openvswitch</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.ovsdb</groupId>
+      <artifactId>utils.config</artifactId>
+      <version>${ovsdb.utils.config.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.ovsdb</groupId>
       <artifactId>schema.hardwarevtep</artifactId>
               javax.net.ssl,
               *
             </Import-Package>
-            <Embed-Dependency>commons-codec,javax.servlet-api,portlet-api,commons-collections;type=!pom;inline=false</Embed-Dependency>
+            <Embed-Dependency>commons-codec,javax.servlet-api,portlet-api,commons-collections,utils.config;type=!pom;inline=false</Embed-Dependency>
             <Embed-Transitive>true</Embed-Transitive>
             <Bundle-Activator>org.opendaylight.ovsdb.plugin.internal.Activator</Bundle-Activator>
             <Private-Package>
index 00701df7b1702ded1d80fe9a50ebb42f603c1b99..a920deca76bfd28f89c202c380e2b7af688b60b3 100644 (file)
 
 package org.opendaylight.ovsdb.plugin;
 
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+
 import com.google.common.collect.Maps;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 
 import java.util.Map;
 
@@ -51,29 +50,13 @@ import java.util.Map;
         addParentColumnToMutate("Manager", "Open_vSwitch", "manager_options");
         addParentColumnToMutate("Controller", "Bridge", "controller");
         // Keep the default value if the property is not set
-        final String autoConfigureControllerStr = getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
+        final String autoConfigureControllerStr =
+                ConfigProperties.getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
         if (autoConfigureControllerStr != null) {
             autoConfigureController = Boolean.getBoolean(autoConfigureControllerStr);
         }
     }
 
-    // TODO: move getProperty() to a common module
-    private static String getProperty(Class<?> classParam, final String propertyStr) {
-        String value = null;
-        Bundle bundle = FrameworkUtil.getBundle(classParam);
-
-        if (bundle != null) {
-            BundleContext bundleContext = bundle.getBundleContext();
-            if (bundleContext != null) {
-                value = bundleContext.getProperty(propertyStr);
-            }
-        }
-        if (value == null) {
-            value = System.getProperty(propertyStr);
-        }
-        return value;
-    }
-
     public static boolean shouldConfigureController (String databaseName, String tableName) {
         if (autoConfigureController && databaseName.equals(DATABASE_NAME) && tableName.equals("Bridge")) return true;
         return false;
index 2e54a5e0a0149fc42d1aa409576cc34c471b8b38..022af289fe715523961921d1d80d1b3aafb5ac4c 100644 (file)
 
 package org.opendaylight.ovsdb.plugin.api;
 
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
+
 import java.util.Map;
 
 import com.google.common.collect.Maps;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 
 public final class OvsVswitchdSchemaConstants {
     public static String DATABASE_NAME = "Open_vSwitch";
@@ -47,29 +46,13 @@ public final class OvsVswitchdSchemaConstants {
         addParentColumnToMutate("Manager", "Open_vSwitch", "manager_options");
         addParentColumnToMutate("Controller", "Bridge", "controller");
         // Keep the default value if the property is not set
-        final String autoConfigureControllerStr = getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
+        final String autoConfigureControllerStr =
+                ConfigProperties.getProperty(OvsVswitchdSchemaConstants.class, OVSDB_AUTOCONFIGURECONTROLLER);
         if (autoConfigureControllerStr != null) {
             autoConfigureController = Boolean.getBoolean(autoConfigureControllerStr);
         }
     }
 
-    // TODO: move getProperty() to a common module
-    private static String getProperty(Class<?> classParam, final String propertyStr) {
-        String value = null;
-        Bundle bundle = FrameworkUtil.getBundle(classParam);
-
-        if (bundle != null) {
-            BundleContext bundleContext = bundle.getBundleContext();
-            if (bundleContext != null) {
-                value = bundleContext.getProperty(propertyStr);
-            }
-        }
-        if (value == null) {
-            value = System.getProperty(propertyStr);
-        }
-        return value;
-    }
-
     public static void setAutoConfigureController(boolean autoConfigure) {
         autoConfigureController = autoConfigure;
     }
index e1b66403f7916a9dc46e31bd818ae63c70f4637e..fc34377160f132327fab3a7740dd309e3b4818e2 100644 (file)
@@ -66,8 +66,8 @@ import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.Manager;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
+import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
@@ -378,7 +378,7 @@ public class ConfigurationServiceImpl implements IPluginInBridgeDomainConfigServ
     private InetAddress getControllerIPAddress(Connection connection) {
         InetAddress controllerIP = null;
 
-        String addressString = getProperty(this.getClass(), "ovsdb.controller.address");
+        String addressString = ConfigProperties.getProperty(this.getClass(), "ovsdb.controller.address");
 
         if (addressString != null) {
             try {
@@ -391,7 +391,7 @@ public class ConfigurationServiceImpl implements IPluginInBridgeDomainConfigServ
             }
         }
 
-        addressString = getProperty(this.getClass(), "of.address");
+        addressString = ConfigProperties.getProperty(this.getClass(), "of.address");
 
         if (addressString != null) {
             try {
@@ -416,7 +416,7 @@ public class ConfigurationServiceImpl implements IPluginInBridgeDomainConfigServ
     private short getControllerOFPort() {
         Short defaultOpenFlowPort = 6633;
         Short openFlowPort = defaultOpenFlowPort;
-        String portString = getProperty(this.getClass(), "of.listenPort");
+        String portString = ConfigProperties.getProperty(this.getClass(), "of.listenPort");
         if (portString != null) {
             try {
                 openFlowPort = Short.decode(portString).shortValue();
@@ -428,23 +428,6 @@ public class ConfigurationServiceImpl implements IPluginInBridgeDomainConfigServ
         return openFlowPort;
     }
 
-    // TODO: move getProperty() to a common module
-    private static String getProperty(Class<?> classParam, final String propertyStr) {
-        String value = null;
-        Bundle bundle = FrameworkUtil.getBundle(classParam);
-
-        if (bundle != null) {
-            BundleContext bundleContext = bundle.getBundleContext();
-            if (bundleContext != null) {
-                value = bundleContext.getProperty(propertyStr);
-            }
-        }
-        if (value == null) {
-            value = System.getProperty(propertyStr);
-        }
-        return value;
-    }
-
     private UUID getCurrentControllerUuid(Node node, final String controllerTableName, final String target) {
         ConcurrentMap<String, Row> rows = this.getRows(node, controllerTableName);
 
diff --git a/pom.xml b/pom.xml
index 455060a01d24c1498cb1ccf62e649f7ead53c9c5..9e132a90574b6e08da3da6d84f77d9fc6e1f8287 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
@@ -29,6 +29,7 @@
     <module>plugin-shell</module>
     <module>plugin-mdsal-adapter</module>
     <module>northbound</module>
+    <module>utils/config</module>
     <module>utils/mdsal-openflow</module>
     <module>openstack/net-virt</module>
     <module>openstack/net-virt-providers</module>
diff --git a/utils/config/pom.xml b/utils/config/pom.xml
new file mode 100644 (file)
index 0000000..eb4514d
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>commons</artifactId>
+    <groupId>org.opendaylight.ovsdb</groupId>
+    <version>1.3.0-SNAPSHOT</version>
+    <relativePath>../../commons/parent/pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>utils.config</artifactId>
+  <name>OpenDaylight OVS common utility</name>
+  <version>1.1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.dependencymanager</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/utils/config/src/main/java/org/opendaylight/ovsdb/utils/config/ConfigProperties.java b/utils/config/src/main/java/org/opendaylight/ovsdb/utils/config/ConfigProperties.java
new file mode 100644 (file)
index 0000000..aa2d64f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Authors : Flavio Fernandes, Sam Hague, Srini Seetharaman
+ */
+
+package org.opendaylight.ovsdb.utils.config;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+
+public class ConfigProperties {
+
+    public static String getProperty(Class<?> classParam, final String propertyStr) {
+        return getProperty(classParam, propertyStr, null);
+    }
+
+    public static String getProperty(Class<?> classParam, final String propertyStr, final String defaultValue) {
+        String value = null;
+        Bundle bundle = FrameworkUtil.getBundle(classParam);
+
+        if (bundle != null) {
+            BundleContext bundleContext = bundle.getBundleContext();
+            if (bundleContext != null) {
+                value = bundleContext.getProperty(propertyStr);
+            }
+        }
+        if (value == null) {
+            value = System.getProperty(propertyStr, defaultValue);
+        }
+        return value;
+    }
+}