You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/01/16 22:20:25 UTC
incubator-tamaya git commit: Fixed several quality issues.
Repository: incubator-tamaya
Updated Branches:
refs/heads/master 77ec9ec12 -> bdb291870
Fixed several quality issues.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/bdb29187
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/bdb29187
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/bdb29187
Branch: refs/heads/master
Commit: bdb291870a0b8dbbd4248c44506f9b056925225f
Parents: 77ec9ec
Author: anatole <an...@apache.org>
Authored: Sat Jan 16 22:18:35 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Jan 16 22:18:35 2016 +0100
----------------------------------------------------------------------
.../mutableconfig/ConfigChangeManager.java | 4 +-
.../mutableconfig/ConfigChangeRequest.java | 36 +++++++++------
.../MutablePropertiesConfigSupport.java | 2 +-
.../PropertiesFileConfigChangeRequest.java | 9 +++-
.../XmlPropertiesFileConfigChangeRequest.java | 11 +++--
.../spi/AbstractConfigChangeRequest.java | 47 +++++++++++---------
.../spi/ConfigChangeManagerSpi.java | 2 +
.../mutableconfig/ConfigChangeManagerTest.java | 17 ++++++-
.../PropertiesFileConfigChangeRequestTest.java | 17 ++++++-
9 files changed, 101 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeManager.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeManager.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeManager.java
index 6c18b87..18502aa 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeManager.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeManager.java
@@ -26,7 +26,7 @@ import java.net.URI;
import java.util.Objects;
/**
- * Accessor for creating {@link ConfigChangeRequest} instances to change and commite configuration.
+ * Accessor for creating {@link ConfigChangeRequest} instances to change and commit configuration.
*/
public final class ConfigChangeManager {
@@ -35,6 +35,8 @@ public final class ConfigChangeManager {
/**
* Creates a new change request for the given configurationSource
+ *
+ * @param configurationSource the configuration source
* @return a new ChangeRequest
* @throws org.apache.tamaya.ConfigException if the given configurationSource cannot be edited.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeRequest.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeRequest.java
index 9bbb2c0..97bc614 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeRequest.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeRequest.java
@@ -35,14 +35,16 @@ import java.util.Map;
public interface ConfigChangeRequest {
/**
- * Get the unique id of this change reqeust (UUID).
- * @return the unique id of this change reqeust (UUID).
+ * Get the unique id of this change request (UUID).
+ *
+ * @return the unique id of this change request (UUID).
*/
String getRequestID();
/**
* Identifies the configuration backend that was used to create this request instance and which is
* also responsible for writing back the changes on this instance.
+ *
* @return the backend URI, never null.
*/
URI getBackendURI();
@@ -50,8 +52,9 @@ public interface ConfigChangeRequest {
/**
* Checks if a configuration key is writable (or it can be added).
*
- * @param keyExpression the key to be cheched for write access (including creation), not null. Here this could also
- * be a regulat expression, such "as a.b.c.*".
+ * @param keyExpression the key to be checked for write access (including creation), not null. Here this could also
+ * be a regular expression, such "as a.b.c.*".
+ * @return the boolean
*/
boolean isWritable(String keyExpression);
@@ -59,17 +62,20 @@ public interface ConfigChangeRequest {
* Checks if a configuration key is removable. This also implies that it is writable, but there might be writable
* keys that cannot be removed.
*
- * @param keyExpression the keyExpression the key to be cheched for write access (including creation), not null. Here this could also
+ * @param keyExpression the keyExpression the key to be cheched for write access (including creation), not null.
+ * Here this could also
* be a regulat expression, such "as a.b.c.*".
+ * @return the boolean
*/
boolean isRemovable(String keyExpression);
/**
* Checks if any keys of the given type already exist in the backend. <b>NOTE:</b> there may be backends that
- * are not able to supportlookups with regular expressions. In most such cases you should pass the keys to
+ * are not able to support lookups with regular expressions. In most such cases you should pass the keys to
* lookup explicitly.
- * @param keyExpression the key to be cheched for write access (including creation), not null. Here this could
- * also be a regulat expression, such "as a.b.c.*".
+ *
+ * @param keyExpression the key to be checked for write access (including creation), not null. Here this could
+ * also be a regular expression, such "as a.b.c.*".
* @return true, if there is any key found matching the expression.
*/
boolean exists(String keyExpression);
@@ -77,7 +83,7 @@ public interface ConfigChangeRequest {
/**
* Sets a property.
*
- * @param key the property's key, not null.
+ * @param key the property's key, not null.
* @param value the property's value, not null.
* @return the former property value, or null.
* @throws org.apache.tamaya.ConfigException if the key/value cannot be added, or the request is read-only.
@@ -93,6 +99,7 @@ public interface ConfigChangeRequest {
* remove all entries as far as possible and abort the writing operation.
*
* @param properties the properties tobe written, not null.
+ * @return the config change request
* @throws org.apache.tamaya.ConfigException if any of the given properties could not be written, or the request is read-only.
*/
ConfigChangeRequest putAll(Map<String, String> properties);
@@ -101,8 +108,8 @@ public interface ConfigChangeRequest {
* Removes a configuration entry.
*
* @param keys the property's keys, not null.
- * @throws org.apache.tamaya.ConfigException if the given cannot be removed.
* @return the property's keys, or the request is read-only.
+ * @throws org.apache.tamaya.ConfigException if the given cannot be removed.
*/
ConfigChangeRequest remove(String... keys);
@@ -115,6 +122,7 @@ public interface ConfigChangeRequest {
* remove all entries as far as possible and abort the writing operation.
*
* @param keys the property's keys to be removed, not null.
+ * @return the config change request
* @throws org.apache.tamaya.ConfigException if any of the given keys could not be removed, or the request is read-only.
*/
ConfigChangeRequest remove(Collection<String> keys);
@@ -128,6 +136,7 @@ public interface ConfigChangeRequest {
* remove all entries as far as possible and abort the writing operation.
*
* @param keys the property's keys to be removed, not null.
+ * @return the config change request
* @throws org.apache.tamaya.ConfigException if any of the given keys could not be removed, or the request is read-only.
*/
ConfigChangeRequest removeAll(String... keys);
@@ -135,21 +144,22 @@ public interface ConfigChangeRequest {
/**
* Commits the request. After a commit the change is not editable anymore. All changes applied will be written to
* the corresponding configuration backend.
- " @throws ConfigException if the request already has been committed or cancelled, or the commit fails.
+ * " @throws ConfigException if the request already has been committed or cancelled, or the commit fails.
*/
void commit();
/**
* Cancel the given request, leaving everything unchanged. Cancelled requests are read-only and can not be used
* for preparing/submitting any configuration changes.
- * @return true, if this instance is closed.
+ *
* @throws org.apache.tamaya.ConfigException if the request already has been committed or cancelled.
*/
- public void cancel();
+ void cancel();
/**
* Operation to check, if the current request is closed (either commited or cancelled). Closed requests are
* read-only and can not be used for preparing/submitting any configuration changes.
+ *
* @return true, if this instance is closed.
*/
boolean isClosed();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/MutablePropertiesConfigSupport.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/MutablePropertiesConfigSupport.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/MutablePropertiesConfigSupport.java
index 04e2858..56effe6 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/MutablePropertiesConfigSupport.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/MutablePropertiesConfigSupport.java
@@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Mutable Config Requestfactory that tries to convert given URIs to file references, if successful, it returns
+ * Mutable Config Request factory that tries to convert given URIs to file references, if successful, it returns
* ConfigChangeRequests fir .properties and .xml files.
*/
public class MutablePropertiesConfigSupport implements ConfigChangeManagerSpi{
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequest.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequest.java
index e393461..13cfc30 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequest.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequest.java
@@ -34,10 +34,15 @@ class PropertiesFileConfigChangeRequest extends AbstractConfigChangeRequest{
private static final Logger LOG = Logger.getLogger(PropertiesFileConfigChangeRequest.class.getName());
- private File file;
+ private final File file;
- private Properties properties = new Properties();
+ private final Properties properties = new Properties();
+ /**
+ * Instantiates a new Properties file config change request.
+ *
+ * @param file the file
+ */
PropertiesFileConfigChangeRequest(File file){
super(file.toURI());
this.file = file;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/XmlPropertiesFileConfigChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/XmlPropertiesFileConfigChangeRequest.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/XmlPropertiesFileConfigChangeRequest.java
index 6ec2363..6e402ca 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/XmlPropertiesFileConfigChangeRequest.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/XmlPropertiesFileConfigChangeRequest.java
@@ -28,16 +28,21 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * Change Request implementation based on .xml properties fiel.
+ * Change Request implementation based on .xml properties file.
*/
class XmlPropertiesFileConfigChangeRequest extends AbstractConfigChangeRequest{
private static final Logger LOG = Logger.getLogger(XmlPropertiesFileConfigChangeRequest.class.getName());
- private File file;
+ private final File file;
- private Properties properties = new Properties();
+ private final Properties properties = new Properties();
+ /**
+ * Instantiates a new Xml properties file config change request.
+ *
+ * @param file the file
+ */
XmlPropertiesFileConfigChangeRequest(File file){
super(file.toURI());
this.file = file;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/AbstractConfigChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/AbstractConfigChangeRequest.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/AbstractConfigChangeRequest.java
index 0fdd43d..5b50050 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/AbstractConfigChangeRequest.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/AbstractConfigChangeRequest.java
@@ -30,18 +30,29 @@ import java.util.*;
public abstract class AbstractConfigChangeRequest implements ConfigChangeRequest {
private final URI uri;
- private String requestID = UUID.randomUUID().toString();
- protected Map<String,String> properties = new HashMap<>();
- protected Set<String> removed = new HashSet<>();
+ private final String requestID = UUID.randomUUID().toString();
+ /**
+ * The Properties.
+ */
+ protected final Map<String,String> properties = new HashMap<>();
+ /**
+ * The Removed.
+ */
+ protected final Set<String> removed = new HashSet<>();
private boolean closed = false;
+ /**
+ * Instantiates a new Abstract config change request.
+ *
+ * @param uri the uri
+ */
protected AbstractConfigChangeRequest(URI uri){
this.uri = Objects.requireNonNull(uri);
}
/**
- * Get the unique id of this change reqeust (UUID).
- * @return the unique id of this change reqeust (UUID).
+ * Get the unique id of this change request (UUID).
+ * @return the unique id of this change request (UUID).
*/
@Override
public String getRequestID(){
@@ -63,14 +74,6 @@ public abstract class AbstractConfigChangeRequest implements ConfigChangeRequest
return true;
}
- protected Map<String,String> getProperties(){
- return properties;
- }
-
- protected Set<String> getRemoved(){
- return removed;
- }
-
@Override
public abstract boolean exists(String keyExpression);
@@ -91,27 +94,21 @@ public abstract class AbstractConfigChangeRequest implements ConfigChangeRequest
@Override
public ConfigChangeRequest remove(String... keys) {
checkClosed();
- for(String k:keys) {
- this.removed.add(k);
- }
+ Collections.addAll(this.removed, keys);
return this;
}
@Override
public ConfigChangeRequest remove(Collection<String> keys) {
checkClosed();
- for(String k:keys) {
- this.removed.add(k);
- }
+ this.removed.addAll(keys);
return this;
}
@Override
public ConfigChangeRequest removeAll(String... keys) {
checkClosed();
- for(String k:keys) {
- this.removed.add(k);
- }
+ Collections.addAll(this.removed, keys);
return this;
}
@@ -122,6 +119,9 @@ public abstract class AbstractConfigChangeRequest implements ConfigChangeRequest
closed = true;
}
+ /**
+ * Commit internal.
+ */
protected abstract void commitInternal();
@Override
@@ -135,6 +135,9 @@ public abstract class AbstractConfigChangeRequest implements ConfigChangeRequest
return closed;
}
+ /**
+ * Check closed.
+ */
protected void checkClosed(){
if(closed){
throw new ConfigException("Change request already closed.");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeManagerSpi.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeManagerSpi.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeManagerSpi.java
index 94e4a44..fa78708 100644
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeManagerSpi.java
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeManagerSpi.java
@@ -30,6 +30,8 @@ public interface ConfigChangeManagerSpi {
/**
* Creates a new change request for the given Configuration.
+ *
+ * @param backendURI the backend uri
* @return a new ChangeRequest, or null if the given backend URI cannot be edited.
*/
ConfigChangeRequest createChangeRequest(URI backendURI);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/ConfigChangeManagerTest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/ConfigChangeManagerTest.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/ConfigChangeManagerTest.java
index 5638e19..2e47383 100644
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/ConfigChangeManagerTest.java
+++ b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/ConfigChangeManagerTest.java
@@ -27,10 +27,15 @@ import java.net.URI;
import static org.junit.Assert.*;
/**
- * Created by atsticks on 16.01.16.
+ * Tests for {@link ConfigChangeManager}.
*/
public class ConfigChangeManagerTest {
+ /**
+ * Test create change request.
+ *
+ * @throws Exception the exception
+ */
@Test
public void testCreateChangeRequest() throws Exception {
File f = File.createTempFile("ConfigChangeRequest",".properties");
@@ -41,11 +46,21 @@ public class ConfigChangeManagerTest {
assertNotNull(req);
}
+ /**
+ * Test invalid create change request.
+ *
+ * @throws Exception the exception
+ */
@Test(expected=ConfigException.class)
public void testInvalidCreateChangeRequest() throws Exception {
ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(new URI("foo:bar"));
}
+ /**
+ * Test null create change request.
+ *
+ * @throws Exception the exception
+ */
@Test(expected=NullPointerException.class)
public void testNullCreateChangeRequest() throws Exception {
ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(null);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bdb29187/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequestTest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequestTest.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequestTest.java
index 44d0860..6829ba1 100644
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequestTest.java
+++ b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequestTest.java
@@ -31,9 +31,14 @@ import java.util.Properties;
import static org.junit.Assert.*;
/**
- * Created by atsticks on 16.01.16.
+ * Tests for {@link PropertiesFileConfigChangeRequest}.
*/
public class PropertiesFileConfigChangeRequestTest {
+ /**
+ * Test read write properties with cancel.
+ *
+ * @throws IOException the io exception
+ */
@Test
public void testReadWriteProperties_WithCancel() throws IOException {
File f = File.createTempFile("testReadWriteProperties_WithCancel",".properties");
@@ -49,6 +54,11 @@ public class PropertiesFileConfigChangeRequestTest {
assertFalse(f.exists());
}
+ /**
+ * Test read write properties with commit.
+ *
+ * @throws IOException the io exception
+ */
@Test
public void testReadWriteProperties_WithCommit() throws IOException {
File f = File.createTempFile("testReadWriteProperties_WithCommit",".properties");
@@ -78,6 +88,11 @@ public class PropertiesFileConfigChangeRequestTest {
assertEquals("value4", props.getProperty("key4"));
}
+ /**
+ * Test read write xml properties with commit.
+ *
+ * @throws IOException the io exception
+ */
@Test
public void testReadWriteXmlProperties_WithCommit() throws IOException {
File f = File.createTempFile("testReadWriteProperties_WithCommit",".xml");