TAMAYA-316: Overhaul package classes

Fix typos and minor warnings/refactorings.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/6d91a934
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/6d91a934
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/6d91a934

Branch: refs/heads/master
Commit: 6d91a934a1fa8103f1e77d73ca43ca6b1d4e413a
Parents: b741d46
Author: Phil Ottlinger <[email protected]>
Authored: Tue Oct 31 10:07:49 2017 +0100
Committer: Phil Ottlinger <[email protected]>
Committed: Tue Oct 31 10:07:49 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/tamaya/osgi/Activator.java  | 10 +---------
 .../main/java/org/apache/tamaya/osgi/ConfigHistory.java  | 11 ++++++-----
 .../java/org/apache/tamaya/osgi/TamayaConfigPlugin.java  |  8 +++++---
 3 files changed, 12 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6d91a934/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
----------------------------------------------------------------------
diff --git 
a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java 
b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
index aef323d..b0e7d43 100644
--- a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
+++ b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java
@@ -20,10 +20,7 @@ package org.apache.tamaya.osgi;
 
 import org.apache.tamaya.osgi.commands.TamayaConfigService;
 import org.osgi.framework.*;
-import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ConfigurationPlugin;
-import org.osgi.service.component.annotations.Reference;
 
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -31,7 +28,7 @@ import java.util.logging.Logger;
 
 /**
  * Activator that registers the Tamaya based Service Class for {@link 
ConfigurationAdmin},
- * using a default service priority of {@code 0}. This behaviour is 
configurable based on OSGI properties:
+ * using a default service priority of {@code 0}. This behavior is 
configurable based on OSGI properties:
  * <ul>
  *     <li><p><b>org.tamaya.integration.osgi.cm.ranking, type: int</b> allows 
to configure the OSGI service ranking for
  *     Tamaya based ConfigurationAdmin instance. The default ranking used is 
10.</p></li>
@@ -49,12 +46,8 @@ public class Activator implements BundleActivator {
 
     private TamayaConfigPlugin plugin;
 
-
     @Override
     public void start(BundleContext context) throws Exception {
-        ServiceReference<ConfigurationAdmin> cmRef = 
context.getServiceReference(ConfigurationAdmin.class);
-        ConfigurationAdmin cm = context.getService(cmRef);
-        Configuration configuration = 
cm.getConfiguration(TamayaConfigPlugin.COMPONENTID, null);
         this.plugin = new TamayaConfigPlugin(context);
         Dictionary<String, Object> props = new Hashtable<>();
         props.put(Constants.SERVICE_RANKING, DEFAULT_RANKING);
@@ -70,5 +63,4 @@ public class Activator implements BundleActivator {
             registration.unregister();
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6d91a934/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
----------------------------------------------------------------------
diff --git 
a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java 
b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
index dc41787..e988a42 100644
--- 
a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
+++ 
b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/ConfigHistory.java
@@ -24,7 +24,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
- * Class storing the history of changers done to the OSGI configuration by 
Tamaya.
+ * Class storing the history of changes applied to the OSGI configuration by 
Tamaya.
  * This class can be used in the future to restore the previous state, if 
needed.
  */
 public final class ConfigHistory implements Serializable{
@@ -226,8 +226,8 @@ public final class ConfigHistory implements Serializable{
 
 
     /**
-     * This methd saves the (serialized) history in the plugin's OSGI 
configuration using
-     * the HISTORY_KEY key.
+     * This method saves the (serialized) history in the plugin's OSGI 
configuration using
+     * the key {@link #HISTORY_KEY}.
      * @param osgiConfig the plugin config, not null.
      */
     static void save(Dictionary<String,Object> osgiConfig){
@@ -246,7 +246,8 @@ public final class ConfigHistory implements Serializable{
      * Restores the history from the plugin's OSGI configuration.
      * @param osgiConfig
      */
-    static void restore(Dictionary<String,Object> osgiConfig){
+    @SuppressWarnings("unchecked")
+       static void restore(Dictionary<String,Object> osgiConfig){
         try{
             String serialized = (String)osgiConfig.get(HISTORY_KEY);
             if(serialized!=null) {
@@ -256,7 +257,7 @@ public final class ConfigHistory implements Serializable{
                 ois.close();
             }
         } catch (Exception e) {
-            LOG.log(Level.WARNING, "Failed to store getConfig change 
history.", e);
+            LOG.log(Level.WARNING, "Failed to restore getConfig change 
history.", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6d91a934/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
----------------------------------------------------------------------
diff --git 
a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
 
b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
index e095b14..6c9c685 100644
--- 
a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
+++ 
b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/TamayaConfigPlugin.java
@@ -212,6 +212,7 @@ public class TamayaConfigPlugin implements 
TamayaConfigService,BundleListener, S
         return true;
     }
 
+    // REVIEW is this method still needed at all?
     private boolean isAutoUpdateEnabled(Bundle bundle, 
Dictionary<String,Object> props) {
         Object enabledVal = props.get(TAMAYA_AUTO_UPDATE_ENABLED_PROP);
         if(enabledVal!=null){
@@ -250,9 +251,9 @@ public class TamayaConfigPlugin implements 
TamayaConfigService,BundleListener, S
             this.enabledByDefault = 
Boolean.parseBoolean(enabledVal.toString());
         }
         if(this.enabledByDefault) {
-            LOG.info("Tamaya Config is enabledByDefault by default. Add 
Tamaya-Enabled to your bundle manifests to enable it.");
+            LOG.info("Tamaya Config is enabled by default. Add Tamaya-Enabled 
to your bundle manifests to enable it.");
         }else{
-            LOG.info("Tamaya Config is enabled by default. Add Tamaya-Disabled 
to your bundle manifests to disable it.");
+            LOG.info("Tamaya Config is not enabled by default. Add 
Tamaya-Disabled to your bundle manifests to disable it.");
         }
     }
 
@@ -343,7 +344,8 @@ public class TamayaConfigPlugin implements 
TamayaConfigService,BundleListener, S
 
     @Override
     public boolean restoreBackup(String pid){
-        Dictionary<String,Object> config = (Dictionary<String,Object>) 
Backups.get(pid);
+        @SuppressWarnings("unchecked")
+               Dictionary<String,Object> config = (Dictionary<String,Object>) 
Backups.get(pid);
         if(config==null){
             return false;
         }

Reply via email to