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 07:40:17 UTC
[2/3] incubator-tamaya git commit: TAMAYA-135: Added mutability for
configuration sources or mechanisms.
TAMAYA-135: Added mutability for configuration sources or mechanisms.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c2f1b151
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c2f1b151
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c2f1b151
Branch: refs/heads/master
Commit: c2f1b151075a6d5d850a71c9718cc97bca55063b
Parents: 49d787d
Author: anatole <an...@apache.org>
Authored: Sat Jan 16 07:39:34 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Jan 16 07:39:34 2016 +0100
----------------------------------------------------------------------
modules/integration/etcd/pom.xml | 9 +-
.../org/apache/tamaya/etcd/EtcdBackends.java | 47 ++++++
.../apache/tamaya/etcd/EtcdPropertySource.java | 33 +---
.../etcd/internal/EtcdConfigChangeRequest.java | 63 ++++++++
.../etcd/internal/MutableConfigSupport.java | 44 ++++++
...aya.mutableconfig.spi.ConfigChangeManagerSpi | 19 +++
modules/mutable-config/pom.xml | 81 ++++++++++
.../mutableconfig/ConfigChangeManager.java | 53 +++++++
.../mutableconfig/ConfigChangeRequest.java | 157 +++++++++++++++++++
.../MutablePropertiesConfigSupport.java | 52 ++++++
.../PropertiesFileConfigChangeRequest.java | 99 ++++++++++++
.../XmlPropertiesFileConfigChangeRequest.java | 99 ++++++++++++
.../spi/AbstractConfigChangeRequest.java | 143 +++++++++++++++++
.../spi/ConfigChangeManagerSpi.java | 37 +++++
...aya.mutableconfig.spi.ConfigChangeManagerSpi | 19 +++
.../mutableconfig/ConfigChangeManagerTest.java | 53 +++++++
.../PropertiesFileConfigChangeRequestTest.java | 109 +++++++++++++
sandbox/integration/commons/pom.xml | 2 +-
sandbox/integration/store/pom.xml | 80 ----------
.../org/apache/tamaya/store/PropertyStore.java | 64 --------
.../tamaya/store/PropertyStoreProvider.java | 78 ---------
.../tamaya/store/WritablePropertySource.java | 66 --------
.../store/spi/DefaultStoredPropertySource.java | 137 ----------------
.../store/spi/PropertyStoreProviderSpi.java | 34 ----
sandbox/jodatime/pom.xml | 2 +-
sandbox/metamodels/pom.xml | 2 +-
sandbox/mutable-config/pom.xml | 81 ----------
.../tamaya/mutableconfig/ChangeSummary.java | 105 -------------
.../mutableconfig/ConfigChangeProvider.java | 50 ------
.../mutableconfig/ConfigChangeRequest.java | 136 ----------------
.../spi/ConfigurationChangeProviderSpi.java | 37 -----
sandbox/pom.xml | 2 +-
sandbox/sysprops/pom.xml | 2 +-
sandbox/ui/pom.xml | 1 +
src/site/asciidoc/extensions/index.adoc | 3 +-
src/site/asciidoc/extensions/mod_etcd.adoc | 2 +
.../asciidoc/extensions/mod_mutable_config.adoc | 143 +++++++++++++++++
37 files changed, 1242 insertions(+), 902 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/integration/etcd/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/pom.xml b/modules/integration/etcd/pom.xml
index 2c743f1..041d98e 100644
--- a/modules/integration/etcd/pom.xml
+++ b/modules/integration/etcd/pom.xml
@@ -27,7 +27,7 @@ under the License.
</parent>
<artifactId>tamaya-etcd</artifactId>
- <name>Apache Tamaya Modules Integration - etcd</name>
+ <name>Apache Tamaya Integration - etcd</name>
<packaging>bundle</packaging>
<properties>
@@ -108,6 +108,13 @@ under the License.
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-mutable-config</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java
new file mode 100644
index 0000000..b424625
--- /dev/null
+++ b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java
@@ -0,0 +1,47 @@
+package org.apache.tamaya.etcd;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Created by atsticks on 15.01.16.
+ */
+public final class EtcdBackends {
+
+ private static final Logger LOG = Logger.getLogger(EtcdBackends.class.getName());
+ private static List<EtcdAccessor> etcdBackends = new ArrayList<>();
+
+ static{
+ int timeout = 2;
+ String val = System.getProperty("tamaya.etcd.timeout");
+ if(val == null){
+ val = System.getenv("tamaya.etcd.timeout");
+ }
+ if(val!=null){
+ timeout = Integer.parseInt(val);
+ }
+ String serverURLs = System.getProperty("tamaya.etcd.server.urls");
+ if(serverURLs==null){
+ serverURLs = System.getenv("tamaya.etcd.server.urls");
+ }
+ if(serverURLs==null){
+ serverURLs = "http://127.0.0.1:4001";
+ }
+ for(String url:serverURLs.split("\\,")) {
+ try{
+ etcdBackends.add(new EtcdAccessor(url.trim(), timeout));
+ LOG.info("Using etcd endoint: " + url);
+ } catch(Exception e){
+ LOG.log(Level.SEVERE, "Error initializing etcd accessor for URL: " + url, e);
+ }
+ }
+ }
+
+ private EtcdBackends(){}
+
+ public static List<EtcdAccessor> getEtcdBackends(){
+ return etcdBackends;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
index a07c504..b441141 100644
--- a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
+++ b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
@@ -31,33 +31,12 @@ import java.util.logging.Logger;
*/
public class EtcdPropertySource implements PropertySource{
private static final Logger LOG = Logger.getLogger(EtcdPropertySource.class.getName());
- private List<EtcdAccessor> etcdBackends = new ArrayList<>();
+
private String prefix = System.getProperty("tamaya.etcd.prefix", "");
public EtcdPropertySource(){
- int timeout = 2;
- String val = System.getProperty("tamaya.etcd.timeout");
- if(val == null){
- val = System.getenv("tamaya.etcd.timeout");
- }
- if(val!=null){
- timeout = Integer.parseInt(val);
- }
- String serverURLs = System.getProperty("tamaya.etcd.server.urls");
- if(serverURLs==null){
- serverURLs = System.getenv("tamaya.etcd.server.urls");
- }
- if(serverURLs==null){
- serverURLs = "http://127.0.0.1:4001";
- }
- for(String url:serverURLs.split("\\,")) {
- try{
- etcdBackends.add(new EtcdAccessor(url.trim(), timeout));
- LOG.info("Using etcd endoint: " + url);
- } catch(Exception e){
- LOG.log(Level.SEVERE, "Error initializing etcd accessor for URL: " + url, e);
- }
- }
+
+
}
@Override
@@ -112,7 +91,7 @@ public class EtcdPropertySource implements PropertySource{
reqKey = reqKey.substring(0,reqKey.length()-".source".length());
}
}
- for(EtcdAccessor accessor:etcdBackends){
+ for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
try{
props = accessor.get(reqKey);
if(!props.containsKey("_ERROR")) {
@@ -130,8 +109,8 @@ public class EtcdPropertySource implements PropertySource{
@Override
public Map<String, String> getProperties() {
- if(etcdBackends.isEmpty()){
- for(EtcdAccessor accessor:etcdBackends){
+ if(EtcdBackends.getEtcdBackends().isEmpty()){
+ for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
try{
Map<String, String> props = accessor.getProperties("");
if(!props.containsKey("_ERROR")) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/EtcdConfigChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/EtcdConfigChangeRequest.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/EtcdConfigChangeRequest.java
new file mode 100644
index 0000000..c088ed7
--- /dev/null
+++ b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/EtcdConfigChangeRequest.java
@@ -0,0 +1,63 @@
+package org.apache.tamaya.etcd.internal;
+
+import org.apache.tamaya.etcd.EtcdAccessor;
+import org.apache.tamaya.etcd.EtcdBackends;
+import org.apache.tamaya.mutableconfig.spi.AbstractConfigChangeRequest;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Change Request implementation based on etcd services.
+ */
+class EtcdConfigChangeRequest extends AbstractConfigChangeRequest{
+
+ private static final Logger LOG = Logger.getLogger(EtcdConfigChangeRequest.class.getName());
+
+ EtcdConfigChangeRequest(URI uri){
+ super(uri);
+ }
+
+ @Override
+ public boolean exists(String keyExpression) {
+ for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
+ try{
+ Map<String,String> props = accessor.get(keyExpression);
+ if(!props.containsKey("_ERROR")) {
+ // No repfix mapping necessary here, since we only access/return the value...
+ return props.get(keyExpression)!=null;
+ }
+ } catch(Exception e){
+ LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
+ }
+ }
+ return false;
+ }
+
+
+ @Override
+ protected void commitInternal() {
+ checkClosed();
+ for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
+ try{
+ for(String k:getRemoved()){
+ Map<String,String> res = accessor.delete(k);
+ if(res.get("_ERROR")!=null){
+ LOG.info("Failed to remove key from etcd: " + k);
+ }
+ }
+ for(Map.Entry<String,String> en:getProperties().entrySet()){
+ Map<String,String> res = accessor.set(en.getKey(), en.getValue());
+ if(res.get("_ERROR")!=null){
+ LOG.info("Failed key from etcd: " + en.getKey() + "=" + en.getValue());
+ }
+ }
+ } catch(Exception e){
+ LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/MutableConfigSupport.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/MutableConfigSupport.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/MutableConfigSupport.java
new file mode 100644
index 0000000..bfcd18c
--- /dev/null
+++ b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/internal/MutableConfigSupport.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.etcd.internal;
+
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
+import org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi;
+
+import java.net.URI;
+
+/**
+ * Created by atsticks on 15.01.16.
+ */
+public class MutableConfigSupport implements ConfigChangeManagerSpi{
+
+ private URI backendURI;
+
+ public MutableConfigSupport(){
+ backendURI = URI.create("config:etcd");
+ }
+
+ @Override
+ public ConfigChangeRequest createChangeRequest(URI uri) {
+ if(backendURI.equals(uri)) {
+ return new EtcdConfigChangeRequest(backendURI);
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi b/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi
new file mode 100644
index 0000000..2189807
--- /dev/null
+++ b/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.etcd.internal.MutableConfigSupport
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/modules/mutable-config/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mutable-config/pom.xml b/modules/mutable-config/pom.xml
new file mode 100644
index 0000000..f551a21
--- /dev/null
+++ b/modules/mutable-config/pom.xml
@@ -0,0 +1,81 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy current the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-extensions</artifactId>
+ <version>0.2-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>tamaya-mutable-config</artifactId>
+ <name>Apache Tamaya Modules - Mutable Configuration Support</name>
+ <description>This module provides abstraction, if your scenario needs to actively change configuration entries
+ and write changes back to some property sources, files etc.</description>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <jdkVersion>1.7</jdkVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-events</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.tamaya.mutableconfig
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..6c18b87
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeManager.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.net.URI;
+import java.util.Objects;
+
+/**
+ * Accessor for creating {@link ConfigChangeRequest} instances to change and commite configuration.
+ */
+public final class ConfigChangeManager {
+
+ /** Singleton constructor. */
+ private ConfigChangeManager(){}
+
+ /**
+ * Creates a new change request for the given configurationSource
+ * @return a new ChangeRequest
+ * @throws org.apache.tamaya.ConfigException if the given configurationSource cannot be edited.
+ */
+ public static ConfigChangeRequest createChangeRequest(URI configurationSource){
+ Objects.requireNonNull(configurationSource);
+ for(ConfigChangeManagerSpi spi:ServiceContextManager.getServiceContext()
+ .getServices(ConfigChangeManagerSpi.class)){
+ ConfigChangeRequest req = spi.createChangeRequest(configurationSource);
+ if(req!=null){
+ return req;
+ }
+ }
+ throw new ConfigException("Not an editable configuration source: " + configurationSource);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..9bbb2c0
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeRequest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+
+
+/**
+ * This interface extends the Configuration interface hereby adding methods to change configuration entries.
+ * Hereby not all configuration entries are necessarily mutable, since some entries may be read from non
+ * mutable areas of configuration. Of course, it is always possible to add a mutable shadow layer on top of all
+ * configuration to enable whatever changes applied. The exact management and storage persistence algorithm should be
+ * transparent.<br/>
+ * As a consequence clients should first check, using the corresponding methods, if entries are to edited or removed
+ * actually are eligible for change/creation or removal.
+ */
+public interface ConfigChangeRequest {
+
+ /**
+ * Get the unique id of this change reqeust (UUID).
+ * @return the unique id of this change reqeust (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();
+
+ /**
+ * 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.*".
+ */
+ boolean isWritable(String keyExpression);
+
+ /**
+ * 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
+ * be a regulat expression, such "as a.b.c.*".
+ */
+ 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
+ * 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.*".
+ * @return true, if there is any key found matching the expression.
+ */
+ boolean exists(String keyExpression);
+
+ /**
+ * Sets a property.
+ *
+ * @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.
+ */
+ ConfigChangeRequest put(String key, String value);
+
+ /**
+ * Puts all given configuration entries. This method should check that all given properties are
+ * basically removable, as defined by #isWritable. If any of the passed keys is not writable during this initial
+ * check, the operation should not perform any configuration changes and throw a {@link org.apache.tamaya.ConfigException}. If errors
+ * occur afterwards, when the properties are effectively written back to the backends, the errors should be
+ * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
+ * remove all entries as far as possible and abort the writing operation.
+ *
+ * @param properties the properties tobe written, not null.
+ * @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);
+
+ /**
+ * 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.
+ */
+ ConfigChangeRequest remove(String... keys);
+
+ /**
+ * Removes all given configuration entries. This method should check that all given properties are
+ * basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial
+ * check, the operation should not perform any configuration changes and throw a {@link org.apache.tamaya.ConfigException}. If errors
+ * occur afterwards, when the properties are effectively written back to the backends, the errors should be
+ * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
+ * remove all entries as far as possible and abort the writing operation.
+ *
+ * @param keys the property's keys to be removed, not null.
+ * @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);
+
+ /**
+ * Removes all given configuration entries. This method should check that all given properties are
+ * basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial
+ * check, the operation should not perform any configuration changes and throw a {@link org.apache.tamaya.ConfigException}. If errors
+ * occur afterwards, when the properties are effectively written back to the backends, the errors should be
+ * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
+ * remove all entries as far as possible and abort the writing operation.
+ *
+ * @param keys the property's keys to be removed, not null.
+ * @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);
+
+ /**
+ * 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.
+ */
+ 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();
+
+ /**
+ * 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/c2f1b151/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
new file mode 100644
index 0000000..04e2858
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/MutablePropertiesConfigSupport.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.internal;
+
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
+import org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi;
+
+import java.io.File;
+import java.net.URI;
+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
+ * ConfigChangeRequests fir .properties and .xml files.
+ */
+public class MutablePropertiesConfigSupport implements ConfigChangeManagerSpi{
+
+ private static final Logger LOG = Logger.getLogger(XmlPropertiesFileConfigChangeRequest.class.getName());
+
+ @Override
+ public ConfigChangeRequest createChangeRequest(URI uri) {
+ try{
+ File f = new File(uri);
+ if(f.getName().endsWith(".properties")){
+ return new PropertiesFileConfigChangeRequest(f);
+ }else if(f.getName().endsWith(".xml")){
+ return new XmlPropertiesFileConfigChangeRequest(f);
+ }
+ } catch(Exception e){
+ LOG.log(Level.FINEST, "URI not convertible to file, ignoring " + uri, e);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..e393461
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.internal;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.mutableconfig.spi.AbstractConfigChangeRequest;
+
+import java.io.*;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Change Request implementation based on .properties file.
+ */
+class PropertiesFileConfigChangeRequest extends AbstractConfigChangeRequest{
+
+ private static final Logger LOG = Logger.getLogger(PropertiesFileConfigChangeRequest.class.getName());
+
+ private File file;
+
+ private Properties properties = new Properties();
+
+ PropertiesFileConfigChangeRequest(File file){
+ super(file.toURI());
+ this.file = file;
+ if(file.exists()) {
+ try (InputStream is = getBackendURI().toURL().openStream()) {
+ properties.load(is);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to load properties from " + file, e);
+ }
+ }
+ }
+
+ @Override
+ public boolean exists(String keyExpression) {
+ if(properties.containsKey(keyExpression)){
+ return true;
+ }
+ for(Object key:properties.keySet()){
+ if(key.toString().matches(keyExpression)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ @Override
+ protected void commitInternal() {
+ if(!file.exists()){
+ try {
+ if(!file.createNewFile()){
+ throw new ConfigException("Failed to create config file " + file);
+ }
+ } catch (IOException e) {
+ throw new ConfigException("Failed to create config file " + file, e);
+ }
+ }
+ for(Map.Entry<String,String> en:super.properties.entrySet()){
+ this.properties.put(en.getKey(), en.getValue());
+ }
+ for(String rmKey:super.removed){
+ this.properties.remove(rmKey);
+ }
+ try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))){
+ properties.store(bos, "Properties written from Tamaya, request: " + getRequestID());
+ bos.flush();
+ }
+ catch(Exception e){
+ throw new ConfigException("Failed to write config to " + file, e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "PropertiesFileConfigChangeRequest{" +
+ "file=" + file +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..6ec2363
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/XmlPropertiesFileConfigChangeRequest.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.internal;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.mutableconfig.spi.AbstractConfigChangeRequest;
+
+import java.io.*;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Change Request implementation based on .xml properties fiel.
+ */
+class XmlPropertiesFileConfigChangeRequest extends AbstractConfigChangeRequest{
+
+ private static final Logger LOG = Logger.getLogger(XmlPropertiesFileConfigChangeRequest.class.getName());
+
+ private File file;
+
+ private Properties properties = new Properties();
+
+ XmlPropertiesFileConfigChangeRequest(File file){
+ super(file.toURI());
+ this.file = file;
+ if(file.exists()) {
+ try (InputStream is = getBackendURI().toURL().openStream()) {
+ properties.loadFromXML(is);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to load properties from " + file, e);
+ }
+ }
+ }
+
+ @Override
+ public boolean exists(String keyExpression) {
+ if(properties.containsKey(keyExpression)){
+ return true;
+ }
+ for(Object key:properties.keySet()){
+ if(key.toString().matches(keyExpression)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ @Override
+ protected void commitInternal() {
+ if(!file.exists()){
+ try {
+ if(!file.createNewFile()){
+ throw new ConfigException("Failed to create config file " + file);
+ }
+ } catch (IOException e) {
+ throw new ConfigException("Failed to create config file " + file, e);
+ }
+ }
+ for(Map.Entry<String,String> en:super.properties.entrySet()){
+ this.properties.put(en.getKey(), en.getValue());
+ }
+ for(String rmKey:super.removed){
+ this.properties.remove(rmKey);
+ }
+ try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))){
+ properties.storeToXML(bos, "Properties written from Tamaya, request: " + getRequestID());
+ bos.flush();
+ }
+ catch(Exception e){
+ throw new ConfigException("Failed to write config to " + file, e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "XmlPropertiesFileConfigChangeRequest{" +
+ "file=" + file +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..0fdd43d
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/AbstractConfigChangeRequest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.spi;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
+
+import java.net.URI;
+import java.util.*;
+
+/**
+ * Base class for implementing a ConfigChangeRequest.
+ */
+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 boolean closed = false;
+
+ 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).
+ */
+ @Override
+ public String getRequestID(){
+ return requestID;
+ }
+
+ @Override
+ public final URI getBackendURI() {
+ return uri;
+ }
+
+ @Override
+ public boolean isWritable(String keyExpression) {
+ return true;
+ }
+
+ @Override
+ public boolean isRemovable(String keyExpression) {
+ return true;
+ }
+
+ protected Map<String,String> getProperties(){
+ return properties;
+ }
+
+ protected Set<String> getRemoved(){
+ return removed;
+ }
+
+ @Override
+ public abstract boolean exists(String keyExpression);
+
+ @Override
+ public ConfigChangeRequest put(String key, String value) {
+ checkClosed();
+ this.properties.put(key, value);
+ return this;
+ }
+
+ @Override
+ public ConfigChangeRequest putAll(Map<String, String> properties) {
+ checkClosed();
+ this.properties.putAll(properties);
+ return this;
+ }
+
+ @Override
+ public ConfigChangeRequest remove(String... keys) {
+ checkClosed();
+ for(String k:keys) {
+ this.removed.add(k);
+ }
+ return this;
+ }
+
+ @Override
+ public ConfigChangeRequest remove(Collection<String> keys) {
+ checkClosed();
+ for(String k:keys) {
+ this.removed.add(k);
+ }
+ return this;
+ }
+
+ @Override
+ public ConfigChangeRequest removeAll(String... keys) {
+ checkClosed();
+ for(String k:keys) {
+ this.removed.add(k);
+ }
+ return this;
+ }
+
+ @Override
+ public final void commit() {
+ checkClosed();
+ commitInternal();
+ closed = true;
+ }
+
+ protected abstract void commitInternal();
+
+ @Override
+ public final void cancel() {
+ checkClosed();
+ closed = true;
+ }
+
+ @Override
+ public final boolean isClosed() {
+ return closed;
+ }
+
+ protected void checkClosed(){
+ if(closed){
+ throw new ConfigException("Change request already closed.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..94e4a44
--- /dev/null
+++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeManagerSpi.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.spi;
+
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
+
+import java.net.URI;
+
+/**
+ * Provider SPI for the {@link org.apache.tamaya.mutableconfig.ConfigChangeManager}. Providers may override
+ * other providers registering with a higher {@link javax.annotation.Priority} value annotated.
+ */
+public interface ConfigChangeManagerSpi {
+
+ /**
+ * Creates a new change request for the given Configuration.
+ * @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/c2f1b151/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi b/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi
new file mode 100644
index 0000000..6a749ac
--- /dev/null
+++ b/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.ConfigChangeManagerSpi
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.mutableconfig.internal.MutablePropertiesConfigSupport
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..5638e19
--- /dev/null
+++ b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/ConfigChangeManagerTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig;
+
+import org.apache.tamaya.ConfigException;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URI;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 16.01.16.
+ */
+public class ConfigChangeManagerTest {
+
+ @Test
+ public void testCreateChangeRequest() throws Exception {
+ File f = File.createTempFile("ConfigChangeRequest",".properties");
+ ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertNotNull(req);
+ f = File.createTempFile("ConfigChangeRequest",".xml");
+ req = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertNotNull(req);
+ }
+
+ @Test(expected=ConfigException.class)
+ public void testInvalidCreateChangeRequest() throws Exception {
+ ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(new URI("foo:bar"));
+ }
+
+ @Test(expected=NullPointerException.class)
+ public void testNullCreateChangeRequest() throws Exception {
+ ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(null);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/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
new file mode 100644
index 0000000..44d0860
--- /dev/null
+++ b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigChangeRequestTest.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.mutableconfig.internal;
+
+import org.apache.tamaya.mutableconfig.ConfigChangeManager;
+import org.apache.tamaya.mutableconfig.ConfigChangeRequest;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 16.01.16.
+ */
+public class PropertiesFileConfigChangeRequestTest {
+ @Test
+ public void testReadWriteProperties_WithCancel() throws IOException {
+ File f = File.createTempFile("testReadWriteProperties_WithCancel",".properties");
+ f.delete();
+ ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertTrue(req instanceof PropertiesFileConfigChangeRequest);
+ req.put("key1", "value1");
+ Map<String,String> cm = new HashMap<>();
+ cm.put("key2", "value2");
+ cm.put("key3", "value3");
+ req.cancel();;
+ assertTrue(req.isClosed());
+ assertFalse(f.exists());
+ }
+
+ @Test
+ public void testReadWriteProperties_WithCommit() throws IOException {
+ File f = File.createTempFile("testReadWriteProperties_WithCommit",".properties");
+ f.delete();
+ ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertTrue(req instanceof PropertiesFileConfigChangeRequest);
+ req.put("key1", "value1");
+ Map<String,String> cm = new HashMap<>();
+ cm.put("key2", "value2");
+ cm.put("key3", "value3");
+ req.putAll(cm);
+ req.commit();;
+ assertTrue(req.isClosed());
+ assertTrue(f.exists());
+ ConfigChangeRequest req2 = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertTrue(req != req2);
+ req2.remove("foo");
+ req2.remove("key3");
+ req2.put("key1", "value1.2");
+ req2.put("key4", "value4");
+ req2.commit();
+ Properties props = new Properties();
+ props.load(f.toURL().openStream());
+ assertEquals(3, props.size());
+ assertEquals("value1.2", props.getProperty("key1"));
+ assertEquals("value2", props.getProperty("key2"));
+ assertEquals("value4", props.getProperty("key4"));
+ }
+
+ @Test
+ public void testReadWriteXmlProperties_WithCommit() throws IOException {
+ File f = File.createTempFile("testReadWriteProperties_WithCommit",".xml");
+ f.delete();
+ ConfigChangeRequest req = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertTrue(req instanceof XmlPropertiesFileConfigChangeRequest);
+ req.put("key1", "value1");
+ Map<String,String> cm = new HashMap<>();
+ cm.put("key2", "value2");
+ cm.put("key3", "value3");
+ req.putAll(cm);
+ req.commit();;
+ assertTrue(req.isClosed());
+ assertTrue(f.exists());
+ ConfigChangeRequest req2 = ConfigChangeManager.createChangeRequest(f.toURI());
+ assertTrue(req != req2);
+ req2.remove("foo");
+ req2.remove("key3");
+ req2.put("key1", "value1.2");
+ req2.put("key4", "value4");
+ req2.commit();
+ Properties props = new Properties();
+ props.loadFromXML(f.toURL().openStream());
+ assertEquals(3, props.size());
+ assertEquals("value1.2", props.getProperty("key1"));
+ assertEquals("value2", props.getProperty("key2"));
+ assertEquals("value4", props.getProperty("key4"));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/commons/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/integration/commons/pom.xml b/sandbox/integration/commons/pom.xml
index 65d3203..2b5eda0 100644
--- a/sandbox/integration/commons/pom.xml
+++ b/sandbox/integration/commons/pom.xml
@@ -27,7 +27,7 @@ under the License.
<relativePath>..</relativePath>
</parent>
<artifactId>tamaya-commons-config</artifactId>
- <name>Apache Tamaya Commons Configuration Integration</name>
+ <name>Apache Tamaya Commons Integration - Apache Commons</name>
<packaging>bundle</packaging>
<dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/store/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/integration/store/pom.xml b/sandbox/integration/store/pom.xml
deleted file mode 100644
index 0e8a546..0000000
--- a/sandbox/integration/store/pom.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy current the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration-sandbox</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
- </parent>
- <artifactId>tamaya-store</artifactId>
- <name>Apache Tamaya Storage/Cache/Datagrid Integration</name>
- <description>Integration with a Datagrid backend for distributed configuration.</description>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-events</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.tamaya,
- org.apache.tamaya.spi,
- org.apache.tamaya.events,
- org.apache.tamaya.spisupport
- javax.annotation,
- *
- </Import-Package>
- <Export-Package>
- org.apache.tamaya.integration.store,
- org.apache.tamaya.integration.store.spi,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStore.java
----------------------------------------------------------------------
diff --git a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStore.java b/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStore.java
deleted file mode 100644
index d1d6adf..0000000
--- a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStore.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.store;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.Map;
-
-/**
- * Simple abstraction of a property synchronization backend. Most methods are similar
- * to a {@link org.apache.tamaya.spi.PropertySource}, enhanced with methods for
- * updating the property storage.
- */
-public interface PropertyStore {
-
- /**
- * Get the store's name.
- * @return the name, never null.
- */
- String getName();
-
- /**
- * Stores the given PropertySource into the store.
- * @param propertySource
- */
- void store(PropertySource propertySource);
-
- /**
- * Read all properties.
- * @return the properties from the remote store, never null.
- */
- Map<String,String> read();
-
- /**
- * Reads a single key fromt hthe store.
- * @param key the key, not null.
- * @return the value, or null.
- */
- String read(String key);
-
- /**
- * Determines if {@link #read()} returns all contained properties, or optionally only
- * a subset of the accessible and defined properties are returned.
- * @return true, if this store is scannable.
- */
- boolean isScannable();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStoreProvider.java
----------------------------------------------------------------------
diff --git a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStoreProvider.java b/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStoreProvider.java
deleted file mode 100644
index dceb29a..0000000
--- a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/PropertyStoreProvider.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.store;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.store.spi.PropertyStoreProviderSpi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * Simple provider accessor singleton for accessing {@link PropertyStore}
- * instances.
- */
-public final class PropertyStoreProvider {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(PropertyStoreProvider.class.getName());
-
-
- /**
- * Singleton constructor.
- */
- private PropertyStoreProvider() {
- }
-
-
- /**
- * Access a {@link PropertyStore} using it's id.
- *
- * @param storeId the unique id of the store to use.
- * @return
- */
- public static PropertyStore getPropertyStore(String storeId) {
- for (PropertyStoreProviderSpi propertyStoreProviderSpi : ServiceContextManager.getServiceContext()
- .getServices(PropertyStoreProviderSpi.class)) {
- PropertyStore store = propertyStoreProviderSpi.getPropertyStore(storeId);
- if (store != null) {
- LOG.finest("DataGrid '" + storeId + "' used: " + store);
- return store;
- }
- }
- throw new ConfigException("No such Store: " + storeId);
- }
-
- /**
- * Access a {@link PropertyStore} using it's id, hereby returning the most significant of the configured
- * {@link PropertyStore} instances.
- *
- * @return the default PropertyStore instance.
- */
- public static PropertyStore getDefaultPropertyStore() {
- return getPropertyStore("default");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/store/src/main/java/org/apache/tamaya/store/WritablePropertySource.java
----------------------------------------------------------------------
diff --git a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/WritablePropertySource.java b/sandbox/integration/store/src/main/java/org/apache/tamaya/store/WritablePropertySource.java
deleted file mode 100644
index c19fa45..0000000
--- a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/WritablePropertySource.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.store;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.Map;
-
-/**
- * Simple abstraction of a property synchronization backend. Most methods are similar
- * to a {@link org.apache.tamaya.spi.PropertySource}, enhanced with methods for
- * updating the property storage.
- */
-public interface WritablePropertySource extends PropertySource{
-
- /**
- * Loads the property source from its store..
- */
- void load();
-
- /**
- * Sets the store to the given properties, replacing all previous state.
- * @param props the new properties.
- */
- void setAll(Map<String, String> props);
-
- /**
- * Updates/adds all the given entries.
- * @param props the entries to be added/updated.
- */
- void putAll(Map<String, String> props);
-
- /**
- * Writes a single entry.
- * @param key the key, not null.
- * @param value the new value, not null.
- */
- void put(String key, String value);
-
- /**
- * Removes all entries.
- */
- void clear();
-
- /**
- * Synchronize the current state with the remote version.
- */
- void synch();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/DefaultStoredPropertySource.java
----------------------------------------------------------------------
diff --git a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/DefaultStoredPropertySource.java b/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/DefaultStoredPropertySource.java
deleted file mode 100644
index b3fe1ee..0000000
--- a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/DefaultStoredPropertySource.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.store.spi;
-
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.FrozenPropertySource;
-import org.apache.tamaya.events.delta.ChangeType;
-import org.apache.tamaya.events.delta.PropertySourceChange;
-import org.apache.tamaya.events.delta.PropertySourceChangeBuilder;
-import org.apache.tamaya.spisupport.BasePropertySource;
-import org.apache.tamaya.store.PropertyStore;
-import org.apache.tamaya.store.WritablePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that is connected to a {@link PropertyStore}.
- */
-public class DefaultStoredPropertySource extends BasePropertySource
- implements WritablePropertySource {
-
- /**
- * The store to be used, not null.
- */
- private PropertyStore propertyStore;
-
- /**
- * The last version of stoarge data accessed.
- */
- private String lastVersion;
-
- private Map<String, String> properties = new HashMap<>();
-
-
- private FrozenPropertySource currentConfig;
-
- /**
- * Creates a new property source.
- *
- * @param propertyStore the backend store.
- * @param defaultOrdinal the default ordinal to be used.
- */
- public DefaultStoredPropertySource(PropertyStore propertyStore, int defaultOrdinal) {
- super(defaultOrdinal);
- this.propertyStore = Objects.requireNonNull(propertyStore);
- this.properties.putAll(this.propertyStore.read());
- }
-
- @Override
- public void load() {
- this.properties.clear();
- this.properties.putAll(this.propertyStore.read());
- synch();
- }
-
- @Override
- public String getName() {
- return this.propertyStore.getName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public String get(String key) {
- if (!propertyStore.isScannable()) {
- return propertyStore.read(key);
- }
- return properties.get(key);
- }
-
- @Override
- public boolean isScannable() {
- return propertyStore.isScannable();
- }
-
- @Override
- public String toString() {
- return "StoredPropertySource{" +
- "propertyStore=" + propertyStore.getName() +
- '}';
- }
-
- @Override
- public void setAll(Map<String, String> props) {
- this.properties.clear();
- this.properties.putAll(props);
- synch();
- }
-
- @Override
- public void putAll(Map<String, String> props) {
- this.properties.putAll(props);
- synch();
- }
-
- @Override
- public void put(String key, String value) {
- this.properties.put(key, value);
- synch();
- }
-
- @Override
- public void clear() {
- this.properties.clear();
- synch();
- }
-
- @Override
- public void synch() {
- FrozenPropertySource newConfig = FrozenPropertySource.of(this);
- PropertySourceChange change = PropertySourceChangeBuilder.of(currentConfig, ChangeType.UPDATED)
- .addChanges(newConfig).build();
- currentConfig = newConfig;
- ConfigEventManager.fireEvent(change);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/PropertyStoreProviderSpi.java
----------------------------------------------------------------------
diff --git a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/PropertyStoreProviderSpi.java b/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/PropertyStoreProviderSpi.java
deleted file mode 100644
index 1b20fc1..0000000
--- a/sandbox/integration/store/src/main/java/org/apache/tamaya/store/spi/PropertyStoreProviderSpi.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.store.spi;
-
-import org.apache.tamaya.store.PropertyStore;
-
-/**
- * Class, that provides access to PropertyStores to be used.
- */
-public interface PropertyStoreProviderSpi {
-
- /**
- * Access a {@link PropertyStore} using it's id.
- * @param storeId the unique id of the store to use.
- * @return
- */
- PropertyStore getPropertyStore(String storeId);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/jodatime/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/jodatime/pom.xml b/sandbox/jodatime/pom.xml
index 98b13a6..98f48cf 100644
--- a/sandbox/jodatime/pom.xml
+++ b/sandbox/jodatime/pom.xml
@@ -30,7 +30,7 @@ under the License.
</parent>
<artifactId>tamaya-jodatime</artifactId>
- <name>Apache Tamaya Joda-Time Support</name>
+ <name>Apache Tamaya Modules - Joda-Time Support</name>
<packaging>bundle</packaging>
<inceptionYear>2015</inceptionYear>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/metamodels/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/metamodels/pom.xml b/sandbox/metamodels/pom.xml
index 4a05846..79513d2 100644
--- a/sandbox/metamodels/pom.xml
+++ b/sandbox/metamodels/pom.xml
@@ -29,7 +29,7 @@ under the License.
<groupId>org.apache.tamaya.ext.metamodels</groupId>
<artifactId>tamaya-metamodels</artifactId>
- <name>Apache Tamaya Extension Modules: Metamodels</name>
+ <name>Apache Tamaya Modules - Metamodels</name>
<packaging>pom</packaging>
<modules>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/mutable-config/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/mutable-config/pom.xml b/sandbox/mutable-config/pom.xml
deleted file mode 100644
index c20a60a..0000000
--- a/sandbox/mutable-config/pom.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy current the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-mutable-config</artifactId>
- <name>Apache Tamaya Mutable Configuration Support</name>
- <description>This module provides abstraction, if your scenario needs to actively change configuration entries
- and write changes back to some property sources, files etc.</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-events</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.mutableconfig
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangeSummary.java
----------------------------------------------------------------------
diff --git a/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangeSummary.java b/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangeSummary.java
deleted file mode 100644
index 63d084c..0000000
--- a/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangeSummary.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.events.delta.ConfigurationChange;
-import org.apache.tamaya.events.delta.PropertySourceChange;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * Summaray class of a configuration change operation.
- * This class is immutable, read-only and thread-safe.
- */
-public final class ChangeSummary implements Serializable{
-
- private static final long serialVersionUID = 1L;
-
- private String changeId;
- private ConfigurationChange configChange;
- private List<PropertySourceChange> sourceChanges = new ArrayList<>();
- private long commitTS;
-
- private ChangeSummary(Builder builder){
- this.changeId = builder.changeId;
- this.commitTS = builder.commitTS;
- this.configChange = Objects.requireNonNull(builder.configChange);
- this.sourceChanges.addAll(builder.sourceChanges);
- }
-
- public String getChangeId(){
- return changeId;
- }
-
- public long getTimestampMillis(){
- return commitTS;
- }
-
- public ConfigurationChange getConfigurationChange(){
- return configChange;
- }
-
- public Collection<PropertySourceChange> getPropertySourceChanges(){
- return Collections.unmodifiableList(this.sourceChanges);
- }
-
-
-
-
-
- public static final class Builder {
-
- private String changeId;
- private ConfigurationChange configChange;
- private List<PropertySourceChange> sourceChanges = new ArrayList<>();
- private long commitTS = System.currentTimeMillis();
-
- public Builder(){
- this(UUID.randomUUID().toString());
- }
-
- public Builder(String changeId){
- this.changeId = Objects.requireNonNull(changeId);
- }
-
- public Builder setConfigChange(ConfigurationChange configChange){
- this.configChange = configChange;
- return this;
- }
-
- public Builder addPropertySourceChange(PropertySourceChange propertyChange){
- this.sourceChanges.add(propertyChange);
- return this;
- }
-
- public Builder setTimestamp(long timestamp){
- this.commitTS = timestamp;
- return this;
- }
-
- public ChangeSummary build(){
- return new ChangeSummary(this);
- }
-
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c2f1b151/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeProvider.java
----------------------------------------------------------------------
diff --git a/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeProvider.java b/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeProvider.java
deleted file mode 100644
index f8842ea..0000000
--- a/sandbox/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ConfigChangeProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.mutableconfig.spi.ConfigurationChangeProviderSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-/**
- * Accessor for creating {@link ConfigChangeRequest} instances to change and commite configuration.
- */
-public final class ConfigChangeProvider {
-
- /**
- * Creates a new change request for the given Configuration.
- * @param config the configuration.
- * @return a new ChangeRequest
- * @throws UnsupportedOperationException if no change providers are registered.
- */
- public static ConfigChangeRequest createChangeRequest(Configuration config){
- return ServiceContextManager.getServiceContext().getService(ConfigurationChangeProviderSpi.class)
- .createChangeRequest(config);
- }
-
- /**
- * Creates a new change request for the current Configuration.
- * @return a new ChangeRequest
- */
- public static ConfigChangeRequest createChangeRequest(){
- return createChangeRequest(ConfigurationProvider.getConfiguration());
- }
-
-}