You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/26 22:19:09 UTC

[28/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-134: Gitignore improvements and second batch of Javadoc fixes done by Philipp Ottlinger.

TAMAYA-134: Gitignore improvements and second batch of
Javadoc fixes done by Philipp Ottlinger.


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/8e827054
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/8e827054
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/8e827054

Branch: refs/heads/master
Commit: 8e827054c9e2082ab7010b5f9a7b427890ad787d
Parents: 0760678
Author: anatole <an...@apache.org>
Authored: Tue Jan 19 01:11:27 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Tue Sep 27 00:18:31 2016 +0200

----------------------------------------------------------------------
 .../tamaya/events/ConfigEventManager.java       | 17 ++++-
 .../events/ConfigurationContextChange.java      |  4 +-
 .../ConfigurationContextChangeBuilder.java      | 19 ++---
 .../events/PropertySourceChangeBuilder.java     |  4 +-
 .../ObservingPropertySourceProvider.java        | 77 ++++++++++++--------
 .../events/spi/ConfigEventManagerSpi.java       | 19 +++--
 6 files changed, 87 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8e827054/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
index 6b206c8..9989fbb 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -55,6 +55,7 @@ public final class ConfigEventManager {
 
     /**
      * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
+     * @param <T> the type of the event.
      * @param l the listener not null.
      * @param eventType the event type to which this listener listens to.
      */
@@ -82,7 +83,8 @@ public final class ConfigEventManager {
     /**
      * Removes a listener registered for the given event type.
      *
-     * @param l the listener not null.
+     * @param <T> the type of the event.
+     * @param l the listener, not null.
      * @param eventType the event type to which this listener listens to.
      */
     public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
@@ -106,6 +108,8 @@ public final class ConfigEventManager {
 
     /**
      * Access all registered ConfigEventListeners listening to a all kind of event types globally.
+     * 
+     * @param <T> the type of the event.
      * @return a list with the listeners found, never null.
      */
     public static <T extends ConfigEvent>
@@ -115,7 +119,8 @@ public final class ConfigEventManager {
 
     /**
      * Publishes a {@link ConfigurationChange} synchronously to all interested listeners.
-     *
+     * 
+     * @param <T> the type of the event.
      * @param event the event, not null.
      */
     public static <T> void fireEvent(ConfigEvent<?> event) {
@@ -125,6 +130,7 @@ public final class ConfigEventManager {
     /**
      * Publishes a {@link ConfigurationChange} asynchronously/multithreaded to all interested listeners.
      *
+     * @param <T> the type of the event.
      * @param event the event, not null.
      */
     public static <T> void fireEventAsynch(ConfigEvent<?> event) {
@@ -133,10 +139,13 @@ public final class ConfigEventManager {
 
     /**
      * Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
-     * and triggers ConfigurationChange events is something changed. This is quite handy for publishing
+     * and trigger ConfigurationChange events if something changed. This is quite handy for publishing
      * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
-     * can be on this machine, or also remotedly. FOr handling corresponding {@link ConfigEventListener} have
+     * can be on this machine, or also remotely. For handling corresponding {@link ConfigEventListener} have
      * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
+     * 
+     * @param enable whether to enable or disable the change monitoring.
+     * 
      * @see #isChangeMonitoring()
      * @see #getChangeMonitoringPeriod()
      */

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8e827054/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
index 8c9ceef..4e12d42 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
@@ -29,7 +29,7 @@ import java.util.List;
 import java.util.UUID;
 
 /**
- * Event that contains a set current changes that were applied or could be applied.
+ * Event that contains a set of current changes that were applied or can be applied.
  * This class is immutable and thread-safe. To create instances use
  * {@link PropertySourceChangeBuilder}.
  *
@@ -49,6 +49,8 @@ public final class ConfigurationContextChange implements ConfigEvent<Configurati
 
     /**
      * Get an empty change set for the given provider.
+     * 
+     * @param configurationContext context to use for creating changesets.
      * @return an empty ConfigurationContextChange instance.
      */
     public static ConfigurationContextChange emptyChangeSet(ConfigurationContext configurationContext){

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8e827054/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
index a48107a..b586428 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
@@ -27,13 +27,13 @@ import java.util.List;
 import java.util.Objects;
 
 /**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
+ * Models a set of current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
+ * can observe changes to property sources and
  * <ol>
- *     <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- *     contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- *     change, its only the data of the property source).</li>
- *     <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
+ *     <li>check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
+ *     contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference to a property source is never affected by a
+ *     change, it is the data of the property source only).</li>
+ *     <li>if so, a corresponding action may be taken, such as reevaluating the configuration values (depending on
  *     the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
  *     event on configuration level.
  * </ol>
@@ -72,13 +72,14 @@ public final class ConfigurationContextChangeBuilder {
     /**
      * Creates a new instance current this builder.
      *
+     * @param context context to use for creating changesets.
      * @return the builder for chaining.
      */
     public static ConfigurationContextChangeBuilder of(ConfigurationContext context) {
         return new ConfigurationContextChangeBuilder(context);
     }
 
-    /*
+    /**
      * Apply a version/UUID to the set being built.
      * @param version the version to apply, or null, to let the system generate a version for you.
      * @return the builder for chaining.
@@ -88,9 +89,9 @@ public final class ConfigurationContextChangeBuilder {
         return this;
     }
 
-    /*
+    /**
      * Apply given timestamp to the set being built.
-     * @param version the version to apply, or null, to let the system generate a version for you.
+     * @param timestamp timestamp to set.
      * @return the builder for chaining.
      */
     public ConfigurationContextChangeBuilder setTimestamp(long timestamp) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8e827054/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
index 009cb11..cefa4f4 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -66,6 +66,7 @@ public final class PropertySourceChangeBuilder {
      * Constructor.
      *
      * @param source the underlying configuration/provider, not null.
+     * @param changeType kind of change.
      */
     private PropertySourceChangeBuilder(PropertySource source, ChangeType changeType) {
         this.source = Objects.requireNonNull(source);
@@ -73,9 +74,10 @@ public final class PropertySourceChangeBuilder {
     }
 
     /**
-     * Creates a new instance current this builder.
+     * Creates a new instance of this builder.
      *
      * @param source the underlying property provider/configuration, not null.
+     * @param changeType kind of change.
      * @return the builder for chaining.
      */
     public static PropertySourceChangeBuilder of(PropertySource source, ChangeType changeType) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8e827054/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
index 6082dd0..347576f 100644
--- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
@@ -18,14 +18,6 @@
  */
 package org.apache.tamaya.events.folderobserver;
 
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
@@ -33,18 +25,34 @@ import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+import org.apache.tamaya.events.ConfigEventManager;
+import org.apache.tamaya.events.ConfigurationContextChange;
+import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+
 /**
- * This implementation run in a folder taking up all file compatible with the given
+ * This implementation runs in a folder taking up all files compatible with the given
  * ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider
  * will adapt the changes automatically and trigger according
  * {@link org.apache.tamaya.events.PropertySourceChange} events.
- * The default folder is META-INF/config, but you can change using the absolute path in
+ * The default folder is META-INF/config, but you can change it via an absolute path in the
  * "-Dtamaya.configdir" parameter.
  */
 public class ObservingPropertySourceProvider implements PropertySourceProvider, FileChangeObserver {
@@ -74,7 +82,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
             synchronized (this.propertySources) {
                 this.propertySources.addAll(readConfiguration(directory));
             }
-            Runnable runnable = new FileChangeListener(directory, this);
+            final Runnable runnable = new FileChangeListener(directory, this);
             executor.execute(runnable);
         } else {
             executor.shutdown();
@@ -87,20 +95,26 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
      * @param directory the target directory, not null.
      */
     private List<PropertySource> readConfiguration(Path directory) {
-        List<PropertySource> result = new ArrayList<>();
+        final List<PropertySource> result = new ArrayList<>();
         try {
             synchronized (propertySources) {
-                for (Path path : Files.newDirectoryStream(directory, "*")) {
+                for (final Path path : Files.newDirectoryStream(directory, "*")) {
                     result.addAll(getPropertySources(path));
                 }
                 return result;
             }
-        } catch (IOException e) {
+        } catch (final IOException e) {
             LOG.log(Level.WARNING, "Failed to read configuration from dir: " + directory, e);
         }
         return result;
     }
 
+    /**
+     * Read property sources from the given file.
+     * 
+     * @param file source of the property sources.
+     * @return property sources from the given file.
+     */
     protected Collection<PropertySource> getPropertySources(final Path file) {
         return Arrays.asList(new PropertySource[]{new BasePropertySource() {
             private final Map<String,String> props = readProperties(file);
@@ -115,17 +129,18 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
      * Load a single file.
      *
      * @param file the file, not null.
+     * @return properties as read from the given file.
      */
     protected static Map<String,String> readProperties(Path file) {
         try (InputStream is = file.toUri().toURL().openStream()){
-            Properties props = new Properties();
+            final Properties props = new Properties();
                 props.load(is);
-            Map<String,String> result = new HashMap<>();
-            for(Map.Entry en:props.entrySet()){
-                result.put(en.getKey().toString(), en.getValue().toString());
+            final Map<String,String> result = new HashMap<>();
+            for(final Map.Entry<Object,Object> en:props.entrySet()){
+                result.put(String.valueOf(en.getKey()), String.valueOf(en.getValue()));
             }
             return result;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.log(Level.INFO, "Error reading file: " + file.toString() +
                     ", using format: properties", e);
         }
@@ -139,18 +154,18 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
      * @return the directory to be read, or null.
      */
     private Path getDirectory() {
-        String absolutePath = System.getProperty("tamaya.configdir");
+        final String absolutePath = System.getProperty("tamaya.configdir");
         if (null!=absolutePath) {
-            Path path = Paths.get(absolutePath);
+            final Path path = Paths.get(absolutePath);
             if (Files.isDirectory(path)) {
                 return path;
             }
         }
-        URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
+        final URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
         if (null!=resource) {
             try {
                 return Paths.get(resource.toURI());
-            } catch (URISyntaxException e) {
+            } catch (final URISyntaxException e) {
                 throw new ConfigException("An error to find the directory to watch", e);
             }
         }
@@ -161,9 +176,9 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
     @Override
     public void directoryChanged(Path directory) {
         synchronized (this.propertySources) {
-            List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
+            final List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
             propertySources.clear();
-            Collection<PropertySource> sourcesRead = readConfiguration(directory);
+            final Collection<PropertySource> sourcesRead = readConfiguration(directory);
             this.propertySources.addAll(sourcesRead);
             triggerConfigChange(existingPropertySources, propertySources);
         }
@@ -172,14 +187,14 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
 
     private void triggerConfigChange(List<PropertySource> originalPropertySources,
                                      List<PropertySource> newPropertySources) {
-        ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
-        for (PropertySource ps : originalPropertySources) {
+        final ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
+        for (final PropertySource ps : originalPropertySources) {
             b.removedPropertySource(ps);
         }
-        for (PropertySource ps : newPropertySources) {
+        for (final PropertySource ps : newPropertySources) {
             b.newPropertySource(ps);
         }
-        ConfigurationContextChange changeEvent = b.build();
+        final ConfigurationContextChange changeEvent = b.build();
         LOG.fine("Trigger Config Context Change: " + changeEvent);
         ConfigEventManager.fireEvent(changeEvent);
     }
@@ -190,4 +205,4 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
             return new ArrayList<>(this.propertySources);
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8e827054/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
index 93c813d..66a8f73 100644
--- a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
+++ b/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
@@ -27,13 +27,14 @@ import java.util.Collection;
  * SPI interface to implement the {@link org.apache.tamaya.events.ConfigEventManager} singleton.
  * Implementations of this interface must be registered with the current {@link org.apache.tamaya.spi.ServiceContext},
  * by default this equals to registering it with {@link java.util.ServiceLoader}. Add {@link javax.annotation.Priority}
- * annotations for overriding (higher values overriden lower values).
+ * annotations for overriding (higher values override lower values).
  */
 public interface ConfigEventManagerSpi {
     /**
-     * Add a listener for observing events. References of this
+     * Adds a listener for observing events. References of this
      * component to the listeners must be managed as weak references.
-     *
+     * 
+     * @param <T> the type of the events listened to.
      * @param l the listener not null.
      */
     <T> void addListener(ConfigEventListener l);
@@ -41,9 +42,10 @@ public interface ConfigEventManagerSpi {
     /**
      * Adds a listener for observing events of a given type.
      *
+     * @param <T> the type of the events listened to.
      * @param l the listener not null.
      * @param eventType the type of concrete configuration event this listeners should be informed about. All other
-     *                  event types will never be delivered toe this listener instance.
+     *                  event types will never be delivered to this listener instance.
      */
     <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType);
 
@@ -57,6 +59,7 @@ public interface ConfigEventManagerSpi {
     /**
      * Removes a listener for observing events of a certain type.
      *
+     * @param <T> the type of the events listened to.
      * @param l the listener not null.
      * @param eventType the type of concrete configuration event this listeners should be informed about. All other
      *                  event types will never be delivered toe this listener instance.
@@ -111,11 +114,13 @@ public interface ConfigEventManagerSpi {
     boolean isChangeMonitorActive();
 
     /**
-     * Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
-     * and triggers ConfigurationChange events is something changed. This is quite handy for publishing
+     * Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly
+     * and trigger ConfigurationChange events if something is changed. This is quite handy for publishing
      * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
-     * can be on this machine, or also remotedly. FOr handling corresponding {@link ConfigEventListener} have
+     * can be on this machine, or also remotedly. For handling corresponding {@link ConfigEventListener} have
      * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
+     * 
+     * @param enable whether to enable or disable the change monitoring.
      */
     void enableChangeMonitor(boolean enable);