[ARIES-1519] Small refactoring. Closes #2

Project: http://git-wip-us.apache.org/repos/asf/aries-rsa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-rsa/commit/fb2165ae
Tree: http://git-wip-us.apache.org/repos/asf/aries-rsa/tree/fb2165ae
Diff: http://git-wip-us.apache.org/repos/asf/aries-rsa/diff/fb2165ae

Branch: refs/heads/master
Commit: fb2165ae4f41f17046a44a69aac9cab6d95da2ee
Parents: c848ffb
Author: Christian Schneider <[email protected]>
Authored: Wed Apr 6 18:06:31 2016 +0200
Committer: Christian Schneider <[email protected]>
Committed: Wed Apr 6 18:06:31 2016 +0200

----------------------------------------------------------------------
 .../rsa/core/DistributionProviderTracker.java     | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/fb2165ae/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
----------------------------------------------------------------------
diff --git 
a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java 
b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
index ea45c65..79b1b51 100644
--- 
a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
+++ 
b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
@@ -18,6 +18,9 @@
  */
 package org.apache.aries.rsa.core;
 
+import static 
org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED;
+import static 
org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED;
+
 import java.util.Dictionary;
 import java.util.Hashtable;
 
@@ -28,7 +31,6 @@ import org.osgi.framework.BundleException;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
@@ -52,17 +54,17 @@ public class DistributionProviderTracker extends 
ServiceTracker<DistributionProv
                                                                     provider);
         RemoteServiceadminFactory rsaf = new 
RemoteServiceadminFactory(rsaCore);
         Dictionary<String, Object> props = new Hashtable<String, Object>();
-        Object value = 
reference.getProperty(RemoteConstants.REMOTE_INTENTS_SUPPORTED);
-        value = value == null ? "" : value;
-        props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, value);
-
-        value = 
reference.getProperty(RemoteConstants.REMOTE_CONFIGS_SUPPORTED);
-        value = value == null ? "" : value;
-        props.put(RemoteConstants.REMOTE_CONFIGS_SUPPORTED, value);
+        props.put(REMOTE_INTENTS_SUPPORTED, getPropertyNullSafe(reference, 
REMOTE_INTENTS_SUPPORTED));
+        props.put(REMOTE_CONFIGS_SUPPORTED, getPropertyNullSafe(reference, 
REMOTE_CONFIGS_SUPPORTED));
         LOG.info("Registering RemoteServiceAdmin for provider " + 
provider.getClass().getName());
         return context.registerService(RemoteServiceAdmin.class.getName(), 
rsaf, props);
     }
 
+    private Object getPropertyNullSafe(ServiceReference<DistributionProvider> 
reference, String key) {
+        Object value = reference.getProperty(key);
+        return value == null ? "" : value;
+    }
+
     protected BundleContext getAPIContext() {
         Bundle apiBundle = FrameworkUtil.getBundle(DistributionProvider.class);
         try {

Reply via email to