You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/10/23 20:36:13 UTC
[01/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-148
Working on making OSGi support work in a testable fashion.
Repository: incubator-tamaya-extensions
Updated Branches:
refs/heads/old_master [created] c641421b6
TAMAYA-148 Working on making OSGi support work in a testable fashion.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/3833438c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/3833438c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/3833438c
Branch: refs/heads/old_master
Commit: 3833438ce706e2d16c63aa03493f47aecd40a2df
Parents: 082c36a
Author: John D. Ament <jo...@apache.org>
Authored: Sun Apr 17 21:47:27 2016 -0400
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../apache/tamaya/events/ConfigEventListener.java | 1 -
.../org.apache.tamaya.events.ConfigListener | 18 ------------------
2 files changed, 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3833438c/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventListener.java b/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
index de635f8..7fb32c8 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
@@ -21,7 +21,6 @@ package org.apache.tamaya.events;
/**
* Interface to be implemented for listening on changes on {@link org.apache.tamaya.Configuration} instances.
*/
-//@FunctionalInterface
public interface ConfigEventListener {
/**
* Called if an event occurred.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3833438c/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigListener
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigListener b/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigListener
deleted file mode 100644
index f3199f2..0000000
--- a/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigListener
+++ /dev/null
@@ -1,18 +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.
-#
[46/50] [abbrv] incubator-tamaya-extensions git commit: Fixed quality
issues.
Posted by pl...@apache.org.
Fixed quality issues.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/09c1ad98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/09c1ad98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/09c1ad98
Branch: refs/heads/old_master
Commit: 09c1ad988041045c624772612a96c9891a7344c3
Parents: 537d61f
Author: anatole <an...@apache.org>
Authored: Sat Apr 30 20:44:03 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/09c1ad98/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
index b33ff27..c2739a1 100644
--- a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
@@ -107,7 +107,7 @@ public final class ConfigurationFilter implements PropertyFilter{
@Override
public String filterProperty(String valueToBeFiltered, FilterContext context) {
- if(!context.isSinglePropertyScoped()){
+ if(context.isSinglePropertyScoped()){
for(PropertyFilter pred: THREADED_SINGLE_FILTERS.get().getFilters()){
valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
}
[07/50] [abbrv] incubator-tamaya-extensions git commit: Fixed compile
issues due to extended constructor for ConversionContext.
Posted by pl...@apache.org.
Fixed compile issues due to extended constructor for ConversionContext.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/8ebc3c1a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/8ebc3c1a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/8ebc3c1a
Branch: refs/heads/old_master
Commit: 8ebc3c1a1ec705e716aeb77c837f51a105a7b355
Parents: 2e22951
Author: anatole <an...@apache.org>
Authored: Wed Feb 17 01:16:56 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
src/main/java/org/apache/tamaya/events/FrozenConfiguration.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8ebc3c1a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
index 313f569..b874987 100644
--- a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
+++ b/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
@@ -116,7 +116,8 @@ public final class FrozenConfiguration implements Configuration, Serializable {
if (value != null) {
List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
.getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(this,key,type).build();
+ ConversionContext context = new ConversionContext.Builder(this,
+ ConfigurationProvider.getConfigurationContext(), key,type).build();
for (PropertyConverter<T> converter : converters) {
try {
T t = converter.convert(value, context);
[13/50] [abbrv] incubator-tamaya-extensions git commit: Reset version
for new release run.
Posted by pl...@apache.org.
Reset version for new release run.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/e5bbbde3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/e5bbbde3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/e5bbbde3
Branch: refs/heads/old_master
Commit: e5bbbde3939f9fcd2adcd89f5a5adaf47066a111
Parents: b42c4ad
Author: anatole <an...@apache.org>
Authored: Wed Mar 9 14:09:25 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e5bbbde3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e843ec8..4bd0ee4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
+ <version>0.2-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-events</artifactId>
[27/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-154:
LHF: fix javadoc while stduying findbugs warning
Posted by pl...@apache.org.
TAMAYA-154: LHF: fix javadoc while stduying findbugs warning
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/6710cec0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/6710cec0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/6710cec0
Branch: refs/heads/old_master
Commit: 6710cec0a8584df7afdb42eff8110cbe5672bf3c
Parents: 07d3602
Author: Phil Ottlinger <po...@apache.org>
Authored: Wed Aug 31 20:41:23 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/tamaya/events/PropertySourceChangeBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6710cec0/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
index 0858fdb..fa2cf5e 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -87,7 +87,7 @@ public final class PropertySourceChangeBuilder {
/**
* Compares the two property config/configurations and creates a collection current all changes
- * that must be appied to render {@code map1} into {@code map2}.
+ * that must be applied to render {@code map1} into {@code map2}.
*
* @param map1 the source map, not null.
* @param map2 the target map, not null.
[08/50] [abbrv] incubator-tamaya-extensions git commit: Removed all
dependencies to Hamcrest versions < 2.0.0.0
Posted by pl...@apache.org.
Removed all dependencies to Hamcrest versions < 2.0.0.0
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/41e9cf35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/41e9cf35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/41e9cf35
Branch: refs/heads/old_master
Commit: 41e9cf354c24ca75bc14b6440a1aa38cb5f04db9
Parents: 8ebc3c1
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Fri Mar 4 04:39:46 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/41e9cf35/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9d2f59d..4bd0ee4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,6 +53,12 @@ under the License.
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -88,4 +94,4 @@ under the License.
</build>
-</project>
\ No newline at end of file
+</project>
[45/50] [abbrv] incubator-tamaya-extensions git commit: Added
ConfigurationFilter tests and fixes.
Posted by pl...@apache.org.
Added ConfigurationFilter tests and fixes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/98980d03
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/98980d03
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/98980d03
Branch: refs/heads/old_master
Commit: 98980d032ae27882eb3c8d507d29ab30c33f79b3
Parents: 1aefa98
Author: anatole <an...@apache.org>
Authored: Sat Feb 13 01:21:40 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../tamaya/filter/ConfigurationFilter.java | 4 +-
.../tamaya/filter/ProgrammableFilter.java | 9 ++-
.../org.apache.tamaya.spi.PropertyFilter | 3 +-
.../tamaya/filter/ConfigurationFilterTest.java | 85 +++++++++++++++++---
4 files changed, 85 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/98980d03/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
index b5bb45e..b33ff27 100644
--- a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
@@ -108,11 +108,11 @@ public final class ConfigurationFilter implements PropertyFilter{
@Override
public String filterProperty(String valueToBeFiltered, FilterContext context) {
if(!context.isSinglePropertyScoped()){
- for(PropertyFilter pred: THREADED_MAP_FILTERS.get().getFilters()){
+ for(PropertyFilter pred: THREADED_SINGLE_FILTERS.get().getFilters()){
valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
}
}else{
- for(PropertyFilter pred: THREADED_SINGLE_FILTERS.get().getFilters()){
+ for(PropertyFilter pred: THREADED_MAP_FILTERS.get().getFilters()){
valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/98980d03/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java b/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
index 18a7e08..ec6040c 100644
--- a/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
@@ -61,6 +61,14 @@ public final class ProgrammableFilter implements PropertyFilter{
}
/**
+ * Removes a filter.
+ * @param filter the filter to be removed, not null.
+ */
+ public void removeFilter(PropertyFilter filter) {
+ filters.remove(filter);
+ }
+
+ /**
* Clears all filters.
*/
public void clearFilters(){
@@ -107,5 +115,4 @@ public final class ProgrammableFilter implements PropertyFilter{
'}';
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/98980d03/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
index 630c222..806b833 100644
--- a/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
+++ b/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
@@ -16,5 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.filter.ConfigurationFilter
-org.apache.tamaya.filter.DefaultMetadataFilter
\ No newline at end of file
+org.apache.tamaya.filter.ConfigurationFilter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/98980d03/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java b/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
index bbfe72d..9d0da1f 100644
--- a/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
+++ b/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
@@ -18,6 +18,10 @@
*/
package org.apache.tamaya.filter;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -28,32 +32,91 @@ import static org.junit.Assert.*;
public class ConfigurationFilterTest {
@Test
- public void testIsMetadataFiltered() throws Exception {
-// TODO
+ public void testMetadataFiltered() throws Exception {
+ ConfigurationFilter.setMetadataFiltered(true);
+ assertTrue(ConfigurationFilter.isMetadataFiltered());
+ ConfigurationFilter.setMetadataFiltered(false);
+ assertFalse(ConfigurationFilter.isMetadataFiltered());
}
@Test
- public void testSetMetadataFiltered() throws Exception {
-// TODO
+ public void testGetSingleFilters() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ assertNotNull(ConfigurationFilter.getSingleFilters());
+ PropertyFilter testFilter = new PropertyFilter() {
+ @Override
+ public String filterProperty(String value, FilterContext context) {
+ return context.getKey() + ":testGetSingleFilters";
+ }
+ };
+ ConfigurationFilter.getSingleFilters().addFilter(testFilter);
+ assertEquals("user.home:testGetSingleFilters", config.get("user.home"));
+ ConfigurationFilter.getSingleFilters().removeFilter(testFilter);
+ assertNotSame("user.home:testGetSingleFilters", config.get("user.home"));
}
@Test
- public void testGetSingleFilters() throws Exception {
-// TODO
+ public void testRemoveSingleFiltersAt0() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ assertNotNull(ConfigurationFilter.getSingleFilters());
+ PropertyFilter testFilter = new PropertyFilter() {
+ @Override
+ public String filterProperty(String value, FilterContext context) {
+ return context.getKey() + ":testGetSingleFilters";
+ }
+ };
+ ConfigurationFilter.getSingleFilters().addFilter(testFilter);
+ assertEquals("user.home:testGetSingleFilters", config.get("user.home"));
+ ConfigurationFilter.getSingleFilters().removeFilter(0);
+ assertNotSame("user.home:testGetSingleFilters", config.get("user.home"));
}
@Test
public void testGetMapFilters() throws Exception {
-// TODO
+ Configuration config = ConfigurationProvider.getConfiguration();
+ assertNotNull(ConfigurationFilter.getMapFilters());
+ PropertyFilter testFilter = new PropertyFilter() {
+ @Override
+ public String filterProperty(String value, FilterContext context) {
+ return context.getKey() + ":testGetMapFilters";
+ }
+ };
+ ConfigurationFilter.getMapFilters().addFilter(testFilter);
+ assertEquals("user.home:testGetMapFilters", config.getProperties().get("user.home"));
+ ConfigurationFilter.getSingleFilters().removeFilter(testFilter);
+ assertNotSame("user.home:testGetSingleFilters", config.getProperties().get("user.home"));
}
@Test
- public void testClearFilters() throws Exception {
-// TODO
+ public void testRemoveMapFilterAt0() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ assertNotNull(ConfigurationFilter.getMapFilters());
+ PropertyFilter testFilter = new PropertyFilter() {
+ @Override
+ public String filterProperty(String value, FilterContext context) {
+ return context.getKey() + ":testGetMapFilters";
+ }
+ };
+ ConfigurationFilter.getMapFilters().addFilter(testFilter);
+ assertEquals("user.home:testGetMapFilters", config.getProperties().get("user.home"));
+ ConfigurationFilter.getMapFilters().removeFilter(0);
+ assertNotSame("user.home:testGetSingleFilters", config.getProperties().get("user.home"));
}
@Test
- public void testFilterProperty() throws Exception {
-// TODO
+ public void testClearFilters() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ assertNotNull(ConfigurationFilter.getSingleFilters());
+ PropertyFilter testFilter = new PropertyFilter() {
+ @Override
+ public String filterProperty(String value, FilterContext context) {
+ return context.getKey() + ":testGetSingleFilters";
+ }
+ };
+ ConfigurationFilter.getSingleFilters().addFilter(testFilter);
+ assertEquals("user.home:testGetSingleFilters", config.get("user.home"));
+ ConfigurationFilter.clearFilters();
+ assertNotSame("user.home:testGetSingleFilters", config.get("user.home"));
}
+
}
\ No newline at end of file
[35/50] [abbrv] incubator-tamaya-extensions git commit: Added tests
for filter module. Checked in missing files.
Posted by pl...@apache.org.
Added tests for filter module.
Checked in missing files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/3fffcb09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/3fffcb09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/3fffcb09
Branch: refs/heads/old_master
Commit: 3fffcb09793fc059160117b04ae35d482a6abd1a
Parents: 3cb7f8d
Author: anatole <an...@apache.org>
Authored: Thu Feb 11 20:20:13 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../tamaya/filter/DefaultMetadataFilter.java | 42 ---------------
.../filter/internal/DefaultMetadataFilter.java | 43 +++++++++++++++
.../tamaya/filter/ConfigurationFilterTest.java | 41 ++++++++++++++
.../tamaya/filter/ProgrammableFilterTest.java | 56 ++++++++++++++++++++
.../tamaya/filter/RegexPropertyFilterTest.java | 19 +++++++
5 files changed, 159 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3fffcb09/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java b/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java
deleted file mode 100644
index 389d9fa..0000000
--- a/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java
+++ /dev/null
@@ -1,42 +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.filter;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-/**
- * Default property filter that hides metadta entries starting with an '_', similar ti {@code etcd}.
- */
-public final class DefaultMetadataFilter implements PropertyFilter{
- @Override
- public String filterProperty(String valueToBeFiltered, FilterContext context) {
- if(context.isSinglePropertyScoped()){
- // When accessing keys explicitly, do not hide anything.
- return valueToBeFiltered;
- }
- if(ConfigurationFilter.THREADED_METADATA_FILTERED.get()) {
- if (context.getKey().startsWith("_")) {
- // Hide metadata entries.
- return null;
- }
- }
- return valueToBeFiltered;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3fffcb09/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java b/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
new file mode 100644
index 0000000..1119cba
--- /dev/null
+++ b/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
@@ -0,0 +1,43 @@
+/*
+ * 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.filter.internal;
+
+import org.apache.tamaya.filter.ConfigurationFilter;
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+
+/**
+ * Default property filter that hides metadta entries starting with an '_', similar ti {@code etcd}.
+ */
+public final class DefaultMetadataFilter implements PropertyFilter{
+ @Override
+ public String filterProperty(String valueToBeFiltered, FilterContext context) {
+ if(context.isSinglePropertyScoped()){
+ // When accessing keys explicitly, do not hide anything.
+ return valueToBeFiltered;
+ }
+ if(ConfigurationFilter.THREADED_METADATA_FILTERED.get()) {
+ if (context.getKey().startsWith("_")) {
+ // Hide metadata entries.
+ return null;
+ }
+ }
+ return valueToBeFiltered;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3fffcb09/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java b/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
new file mode 100644
index 0000000..b4f3fa3
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
@@ -0,0 +1,41 @@
+package org.apache.tamaya.filter;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 11.02.16.
+ */
+public class ConfigurationFilterTest {
+
+ @Test
+ public void testIsMetadataFiltered() throws Exception {
+
+ }
+
+ @Test
+ public void testSetMetadataFiltered() throws Exception {
+
+ }
+
+ @Test
+ public void testGetSingleFilters() throws Exception {
+
+ }
+
+ @Test
+ public void testGetMapFilters() throws Exception {
+
+ }
+
+ @Test
+ public void testClearFilters() throws Exception {
+
+ }
+
+ @Test
+ public void testFilterProperty() throws Exception {
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3fffcb09/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java b/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
new file mode 100644
index 0000000..0a30dc4
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
@@ -0,0 +1,56 @@
+package org.apache.tamaya.filter;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 11.02.16.
+ */
+public class ProgrammableFilterTest {
+
+ @Test
+ public void testAddFilter() throws Exception {
+
+ }
+
+ @Test
+ public void testAddFilter1() throws Exception {
+
+ }
+
+ @Test
+ public void testRemoveFilter() throws Exception {
+
+ }
+
+ @Test
+ public void testClearFilters() throws Exception {
+
+ }
+
+ @Test
+ public void testSetFilters() throws Exception {
+
+ }
+
+ @Test
+ public void testSetFilters1() throws Exception {
+
+ }
+
+ @Test
+ public void testGetFilters() throws Exception {
+
+ }
+
+ @Test
+ public void testFilterProperty() throws Exception {
+
+ }
+
+ @Test
+ public void testToString() throws Exception {
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3fffcb09/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java b/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
new file mode 100644
index 0000000..7583a86
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
@@ -0,0 +1,19 @@
+package org.apache.tamaya.filter;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 11.02.16.
+ */
+public class RegexPropertyFilterTest {
+
+ @org.junit.Test
+ public void testFilterProperty() throws Exception {
+
+ }
+
+ @org.junit.Test
+ public void testToString() throws Exception {
+
+ }
+}
\ No newline at end of file
[50/50] [abbrv] incubator-tamaya-extensions git commit: Merge branch
'master' of
https://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions
Posted by pl...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/c641421b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/c641421b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/c641421b
Branch: refs/heads/old_master
Commit: c641421b66cbc7da07ed7c7ef728ffb0691d2afc
Parents: 36011cf 4900aa7
Author: Phil Ottlinger <po...@apache.org>
Authored: Mon Oct 17 20:54:51 2016 +0200
Committer: Phil Ottlinger <po...@apache.org>
Committed: Mon Oct 17 20:54:51 2016 +0200
----------------------------------------------------------------------
.gitignore | 19 ++
dummy | 0
events/pom.xml | 2 -
filter/pom.xml | 81 ++++++++
.../tamaya/filter/ConfigurationFilter.java | 121 ++++++++++++
.../tamaya/filter/ProgrammableFilter.java | 118 ++++++++++++
.../tamaya/filter/RegexPropertyFilter.java | 56 ++++++
.../filter/internal/DefaultMetadataFilter.java | 43 +++++
.../org.apache.tamaya.spi.PropertyFilter | 19 ++
.../tamaya/filter/ConfigurationFilterTest.java | 122 ++++++++++++
.../tamaya/filter/ProgrammableFilterTest.java | 141 ++++++++++++++
.../tamaya/filter/RegexPropertyFilterTest.java | 55 ++++++
json/pom.xml | 147 ++++++++++++++
.../java/org/apache/tamaya/json/JSONFormat.java | 85 +++++++++
.../apache/tamaya/json/JSONPropertySource.java | 149 +++++++++++++++
.../org/apache/tamaya/json/JSONVisitor.java | 119 ++++++++++++
...org.apache.tamaya.format.ConfigurationFormat | 19 ++
.../json/CommonJSONTestCaseCollection.java | 190 +++++++++++++++++++
.../org/apache/tamaya/json/JSONFormatIT.java | 48 +++++
.../org/apache/tamaya/json/JSONFormatTest.java | 75 ++++++++
.../tamaya/json/JSONPropertySourceTest.java | 56 ++++++
json/src/test/resources/arquillian.xml | 30 +++
.../test/resources/configs/invalid/array.json | 21 ++
.../resources/configs/invalid/empty-file.json | 18 ++
.../configs/invalid/only-opening-bracket.json | 19 ++
.../resources/configs/invalid/with-array.json | 27 +++
.../test/resources/configs/valid/cyrillic.json | 22 +++
.../configs/valid/empty-object-config.json | 20 ++
.../valid/simple-flat-string-only-config.json | 23 +++
.../simple-nested-string-only-config-1.json | 27 +++
.../simple-nested-string-only-config-2.json | 26 +++
.../configs/valid/with-explicit-priority.json | 25 +++
32 files changed, 1921 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c641421b/events/pom.xml
----------------------------------------------------------------------
diff --cc events/pom.xml
index fb6c3b3,d274633..0a2de38
--- a/events/pom.xml
+++ b/events/pom.xml
@@@ -94,6 -95,6 +94,4 @@@ under the License
</plugin>
</plugins>
</build>
--
--
</project>
[20/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release 0.2-incubating
Posted by pl...@apache.org.
[maven-release-plugin] prepare release 0.2-incubating
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/8483171e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/8483171e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/8483171e
Branch: refs/heads/old_master
Commit: 8483171e0d7fe838cba5e08e4690cc4ec1b32c7c
Parents: 11f5d50
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 17:39:55 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8483171e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6222349..a59a968 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[09/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release 0.2-incubating
Posted by pl...@apache.org.
[maven-release-plugin] prepare release 0.2-incubating
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/dd25aa8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/dd25aa8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/dd25aa8b
Branch: refs/heads/old_master
Commit: dd25aa8b122b6954f5630ff16338646e76b906bb
Parents: 41e9cf3
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 17:39:55 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/dd25aa8b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4bd0ee4..0fece2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-events</artifactId>
[38/50] [abbrv] incubator-tamaya-extensions git commit: Set new
development version.
Posted by pl...@apache.org.
Set new development version.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/082c36a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/082c36a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/082c36a9
Branch: refs/heads/old_master
Commit: 082c36a9a2d3577f70a619403e71c3683a3bdbda
Parents: a15bd0e
Author: anatole <an...@apache.org>
Authored: Thu Apr 14 00:47:11 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/082c36a9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4f3a981..d43379c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-events</artifactId>
[34/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-136:
Adding PropertyValue for PropertySource SPI. All changes and test fixes in
all modules/examples relevant for release.
Posted by pl...@apache.org.
TAMAYA-136: Adding PropertyValue for PropertySource SPI. All changes and test fixes in all modules/examples relevant for release.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/3cb7f8de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/3cb7f8de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/3cb7f8de
Branch: refs/heads/old_master
Commit: 3cb7f8de5bd875ae38dd5dedd3bf591bbce2de19
Parents: 89223dc
Author: anatole <an...@apache.org>
Authored: Tue Feb 2 17:15:53 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 77 +++++++++++++
.../tamaya/filter/ConfigurationFilter.java | 112 +++++++++++++++++++
.../tamaya/filter/DefaultMetadataFilter.java | 42 +++++++
.../tamaya/filter/ProgrammableFilter.java | 111 ++++++++++++++++++
.../tamaya/filter/RegexPropertyFilter.java | 56 ++++++++++
.../org.apache.tamaya.spi.PropertyFilter | 20 ++++
6 files changed, 418 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3cb7f8de/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2480950
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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>
+ </parent>
+
+ <artifactId>tamaya-filter</artifactId>
+ <name>Apache Tamaya Modules - Adaptive Configuration Filtering</name>
+ <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>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</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.filter,
+ </Export-Package>
+ <!--<Private-Package>-->
+ <!--org.apache.tamaya.events.internal-->
+ <!--</Private-Package>-->
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3cb7f8de/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
new file mode 100644
index 0000000..99ab27f
--- /dev/null
+++ b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
@@ -0,0 +1,112 @@
+/*
+ * 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.filter;
+
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+
+
+/**
+ * Hereby
+ * <ul>
+ * <li><b>Single</b> filters are applied only when values are explicitly accessed. This is useful, e.g. for
+ * filtering passwords into clear text variants. Nevertheless metadata keys hidden on map level must be
+ * accessible (=not filtered) when accessed as single values.</li>
+ * <li><b>Map</b> filters are applied when values are filtered as part of a full properties access.
+ * Often filtering in these cases is more commonly applied, e.g. you dont want to show up all kind of metadata.
+ * </li>
+ * For both variants individual filter rules can be applied here. All filters configured are managed on a
+ * thread-local level, so this class is typically used to temporarely filter out some values. Do not forget to
+ * restore its state, when not using a thread anymore (especially important in multi-threaded environments), not
+ * doing so will create nasty side effects of configuration not being visisble depending on the thread
+ * active.
+ * </ul>
+ */
+public final class ConfigurationFilter implements PropertyFilter{
+
+ static final ThreadLocal<Boolean> THREADED_METADATA_FILTERED = new ThreadLocal<Boolean>(){
+ @Override
+ protected Boolean initialValue() {
+ return Boolean.TRUE;
+ }
+ };
+
+ private static final ThreadLocal<ProgrammableFilter> THREADED_MAP_FILTERS = new ThreadLocal<ProgrammableFilter>(){
+ @Override
+ protected ProgrammableFilter initialValue() {
+ return new ProgrammableFilter();
+ }
+ };
+
+ private static final ThreadLocal<ProgrammableFilter> THREADED_SINGLE_FILTERS = new ThreadLocal<ProgrammableFilter>(){
+ @Override
+ protected ProgrammableFilter initialValue() {
+ return new ProgrammableFilter();
+ }
+ };
+
+ /**
+ * Seactivates metadata filtering also on global map access for this thread.
+ * @see #clearFilters()
+ * @param active true,to enable metadata filtering (default).
+ */
+ public static void setMetadataFilter(boolean active){
+ THREADED_METADATA_FILTERED.set(active);
+ }
+
+ /**
+ * Access the filtering configuration that is used for filtering single property values accessed.
+ * @return the filtering config, never null.
+ */
+ public static ProgrammableFilter getSingleFilters(){
+ return THREADED_SINGLE_FILTERS.get();
+ }
+
+ /**
+ * Access the filtering configuration that is used for filtering configuration properties accessed as full
+ * map.
+ * @return the filtering config, never null.
+ */
+ public static ProgrammableFilter getMapFilters(){
+ return THREADED_MAP_FILTERS.get();
+ }
+
+ /**
+ * Removes all programmable filters active on the current thread.
+ */
+ public static void clearFilters(){
+ THREADED_MAP_FILTERS.get().clearFilters();
+ THREADED_SINGLE_FILTERS.get().clearFilters();
+ THREADED_METADATA_FILTERED.set(true);
+ }
+
+ @Override
+ public String filterProperty(String valueToBeFiltered, FilterContext context) {
+ if(!context.isSinglePropertyScoped()){
+ for(PropertyFilter pred: THREADED_MAP_FILTERS.get().getFilters()){
+ valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
+ }
+ }else{
+ for(PropertyFilter pred: THREADED_SINGLE_FILTERS.get().getFilters()){
+ valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
+ }
+ }
+ return valueToBeFiltered;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3cb7f8de/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java b/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java
new file mode 100644
index 0000000..389d9fa
--- /dev/null
+++ b/src/main/java/org/apache/tamaya/filter/DefaultMetadataFilter.java
@@ -0,0 +1,42 @@
+/*
+ * 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.filter;
+
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+
+/**
+ * Default property filter that hides metadta entries starting with an '_', similar ti {@code etcd}.
+ */
+public final class DefaultMetadataFilter implements PropertyFilter{
+ @Override
+ public String filterProperty(String valueToBeFiltered, FilterContext context) {
+ if(context.isSinglePropertyScoped()){
+ // When accessing keys explicitly, do not hide anything.
+ return valueToBeFiltered;
+ }
+ if(ConfigurationFilter.THREADED_METADATA_FILTERED.get()) {
+ if (context.getKey().startsWith("_")) {
+ // Hide metadata entries.
+ return null;
+ }
+ }
+ return valueToBeFiltered;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3cb7f8de/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java b/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
new file mode 100644
index 0000000..8589faa
--- /dev/null
+++ b/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
@@ -0,0 +1,111 @@
+/*
+ * 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.filter;
+
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A set of property filter and accessor methods.
+ */
+public final class ProgrammableFilter implements PropertyFilter{
+ /** The filters. */
+ private List<PropertyFilter> filters = new ArrayList<>();
+
+ /**
+ * Add a filter.
+ * @param filter the filter.
+ */
+ public void addFilter(PropertyFilter filter){
+ filters.add(filter);
+ }
+
+ /**
+ * Adds a filter at given position.
+ * @param pos the position.
+ * @param filter the filter.
+ */
+ public void addFilter(int pos, PropertyFilter filter){
+ filters.add(pos, filter);
+ }
+
+ /**
+ * Removes a filter at a given position.
+ * @param pos the position.
+ * @return the filter removed, or null.
+ */
+ public PropertyFilter removeFilter(int pos){
+ return filters.remove(pos);
+ }
+
+ /**
+ * Clears all filters.
+ */
+ public void clearFilters(){
+ filters.clear();
+ }
+
+ /**
+ * Set the filters.
+ * @param filters the filters to be applied.
+ */
+ public void setFilters(PropertyFilter... filters){
+ setFilters(Arrays.asList(filters));
+ }
+
+ /**
+ * Set the filters.
+ * @param filters the filters to be applied.
+ */
+ public void setFilters(Collection<PropertyFilter> filters) {
+ filters.clear();
+ filters.addAll(filters);
+ }
+
+ /**
+ * Get all filters.
+ * @return all filters.
+ */
+ public List<PropertyFilter> getFilters(){
+ return Collections.unmodifiableList(filters);
+ }
+
+ @Override
+ public String filterProperty(String valueToBeFiltered, FilterContext context) {
+ for(PropertyFilter filter:filters){
+ valueToBeFiltered = filter.filterProperty(valueToBeFiltered, context);
+ }
+ return valueToBeFiltered;
+ }
+
+ @Override
+ public String toString() {
+ return "FilterConfig{" +
+ "filters=" + filters +
+ '}';
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3cb7f8de/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java b/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
new file mode 100644
index 0000000..616f2cf
--- /dev/null
+++ b/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
@@ -0,0 +1,56 @@
+/*
+ * 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.filter;
+
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
+
+import java.util.Objects;
+
+/**
+ * Predicate filtering using a regex expression operating on the key.
+ */
+public final class RegexPropertyFilter implements PropertyFilter{
+ /** The expression used to filter. */
+ private String expression;
+
+ /**
+ * Creates a new regex filter expression.
+ * @param expression the reged expression, not null.
+ */
+ public RegexPropertyFilter(String expression){
+ this.expression = Objects.requireNonNull(expression);
+ }
+
+ @Override
+ public String filterProperty(String valueToBeFiltered, FilterContext context) {
+ if(context.getKey().matches(expression)){
+ return null;
+ }
+ return valueToBeFiltered;
+ }
+
+ @Override
+ public String toString() {
+ return "RegexPredicate{" +
+ "expression='" + expression + '\'' +
+ '}';
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3cb7f8de/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
new file mode 100644
index 0000000..630c222
--- /dev/null
+++ b/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
@@ -0,0 +1,20 @@
+#
+# 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.filter.ConfigurationFilter
+org.apache.tamaya.filter.DefaultMetadataFilter
\ No newline at end of file
[14/50] [abbrv] incubator-tamaya-extensions git commit: Added
Configuration.getConfigurationContext().
Posted by pl...@apache.org.
Added Configuration.getConfigurationContext().
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/0a9aeae6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/0a9aeae6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/0a9aeae6
Branch: refs/heads/old_master
Commit: 0a9aeae664e531917413043292ae4cf2647aecea
Parents: e5bbbde
Author: anatole <an...@apache.org>
Authored: Mon Mar 14 00:39:53 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/tamaya/events/FrozenConfiguration.java | 7 +++++++
src/test/java/org/apache/tamaya/events/TestConfigView.java | 6 ++++++
2 files changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/0a9aeae6/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
index b874987..304ddba 100644
--- a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
+++ b/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
@@ -24,6 +24,8 @@ import org.apache.tamaya.ConfigQuery;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.functions.ConfigurationFunctions;
+import org.apache.tamaya.spi.ConfigurationContext;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -162,6 +164,11 @@ public final class FrozenConfiguration implements Configuration, Serializable {
}
@Override
+ public ConfigurationContext getContext() {
+ return ConfigurationFunctions.emptyConfigurationContext();
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/0a9aeae6/src/test/java/org/apache/tamaya/events/TestConfigView.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/TestConfigView.java b/src/test/java/org/apache/tamaya/events/TestConfigView.java
index 4f2227a..8e5b397 100644
--- a/src/test/java/org/apache/tamaya/events/TestConfigView.java
+++ b/src/test/java/org/apache/tamaya/events/TestConfigView.java
@@ -24,6 +24,7 @@ import org.apache.tamaya.ConfigQuery;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -73,6 +74,11 @@ public class TestConfigView implements ConfigOperator{
}
@Override
+ public ConfigurationContext getContext() {
+ return config.getContext();
+ }
+
+ @Override
public String get(String key) {
return getProperties().get(key);
}
[41/50] [abbrv] incubator-tamaya-extensions git commit: - Moved UI
module into sandbox,
including UI parts. - Decoupled accordingly existing modules from UI. - Fixed
a few quality issues.
Posted by pl...@apache.org.
- Moved UI module into sandbox, including UI parts.
- Decoupled accordingly existing modules from UI.
- Fixed a few quality issues.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/07d36020
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/07d36020
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/07d36020
Branch: refs/heads/old_master
Commit: 07d360203eac287e8197c534997d21e3abf5b9a5
Parents: 81b05eb
Author: anatole <an...@apache.org>
Authored: Tue Aug 16 15:50:17 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 7 -
.../org/apache/tamaya/events/ui/EventView.java | 181 -------------------
.../services/org.apache.tamaya.ui.ViewProvider | 19 --
src/main/resources/ui/lang/tamaya.properties | 24 ---
.../services/org.apache.tamaya.ui.ViewProvider | 19 --
src/test/resources/config/application.yml | 31 ----
6 files changed, 281 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/07d36020/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7294789..d274633 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,13 +58,6 @@ under the License.
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-ui</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/07d36020/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ui/EventView.java b/src/main/java/org/apache/tamaya/events/ui/EventView.java
deleted file mode 100644
index 2c4dead..0000000
--- a/src/main/java/org/apache/tamaya/events/ui/EventView.java
+++ /dev/null
@@ -1,181 +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.events.ui;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.navigator.View;
-import com.vaadin.navigator.ViewChangeListener;
-import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.ui.UIConstants;
-import org.apache.tamaya.ui.ViewProvider;
-import org.apache.tamaya.ui.components.VerticalSpacedLayout;
-import org.apache.tamaya.ui.services.MessageProvider;
-
-import javax.annotation.Priority;
-import java.util.Date;
-
-/**
- * Tamaya View for observing the current event stream.
- */
-public class EventView extends VerticalSpacedLayout implements View {
-
- /**
- * Provider used to register the view.
- */
- @Priority(20)
- public static final class Provider implements ViewProvider{
-
- @Override
- public ViewLifecycle getLifecycle() {
- return ViewLifecycle.EAGER;
- }
-
- @Override
- public String getName() {
- return "view.events.name";
- }
-
- @Override
- public String getUrlPattern() {
- return "/events";
- }
-
- @Override
- public String getDisplayName() {
- return getName();
- }
-
- @Override
- public View createView(Object... params){
- return new EventView();
- }
- }
-
- private CheckBox changeMonitorEnabled = new CheckBox(ServiceContextManager.getServiceContext()
- .getService(MessageProvider.class).getMessage("view.events.button.enableMonitoring"));
- private Button clearViewButton = new Button(ServiceContextManager.getServiceContext()
- .getService(MessageProvider.class).getMessage("view.events.button.clearView"));
- private TextField pollingInterval = new TextField(ServiceContextManager.getServiceContext()
- .getService(MessageProvider.class).getMessage("view.events.field.pollingInterval"));
- private Table eventsTable = new Table(ServiceContextManager.getServiceContext()
- .getService(MessageProvider.class).getMessage("view.events.table.name"));
-
-
- public EventView() {
- Label caption = new Label(ServiceContextManager.getServiceContext()
- .getService(MessageProvider.class).getMessage("view.events.name"));
- Label description = new Label(ServiceContextManager.getServiceContext()
- .getService(MessageProvider.class).getMessage("view.events.description"),
- ContentMode.HTML);
-
- ConfigEventManager.addListener(new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- addEvent(event);
- }
- });
- changeMonitorEnabled.addValueChangeListener(new Property.ValueChangeListener() {
- @Override
- public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
- ConfigEventManager.enableChangeMonitoring(changeMonitorEnabled.getValue());
- if(changeMonitorEnabled.getValue()) {
- Notification.show("Event Monitoring (Polling) active.");
- }else{
- Notification.show("Event Monitoring (Polling) inactive.");
- }
- }
- });
- clearViewButton.addClickListener(new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent clickEvent) {
- eventsTable.removeAllItems();
- Notification.show("Events cleared.");
- }
- });
-
- HorizontalLayout eventSettings = new HorizontalLayout();
- eventSettings.addComponents(changeMonitorEnabled, new Label(" Polling Interval"), pollingInterval, clearViewButton);
- changeMonitorEnabled.setValue(ConfigEventManager.isChangeMonitoring());
- pollingInterval.setValue(String.valueOf(ConfigEventManager.getChangeMonitoringPeriod()));
- pollingInterval.setRequired(true);
- pollingInterval.addValueChangeListener(new Property.ValueChangeListener() {
- @Override
- public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
- try{
- long millis = Long.parseLong((String)valueChangeEvent.getProperty().getValue());
- ConfigEventManager.setChangeMonitoringPeriod(millis);
- Notification.show("Updated Event Monitoring Poll Interval to " + millis + " milliseconds.");
- }catch(Exception e){
- Notification.show("Cannot update Event Monitoring Poll Interval to "
- + valueChangeEvent.getProperty().getValue(), Notification.Type.ERROR_MESSAGE);
- }
- }
- });
- eventsTable.addContainerProperty("Timestamp", Date.class, null);
- eventsTable.addContainerProperty("Type", String.class, "?");
- eventsTable.addContainerProperty("Payload", String.class, "<empty>");
- eventsTable.addContainerProperty("Version", String.class, "?");
- eventsTable.setPageLength(20);
- eventsTable.setWidth("100%");
- eventsTable.setResponsive(true);
-
-
- caption.addStyleName(UIConstants.LABEL_HUGE);
- description.addStyleName(UIConstants.LABEL_LARGE);
- addComponents(caption, description, eventSettings, eventsTable);
- }
-
- private void addEvent(ConfigEvent<?> evt){
- Object newItemId = eventsTable.addItem();
- Item row = eventsTable.getItem(newItemId);
- row.getItemProperty("Timestamp").setValue(new Date(evt.getTimestamp()));
- row.getItemProperty("Type").setValue(evt.getResourceType().getSimpleName());
- String value = String.valueOf(evt.getResource());
- String valueShort = value.length()<150?value:value.substring(0,147)+"...";
- row.getItemProperty("Payload").setValue(valueShort);
- row.getItemProperty("Version").setValue(evt.getVersion());
- }
-
-
- private String getCaption(String key, String value) {
- int index = key.lastIndexOf('.');
- if(index<0){
- return key + " = " + value;
- }else{
- return key.substring(index+1) + " = " + value;
- }
- }
-
- @Override
- public void enter(ViewChangeListener.ViewChangeEvent event) {
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/07d36020/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider b/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
deleted file mode 100644
index f779d5c..0000000
--- a/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.ui.EventView$Provider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/07d36020/src/main/resources/ui/lang/tamaya.properties
----------------------------------------------------------------------
diff --git a/src/main/resources/ui/lang/tamaya.properties b/src/main/resources/ui/lang/tamaya.properties
deleted file mode 100644
index 8f83a5c..0000000
--- a/src/main/resources/ui/lang/tamaya.properties
+++ /dev/null
@@ -1,24 +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.
-#
-
-view.events.name=Configuration Events
-view.events.table.name=Observed Events
-view.events.button.enableMonitoring=Change Monitor active
-view.events.button.clearView=Clear View
-view.events.description=This view shows the configuration events triggered in the system.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/07d36020/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
----------------------------------------------------------------------
diff --git a/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider b/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
deleted file mode 100644
index f779d5c..0000000
--- a/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.ui.EventView$Provider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/07d36020/src/test/resources/config/application.yml
----------------------------------------------------------------------
diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml
deleted file mode 100644
index 00d6d43..0000000
--- a/src/test/resources/config/application.yml
+++ /dev/null
@@ -1,31 +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.
-#
-server:
- type: default
- maxThreads: 1024
- applicationConnectors:
- - type: http
- port: 8090
- - type: https
- port: 8453
- adminConnectors:
- - type: http
- port: 8091
- - type: https
- port: 8453
\ No newline at end of file
[21/50] [abbrv] incubator-tamaya-extensions git commit: Modulularized
UI module, added multi file based i18n, using config mechanisms.
Posted by pl...@apache.org.
Modulularized UI module, added multi file based i18n, using config mechanisms.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/c7828a4b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/c7828a4b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/c7828a4b
Branch: refs/heads/old_master
Commit: c7828a4b0c75d77f5d4830ec436aecf45424a1ee
Parents: f3d3288
Author: anatole <an...@apache.org>
Authored: Sat Apr 16 08:25:46 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../org/apache/tamaya/events/ui/EventView.java | 134 +++++++++++++++++++
.../services/org.apache.tamaya.ui.ViewProvider | 19 +++
src/main/resources/ui/lang/tamaya.properties | 5 +
.../tamaya/events/RandomPropertySource.java | 48 +++++++
.../org.apache.tamaya.spi.PropertySource | 19 +++
.../services/org.apache.tamaya.ui.ViewProvider | 19 +++
src/test/resources/config/application.yml | 13 ++
7 files changed, 257 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ui/EventView.java b/src/main/java/org/apache/tamaya/events/ui/EventView.java
new file mode 100644
index 0000000..a69b04c
--- /dev/null
+++ b/src/main/java/org/apache/tamaya/events/ui/EventView.java
@@ -0,0 +1,134 @@
+/*
+ * 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.events.ui;
+
+import com.vaadin.data.Property;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.ui.*;
+import org.apache.tamaya.events.ConfigEvent;
+import org.apache.tamaya.events.ConfigEventListener;
+import org.apache.tamaya.events.ConfigEventManager;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.ui.UIConstants;
+import org.apache.tamaya.ui.ViewProvider;
+import org.apache.tamaya.ui.components.VerticalSpacedLayout;
+import org.apache.tamaya.ui.services.MessageProvider;
+
+import javax.annotation.Priority;
+
+
+public class EventView extends VerticalSpacedLayout implements View {
+
+ @Priority(20)
+ public static final class Provider implements ViewProvider{
+
+ @Override
+ public ViewLifecycle getLifecycle() {
+ return ViewLifecycle.EAGER;
+ }
+
+ @Override
+ public String getUrlPattern() {
+ return "/events";
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "view.events.name";
+ }
+
+ @Override
+ public View createView(){
+ return new EventView();
+ }
+ }
+
+ private CheckBox changeMonitorEnabled = new CheckBox(ServiceContextManager.getServiceContext()
+ .getService(MessageProvider.class).getMessage("view.events.button.enableMonitoring"));
+ private Button clearViewButton = new Button(ServiceContextManager.getServiceContext()
+ .getService(MessageProvider.class).getMessage("view.events.button.clearView"));
+ private Table eventsTable = new Table(ServiceContextManager.getServiceContext()
+ .getService(MessageProvider.class).getMessage("view.events.table.name"));
+
+
+ public EventView() {
+ Label caption = new Label(ServiceContextManager.getServiceContext()
+ .getService(MessageProvider.class).getMessage("view.events.name"));
+ Label description = new Label(ServiceContextManager.getServiceContext()
+ .getService(MessageProvider.class).getMessage("view.events.description"),
+ ContentMode.HTML);
+
+ ConfigEventManager.addListener(new ConfigEventListener() {
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ addEvent(event);
+ }
+ });
+ changeMonitorEnabled.addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
+ ConfigEventManager.enableChangeMonitoring(changeMonitorEnabled.getValue());
+ }
+ });
+ clearViewButton.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent clickEvent) {
+ eventsTable.removeAllItems();
+ }
+ });
+
+ changeMonitorEnabled.setData(ConfigEventManager.isChangeMonitoring());
+ eventsTable.addContainerProperty("Timestamp", Long.class, null);
+ eventsTable.addContainerProperty("Type", Class.class, null);
+ eventsTable.addContainerProperty("Payload", String.class, null);
+ eventsTable.addContainerProperty("Version", String.class, null);
+ eventsTable.setPageLength(20);
+ eventsTable.setWidth("100%");
+ eventsTable.setResponsive(true);
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.addComponents(changeMonitorEnabled, clearViewButton);
+ caption.addStyleName(UIConstants.LABEL_HUGE);
+ description.addStyleName(UIConstants.LABEL_LARGE);
+ addComponents(caption, description, hl, eventsTable);
+ }
+
+ private void addEvent(ConfigEvent<?> evt){
+ eventsTable.addItem(new Object[]{evt.getTimestamp(), evt.getResourceType().getSimpleName(),
+ String.valueOf(evt.getResource()),evt.getVersion()});
+ this.markAsDirty();
+ }
+
+
+ private String getCaption(String key, String value) {
+ int index = key.lastIndexOf('.');
+ if(index<0){
+ return key + " = " + value;
+ }else{
+ return key.substring(index+1) + " = " + value;
+ }
+ }
+
+ @Override
+ public void enter(ViewChangeListener.ViewChangeEvent event) {
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider b/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
new file mode 100644
index 0000000..f779d5c
--- /dev/null
+++ b/src/main/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
@@ -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.events.ui.EventView$Provider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/main/resources/ui/lang/tamaya.properties
----------------------------------------------------------------------
diff --git a/src/main/resources/ui/lang/tamaya.properties b/src/main/resources/ui/lang/tamaya.properties
new file mode 100644
index 0000000..37ca420
--- /dev/null
+++ b/src/main/resources/ui/lang/tamaya.properties
@@ -0,0 +1,5 @@
+view.events.name=Configuration Events
+view.events.table.name=Observed Events
+view.events.button.enableMonitoring=Change Monitor active
+view.events.button.clearView=Clear View
+view.events.description=This view shows the configuration events triggered in the system.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/RandomPropertySource.java b/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
new file mode 100644
index 0000000..f32ead7
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
@@ -0,0 +1,48 @@
+package org.apache.tamaya.events;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PropertySource that provides a randome entry, different on each access!
+ */
+public class RandomPropertySource implements PropertySource{
+
+ private Map<String, String> data = new HashMap<>();
+
+ @Override
+ public int getOrdinal() {
+ return 0;
+ }
+
+ @Override
+ public String getName() {
+ return "random";
+ }
+
+ @Override
+ public PropertyValue get(String key) {
+ if(key.equals("random.new")){
+ return PropertyValue.of(key, String.valueOf(Math.random()),getName());
+ }
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ synchronized(data) {
+ data.put("random.new", String.valueOf(Math.random()));
+ data.put("_random.new.source", getName());
+ data.put("_random.new.timestamp", String.valueOf(System.currentTimeMillis()));
+ return new HashMap<>(data);
+ }
+ }
+
+ @Override
+ public boolean isScannable() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
new file mode 100644
index 0000000..9c2b9f6
--- /dev/null
+++ b/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -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.events.RandomPropertySource
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
----------------------------------------------------------------------
diff --git a/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider b/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
new file mode 100644
index 0000000..f779d5c
--- /dev/null
+++ b/src/test/resources/META-INF/services/org.apache.tamaya.ui.ViewProvider
@@ -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.events.ui.EventView$Provider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c7828a4b/src/test/resources/config/application.yml
----------------------------------------------------------------------
diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml
new file mode 100644
index 0000000..9ec8d5b
--- /dev/null
+++ b/src/test/resources/config/application.yml
@@ -0,0 +1,13 @@
+server:
+ type: default
+ maxThreads: 1024
+ applicationConnectors:
+ - type: http
+ port: 8090
+ - type: https
+ port: 8453
+ adminConnectors:
+ - type: http
+ port: 8091
+ - type: https
+ port: 8453
\ No newline at end of file
[28/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-172:
Fixed invalid comparison of PropertyValue with String.
Posted by pl...@apache.org.
TAMAYA-172: Fixed invalid comparison of PropertyValue with String.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/9bf98feb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/9bf98feb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/9bf98feb
Branch: refs/heads/old_master
Commit: 9bf98feb72ea54e154e6614d6972fe1f8185a6f4
Parents: 6710cec
Author: anatole <an...@apache.org>
Authored: Sun Sep 11 22:16:07 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/tamaya/events/PropertySourceChangeBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/9bf98feb/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
index fa2cf5e..b7a4483 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -99,7 +99,7 @@ public final class PropertySourceChangeBuilder {
PropertyValue val = map2.get(en.getKey());
if (val == null) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.equals(en.getValue())) {
+ } else if (!val.getValue().equals(en.getValue())) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue()));
}
}
[16/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release tamaya-all-0.2-incubating
Posted by pl...@apache.org.
[maven-release-plugin] prepare release tamaya-all-0.2-incubating
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/64c43de4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/64c43de4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/64c43de4
Branch: refs/heads/old_master
Commit: 64c43de418bdbc802aeff04b82376202da4ed98c
Parents: 8fb49b7
Author: anatole <an...@apache.org>
Authored: Wed Mar 16 16:20:07 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/64c43de4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0535316..4f3a981 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-events</artifactId>
[40/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare for next development iteration
Posted by pl...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/ee432435
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/ee432435
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/ee432435
Branch: refs/heads/old_master
Commit: ee43243571416c8f6d402758bb795b7cff5645c5
Parents: 8483171
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 17:40:05 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/ee432435/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a59a968..d9d4854 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[19/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release vote02-tamaya-0.2-incubating
Posted by pl...@apache.org.
[maven-release-plugin] prepare release vote02-tamaya-0.2-incubating
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/a15bd0e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/a15bd0e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/a15bd0e5
Branch: refs/heads/old_master
Commit: a15bd0e59206f0d7125ecec28f873f11f22663a9
Parents: c5a7508
Author: anatole <an...@apache.org>
Authored: Tue Apr 5 18:56:54 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a15bd0e5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0535316..4f3a981 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-events</artifactId>
[31/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-175
Moved the events module to the directory events after extracting it for the
Tamaya main repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java b/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
new file mode 100644
index 0000000..b20ebef
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
@@ -0,0 +1,163 @@
+/*
+ * 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.events.delta;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.events.ConfigurationChange;
+import org.apache.tamaya.events.ConfigurationChangeBuilder;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test class for {@link ConfigurationChange}.
+ */
+public class ConfigurationChangeTest {
+
+ @Test
+ public void testEmptyChangeSet() throws Exception {
+ ConfigurationChange change = ConfigurationChange.emptyChangeSet(ConfigurationProvider.getConfiguration());
+ assertNotNull(change);
+ assertTrue(change.isEmpty());
+ }
+
+ @Test
+ public void testGetConfiguration() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
+ assertNotNull(change);
+ assertTrue(change.getUpdatedSize()==0);
+ assertTrue(change.getAddedSize()==0);
+ assertTrue(change.getRemovedSize()==0);
+ assertTrue(change.getChanges().size()==0);
+ for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
+ if (!"[meta]frozenAt".equals(en.getKey())) {
+ if(en.getKey().contains("random.new")){ // dynamic generated value!
+ continue;
+ }
+ assertEquals("Error for " + en.getKey(), en.getValue(), change.getResource().get(en.getKey()));
+ }
+ }
+ }
+
+ @Test
+ public void testGetVersion() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
+ assertNotNull(change.getVersion());
+ change = ConfigurationChangeBuilder.of(config).setVersion("version2").build();
+ assertNotNull(change.getVersion());
+ assertEquals("version2", change.getVersion());
+ }
+
+ @Test
+ public void testGetTimestamp() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
+ assertTrue((System.currentTimeMillis() - change.getTimestamp()) <= 10L);
+ change = ConfigurationChangeBuilder.of(config).setTimestamp(10L).build();
+ assertEquals(10L, change.getTimestamp());
+ }
+
+ @Test
+ public void testGetEvents() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("key1", "key2").build();
+ assertTrue(change.getChanges().size() == 2);
+ change = ConfigurationChangeBuilder.of(config).addChange("key1Added", "value1Added").build();
+ assertTrue(change.getChanges().size() == 1);
+ }
+
+ @Test
+ public void testGetRemovedSize() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("java.version", "key2").build();
+ assertTrue(change.getRemovedSize() == 2);
+ assertTrue(change.getAddedSize() == 0);
+ }
+
+ @Test
+ public void testGetAddedSize() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
+ assertTrue(change.getAddedSize() == 1);
+ assertTrue(change.getRemovedSize() == 0);
+ }
+
+ @Test
+ public void testGetUpdatedSize() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("java.version", "1.8").build();
+ assertTrue(change.getUpdatedSize() == 1);
+ }
+
+ @Test
+ public void testIsRemoved() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
+ assertTrue(change.isRemoved("java.version"));
+ }
+
+ @Test
+ public void testIsAdded() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
+ assertTrue(change.isAdded("key1"));
+ }
+
+ @Test
+ public void testIsUpdated() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("java.version", "1.8").build();
+ assertTrue(change.isUpdated("java.version"));
+ }
+
+ @Test
+ public void testContainsKey() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
+ assertTrue(change.isKeyAffected("key1"));
+ assertFalse(change.isKeyAffected("key2"));
+ change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
+ assertFalse(change.isKeyAffected("java.version"));
+ assertFalse(change.isKeyAffected("key2"));
+ }
+
+ @Test
+ public void testIsEmpty() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
+ assertTrue(change.isEmpty());
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
+ change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
+ assertTrue(change.toString().contains("timestamp"));
+ assertTrue(change.toString().contains("version"));
+ assertTrue(change.toString().contains("configuration"));
+ assertFalse(change.toString().contains("key1"));
+ assertFalse(change.toString().contains("key2"));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java b/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
new file mode 100644
index 0000000..ee631ce
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
@@ -0,0 +1,138 @@
+/*
+ * 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.events.delta;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.events.ChangeType;
+import org.apache.tamaya.events.ConfigurationContextChange;
+import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
+import org.apache.tamaya.events.PropertySourceChangeBuilder;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test class for {@link ConfigurationContextChange}.
+ */
+public class ConfigurationContextChangeTest {
+
+ @Test
+ public void testEmptyChangeSet() throws Exception {
+ ConfigurationContextChange change = ConfigurationContextChange.emptyChangeSet(
+ ConfigurationProvider.getConfigurationContext());
+ assertNotNull(change);
+ assertTrue(change.isEmpty());
+ }
+
+ @Test
+ public void testGetVersion() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertNotNull(change.getVersion());
+ change = ConfigurationContextChangeBuilder.of().setVersion("version2").build();
+ assertNotNull(change.getVersion());
+ assertEquals("version2", change.getVersion());
+ }
+
+ @Test
+ public void testGetTimestamp() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue((System.currentTimeMillis() - change.getTimestamp()) <= 10L);
+ change = ConfigurationContextChangeBuilder.of().setTimestamp(10L).build();
+ assertEquals(10L, change.getTimestamp());
+ }
+
+ @Test
+ public void testGetPropertySourceChanges() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceChanges(). isEmpty());
+ change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceChanges(). isEmpty());
+ }
+
+ @Test
+ public void testGetPropertySourceUpdates() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceChanges(). isEmpty());
+ change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceUpdates(). isEmpty());
+ }
+
+ @Test
+ public void testGetRemovedPropertySources() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceChanges(). isEmpty());
+ change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getRemovedPropertySources(). isEmpty());
+ }
+
+ @Test
+ public void testGetAddedPropertySources() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceChanges(). isEmpty());
+ change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getAddedPropertySources().isEmpty());
+ }
+
+ @Test
+ public void testGetUpdatedPropertySources() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getPropertySourceChanges(). isEmpty());
+ change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.getUpdatedPropertySources().isEmpty());
+ }
+
+ @Test
+ public void testIsAffected() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ PropertySource ps = new SystemPropertySource();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().changedPropertySource(
+ PropertySourceChangeBuilder.of(ps, ChangeType.UPDATED).build()
+ ).build();
+ String toString = change.toString();
+ assertTrue(change.isAffected(ps));
+ }
+
+ @Test
+ public void testIsEmpty() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
+ assertTrue(change.isEmpty());
+ change = ConfigurationContextChangeBuilder.of().newPropertySource(new SystemPropertySource()).build();
+ assertFalse(change.isEmpty());
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().newPropertySource(new SystemPropertySource()).build();
+ String toString = change.toString();
+ assertNotNull(toString);
+ assertTrue(toString.contains(new SystemPropertySource().getName()));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java b/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
new file mode 100644
index 0000000..0dcdfba
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
@@ -0,0 +1,209 @@
+/*
+ * 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.events.delta;
+
+import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
+import org.apache.tamaya.core.propertysource.SimplePropertySource;
+import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.events.ChangeType;
+import org.apache.tamaya.events.PropertySourceChange;
+import org.apache.tamaya.events.PropertySourceChangeBuilder;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link PropertySourceChange} and its builder.
+ */
+public class PropertySourceChangeTest {
+
+ private static final PropertySource myPS = new SystemPropertySource();
+
+ @Test
+ public void testGetChangeType() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED).build();
+ assertEquals(change.getChangeType(), ChangeType.DELETED);
+ change = PropertySourceChangeBuilder.of(myPS, ChangeType.UPDATED).build();
+ assertEquals(change.getChangeType(), ChangeType.UPDATED);
+ }
+
+ @Test
+ public void testGetPropertySource() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED).build();
+ assertEquals(change.getResource().getName(), myPS.getName());
+ }
+
+ @Test
+ public void testGetVersion() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
+ .setVersion("myVersion1").build();
+ assertEquals(change.getVersion(), "myVersion1");
+ }
+
+ @Test
+ public void testGetTimestamp() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
+ .setTimestamp(111L).build();
+ assertEquals(change.getTimestamp(), 111L);
+ }
+
+ @Test
+ public void testGetEvents() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
+ .addChanges(
+ new EnvironmentPropertySource()
+ ).build();
+ assertTrue(change.getChanges().size()>0);
+ }
+
+ @Test
+ public void testGetRemovedSize() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.UPDATED)
+ .addChanges(
+ new EnvironmentPropertySource()
+ ).build();
+ assertTrue(change.getRemovedSize()>0);
+ }
+
+ @Test
+ public void testGetAddedSize() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
+ .addChanges(
+ new EnvironmentPropertySource()
+ ).build();
+ assertTrue(change.getAddedSize()>0);
+ }
+
+ @Test
+ public void testGetUpdatedSize() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
+ .addChanges(
+ new EnvironmentPropertySource()
+ ).build();
+ assertTrue(change.getUpdatedSize()==0);
+ }
+
+ @Test
+ public void testIsRemoved() throws Exception {
+ Map<String, String> testData = new HashMap<>();
+ testData.put("key1", "value1");
+ testData.put("key2", "value2");
+ PropertySource ps1 = new SimplePropertySource("test", testData);
+ testData = new HashMap<>();
+ testData.put("key1", "value2");
+ testData.put("key3", "value3");
+ PropertySource ps2 = new SimplePropertySource("test", testData);
+ PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
+ .addChanges(
+ ps2
+ ).build();
+ assertFalse(change.isRemoved("key1"));
+ assertTrue(change.isRemoved("key2"));
+ assertFalse(change.isRemoved("key3"));
+ }
+
+ @Test
+ public void testIsAdded() throws Exception {
+ Map<String, String> testData = new HashMap<>();
+ testData.put("key1", "value1");
+ testData.put("key2", "value2");
+ PropertySource ps1 = new SimplePropertySource("test", testData);
+ testData = new HashMap<>();
+ testData.put("key1", "value2");
+ testData.put("key3", "value3");
+ PropertySource ps2 = new SimplePropertySource("test", testData);
+ PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
+ .addChanges(
+ ps2
+ ).build();
+ assertTrue(change.isAdded("key3"));
+ assertFalse(change.isAdded("key2"));
+ assertFalse(change.isAdded("key1"));
+ }
+
+ @Test
+ public void testIsUpdated() throws Exception {
+ Map<String, String> testData = new HashMap<>();
+ testData.put("key1", "value1");
+ testData.put("key2", "value2");
+ PropertySource ps1 = new SimplePropertySource("test", testData);
+ testData = new HashMap<>();
+ testData.put("key1", "value2");
+ testData.put("key3", "value3");
+ PropertySource ps2 = new SimplePropertySource("test", testData);
+ PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
+ .addChanges(
+ ps2
+ ).build();
+ assertTrue(change.isUpdated("key1"));
+ assertFalse(change.isUpdated("key2"));
+ assertFalse(change.isUpdated("key3"));
+ }
+
+ @Test
+ public void testContainsKey() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
+ .addChanges(
+ myPS
+ ).build();
+ assertTrue(change.isKeyAffected("java.version"));
+ }
+
+ @Test
+ public void testIsEmpty() throws Exception {
+ PropertySourceChange change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
+ .build();
+ assertTrue(change.isEmpty());
+ change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
+ .addChanges(
+ myPS
+ ).build();
+ assertFalse(change.isEmpty());
+ }
+
+ @Test
+ public void testOfAdded() throws Exception {
+ PropertySourceChange change = PropertySourceChange.ofAdded(myPS);
+ assertNotNull(change);
+ assertEquals(change.getChangeType(), ChangeType.NEW);
+ }
+
+ @Test
+ public void testOfDeleted() throws Exception {
+ PropertySourceChange change = PropertySourceChange.ofDeleted(myPS);
+ assertNotNull(change);
+ assertEquals(change.getChangeType(), ChangeType.DELETED);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ PropertySourceChange change = PropertySourceChange.ofAdded(myPS);
+ String toString = change.toString();
+ assertNotNull(toString);
+ assertTrue(toString.contains(myPS.getName()));
+ change = PropertySourceChange.ofDeleted(myPS);
+ toString = change.toString();
+ assertNotNull(toString);
+ assertTrue(toString.contains(myPS.getName()));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java b/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
new file mode 100644
index 0000000..d54a66e
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.events.internal;
+
+import org.apache.tamaya.events.ConfigEvent;
+import org.apache.tamaya.events.ConfigEventListener;
+import org.apache.tamaya.events.SimpleEvent;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link DefaultConfigEventManagerSpi}.
+ */
+public class DefaultConfigEventManagerSpiTest {
+
+ private final DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi();
+ private Object testAddListenerValue;
+
+ @Test
+ public void testAddListener() throws Exception {
+ ConfigEventListener testListener = new ConfigEventListener() {
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ testAddListenerValue = event.getResource();
+ }
+ };
+ spi.addListener(testListener);
+ spi.fireEvent(new SimpleEvent("Event1"));
+ assertEquals(testAddListenerValue, "Event1");
+ spi.removeListener(testListener);
+ spi.fireEvent(new SimpleEvent("Event2"));
+ assertEquals(testAddListenerValue, "Event1");
+
+ }
+
+ @Test
+ public void testRemoveListener() throws Exception {
+ ConfigEventListener testListener = new ConfigEventListener() {
+
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ testAddListenerValue = event;
+ }
+ };
+ spi.removeListener(testListener);
+ spi.removeListener(testListener);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
new file mode 100644
index 0000000..f675fd6
--- /dev/null
+++ b/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
@@ -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.events.internal.DefaultConfigurationContextChangeListener
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
new file mode 100644
index 0000000..9c2b9f6
--- /dev/null
+++ b/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -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.events.RandomPropertySource
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
new file mode 100644
index 0000000..d34b4a2
--- /dev/null
+++ b/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
@@ -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.events.TestObservingProvider
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/data/test1.properties
----------------------------------------------------------------------
diff --git a/events/src/test/resources/data/test1.properties b/events/src/test/resources/data/test1.properties
new file mode 100644
index 0000000..0df3bd1
--- /dev/null
+++ b/events/src/test/resources/data/test1.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+1=val1
+3=val3
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/data/test1b.properties
----------------------------------------------------------------------
diff --git a/events/src/test/resources/data/test1b.properties b/events/src/test/resources/data/test1b.properties
new file mode 100644
index 0000000..ec57163
--- /dev/null
+++ b/events/src/test/resources/data/test1b.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+1b=val1
+7=val7
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/data/test2.properties
----------------------------------------------------------------------
diff --git a/events/src/test/resources/data/test2.properties b/events/src/test/resources/data/test2.properties
new file mode 100644
index 0000000..0643c1d
--- /dev/null
+++ b/events/src/test/resources/data/test2.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+4=val4
+6=val6
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/data/test3.properties
----------------------------------------------------------------------
diff --git a/events/src/test/resources/data/test3.properties b/events/src/test/resources/data/test3.properties
new file mode 100644
index 0000000..bb856c7
--- /dev/null
+++ b/events/src/test/resources/data/test3.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+2=val2
+5=val5
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/events/src/test/resources/test.properties b/events/src/test/resources/test.properties
new file mode 100644
index 0000000..af06631
--- /dev/null
+++ b/events/src/test/resources/test.properties
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+testValue1=value
+test=test2
+a=b
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index d274633..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-events</artifactId>
- <name>Apache Tamaya Modules - Event and dynamic Update Extensions</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <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-functions</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</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </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.events,
- org.apache.tamaya.events.delta,
- org.apache.tamaya.events.folderobserver,
- org.apache.tamaya.events.spi
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.events.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ChangeType.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ChangeType.java b/src/main/java/org/apache/tamaya/events/ChangeType.java
deleted file mode 100644
index 2059017..0000000
--- a/src/main/java/org/apache/tamaya/events/ChangeType.java
+++ /dev/null
@@ -1,31 +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.events;
-
-/**
- * Enum describing the type of configuration change.
- */
-public enum ChangeType {
- /** Configuration hase been added. */
- NEW,
- /** Configuration hase been removed. */
- DELETED,
- /** Configuration hase been changed. */
- UPDATED,
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigEvent.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEvent.java b/src/main/java/org/apache/tamaya/events/ConfigEvent.java
deleted file mode 100644
index 5a713d7..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigEvent.java
+++ /dev/null
@@ -1,55 +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.events;
-
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * @param <T> the resource type.
- */
-public interface ConfigEvent<T>{
-
- /**
- * Access the type of resource. This allows to easily determine the resource an event wants to observe.
- * @return the resource type.
- */
- Class<T> getResourceType();
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, never null.
- */
- T getResource();
-
- /**
- * Get the version relative to the observed resource. The version is required to be unique for
- * each change emmitted for a resource. There is no further requirement how this uniqueness is
- * modelled, so returning a UUID is a completely valid strategy.
- * @return the base version.
- */
- String getVersion();
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- long getTimestamp();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventListener.java b/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
deleted file mode 100644
index 7fb32c8..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
+++ /dev/null
@@ -1,31 +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.events;
-
-/**
- * Interface to be implemented for listening on changes on {@link org.apache.tamaya.Configuration} instances.
- */
-public interface ConfigEventListener {
- /**
- * Called if an event occurred.
- * @param event the event, not null.
- */
- void onConfigEvent(ConfigEvent<?> event);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
deleted file mode 100644
index f6bd3da..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ /dev/null
@@ -1,186 +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.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.Collection;
-
-/**
- * Singleton accessor for accessing the event support component that distributes change events of
- * {@link org.apache.tamaya.spi.PropertySource} and {@link org.apache.tamaya.Configuration}.
- */
-public final class ConfigEventManager {
- /**
- * The backing SPI.
- */
- private static final ConfigEventManagerSpi SPI = ServiceContextManager.getServiceContext()
- .getService(ConfigEventManagerSpi.class);
-
- /**
- * Private singleton constructor.
- */
- private ConfigEventManager() {
- }
-
- /**
- * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
- * @param l the listener not null.
- */
- public static void addListener(ConfigEventListener l) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.addListener(l);
- }
-
- /**
- * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
- * @param <T> the type of the event.
- * @param l the listener not null.
- * @param eventType the event type to which this listener listens to.
- */
- public static <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.addListener(l);
- }
-
- /**
- * Removes a listener registered globally.
- *
- * @param l the listener not null.
- */
- public static void removeListener(ConfigEventListener l) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.removeListener(l);
- }
-
- /**
- * Removes a listener registered for the given event type.
- *
- * @param <T> the type of the event.
- * @param l the listener, not null.
- * @param eventType the event type to which this listener listens to.
- */
- public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.removeListener(l);
- }
-
- /**
- * Access all registered ConfigEventListeners listening to a given event type.
- * @param type the event type
- * @param <T> type param
- * @return a list with the listeners found, never null.
- */
- public static <T extends ConfigEvent>
- Collection<? extends ConfigEventListener> getListeners(Class<T> type) {
- return SPI.getListeners(type);
- }
-
- /**
- * Access all registered ConfigEventListeners listening to a all kind of event types globally.
- *
- * @param <T> the type of the event.
- * @return a list with the listeners found, never null.
- */
- public static <T extends ConfigEvent>
- Collection<? extends ConfigEventListener> getListeners() {
- return SPI.getListeners();
- }
-
- /**
- * Publishes a {@link ConfigurationChange} synchronously to all interested listeners.
- *
- * @param <T> the type of the event.
- * @param event the event, not null.
- */
- public static <T> void fireEvent(ConfigEvent<?> event) {
- SPI.fireEvent(event);
- }
-
- /**
- * Publishes a {@link ConfigurationChange} asynchronously/multithreaded to all interested listeners.
- *
- * @param <T> the type of the event.
- * @param event the event, not null.
- */
- public static <T> void fireEventAsynch(ConfigEvent<?> event) {
- SPI.fireEventAsynch(event);
- }
-
- /**
- * Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and trigger ConfigurationChange events if something changed. This is quite handy for publishing
- * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotely. For handling corresponding {@link ConfigEventListener} have
- * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
- *
- * @param enable whether to enable or disable the change monitoring.
- *
- * @see #isChangeMonitoring()
- * @see #getChangeMonitoringPeriod()
- */
- public static void enableChangeMonitoring(boolean enable) {
- SPI.enableChangeMonitor(enable);
- }
-
- /**
- * Check if the observer is running currently.
- *
- * @return true, if the change monitoring service is currently running.
- * @see #enableChangeMonitoring(boolean)
- */
- public static boolean isChangeMonitoring() {
- return SPI.isChangeMonitorActive();
- }
-
- /**
- * Get the current check period to check for configuration changes.
- *
- * @return the check period in ms.
- */
- public static long getChangeMonitoringPeriod(){
- return SPI.getChangeMonitoringPeriod();
- }
-
- /**
- * Sets the current monitoring period and restarts the monitor. You still have to enable the monitor if
- * it is currently not enabled.
- * @param millis the monitoring period in ms.
- * @see #enableChangeMonitoring(boolean)
- * @see #isChangeMonitoring()
- */
- public static void setChangeMonitoringPeriod(long millis){
- SPI.setChangeMonitoringPeriod(millis);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
deleted file mode 100644
index c31cda2..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
+++ /dev/null
@@ -1,218 +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.events;
-
-import org.apache.tamaya.Configuration;
-
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class ConfigurationChange implements ConfigEvent<Configuration>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final FrozenConfiguration configuration;
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The recorded changes. */
- private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
-
- /**
- * Get an empty change set for the given provider.
- * @param configuration The configuration changed, not null.
- * @return an empty ConfigurationChangeSet instance.
- */
- public static ConfigurationChange emptyChangeSet(Configuration configuration){
- return ConfigurationChangeBuilder.of(configuration).build();
- }
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- ConfigurationChange(ConfigurationChangeBuilder builder) {
- this.configuration = FrozenConfiguration.of(builder.source);
- for(PropertyChangeEvent ev:builder.delta.values()){
- this.changes.put(ev.getPropertyName(), ev);
- }
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- }
-
- @Override
- public Class<Configuration> getResourceType() {
- return Configuration.class;
- }
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, never null.
- */
- @Override
- public Configuration getResource(){
- return this.configuration;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertyChangeEvent> getChanges(){
- return Collections.unmodifiableCollection(this.changes.values());
- }
-
- /**
- * Access the number current removed entries.
- * @return the number current removed entries.
- */
- public int getRemovedSize() {
- int removedCount = 0;
- for(PropertyChangeEvent ev:this.changes.values()){
- if(ev.getNewValue() == null){
- removedCount++;
- }
- }
- return removedCount;
- }
-
- /**
- * Access the number current added entries.
- * @return the number current added entries.
- */
- public int getAddedSize() {
- int addedCount = 0;
- for(PropertyChangeEvent ev:this.changes.values()){
- if(ev.getOldValue() == null &&
- ev.getNewValue() != null){
- addedCount++;
- }
- }
- return addedCount;
- }
-
- /**
- * Access the number current updated entries.
- * @return the number current updated entries.
- */
- public int getUpdatedSize() {
- int updatedCount = 0;
- for(PropertyChangeEvent ev:this.changes.values()){
- if( ev.getOldValue()!=null && ev.getNewValue()!=null){
- updatedCount++;
- }
- }
- return updatedCount;
- }
-
-
- /**
- * Checks if the given key was removed.
- * @param key the target key, not null.
- * @return true, if the given key was removed.
- */
- public boolean isRemoved(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() == null;
- }
-
- /**
- * Checks if the given key was added.
- * @param key the target key, not null.
- * @return true, if the given key was added.
- */
- public boolean isAdded(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() == null;
- }
-
- /**
- * Checks if the given key was updated.
- * @param key the target key, not null.
- * @return true, if the given key was updated.
- */
- public boolean isUpdated(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() != null && change.getNewValue() != null;
- }
-
- /**
- * Checks if the given key is added, or updated AND NOT removed.
- * @param key the target key, not null.
- * @return true, if the given key was added, or updated BUT NOT removed.
- */
- public boolean isKeyAffected(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() != null;
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changes.isEmpty();
- }
-
-
- @Override
- public String toString() {
- return "ConfigurationChange{" +
- "configuration=" + configuration +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
deleted file mode 100644
index 1fd228a..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
+++ /dev/null
@@ -1,274 +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.events;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
- * <ol>
- * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- * change, its only the data of the property source).</li>
- * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class ConfigurationChangeBuilder {
- /**
- * The recorded changes.
- */
- final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
- /**
- * The underlying configuration/provider.
- */
- final Configuration source;
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- /**
- * Constructor.
- *
- * @param configuration the underlying configuration, not null.
- */
- private ConfigurationChangeBuilder(Configuration configuration) {
- this.source = Objects.requireNonNull(configuration);
- }
-
- /**
- * Creates a new instance current this builder using the current COnfiguration as root resource.
- *
- * @return the builder for chaining.
- */
- public static ConfigurationChangeBuilder of() {
- return new ConfigurationChangeBuilder(ConfigurationProvider.getConfiguration());
- }
-
- /**
- * Creates a new instance current this builder.
- *
- * @param configuration the configuration changed, not null.
- * @return the builder for chaining.
- */
- public static ConfigurationChangeBuilder of(Configuration configuration) {
- return new ConfigurationChangeBuilder(configuration);
- }
-
- /**
- * Compares the two property config/configurations and creates a collection current all changes
- * that must be appied to render {@code map1} into {@code map2}.
- *
- * @param map1 the source map, not null.
- * @param map2 the target map, not null.
- * @return a collection current change events, never null.
- */
- public static Collection<PropertyChangeEvent> compare(Configuration map1, Configuration map2) {
- List<PropertyChangeEvent> changes = new ArrayList<>();
- for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
- String val = map2.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
- }
- }
- for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
- String val = map1.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
- }
- }
- return changes;
- }
-
- /*
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /*
- * Apply given timestamp to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param newState the new target state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder addChanges(Configuration newState) {
- for (PropertyChangeEvent c : compare(newState, this.source)) {
- this.delta.put(c.getPropertyName(), c);
- }
- return this;
- }
-
- /**
- * Applies a single key/value change.
- *
- * @param key the changed key
- * @param value the new value.
- * @return this instance for chining.
- */
- public ConfigurationChangeBuilder addChange(String key, String value) {
- this.delta.put(key, new PropertyChangeEvent(this.source, key, this.source.get(key), value));
- return this;
- }
-
- /**
- * Get the current values, also considering any changes recorded within this change set.
- *
- * @param key the key current the entry, not null.
- * @return the keys, or null.
- */
- public String get(String key) {
- PropertyChangeEvent change = this.delta.get(key);
- if (change != null && !(change.getNewValue() == null)) {
- return (String) change.getNewValue();
- }
- return null;
- }
-
- /**
- * Marks the given key(s) fromMap the configuration/properties to be removed.
- *
- * @param key the key current the entry, not null.
- * @param otherKeys additional keys to be removed (convenience), not null.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder removeKey(String key, String... otherKeys) {
- String oldValue = this.source.get(key);
- if (oldValue == null) {
- this.delta.remove(key);
- }
- this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
- for (String addKey : otherKeys) {
- oldValue = this.source.get(addKey);
- if (oldValue == null) {
- this.delta.remove(addKey);
- }
- this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
- }
- return this;
- }
-
- /**
- * Apply all the given values to the base configuration/properties.
- * Note that all values passed must be convertible to String, either
- * <ul>
- * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
- * <li>default codecs are present for the given type, or</li>
- * <li>the value is an instanceof String</li>
- * </ul>
- *
- * @param changes the changes to be applied, not null.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder putAll(Map<String, String> changes) {
- for (Map.Entry<String, String> en : changes.entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
- }
- return this;
- }
-
- /**
- * This method will create a change set that clears all entries fromMap the given base configuration/properties.
- *
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder removeAllKeys() {
- this.delta.clear();
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
- }
-// this.source.getProperties().forEach((k, v) ->
-// this.delta.put(k, new PropertyChangeEvent(this.source, k, v, null)));
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.delta.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.delta.clear();
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public ConfigurationChange build() {
- return new ConfigurationChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "ConfigurationChangeSetBuilder [config=" + source + ", " +
- ", delta=" + delta + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
deleted file mode 100644
index 4e12d42..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
+++ /dev/null
@@ -1,210 +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.events;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * Event that contains a set of current changes that were applied or can be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class ConfigurationContextChange implements ConfigEvent<ConfigurationContext>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The configuration context. */
- private final ConfigurationContext configurationContext;
-
- /**
- * Get an empty change set for the given provider.
- *
- * @param configurationContext context to use for creating changesets.
- * @return an empty ConfigurationContextChange instance.
- */
- public static ConfigurationContextChange emptyChangeSet(ConfigurationContext configurationContext){
- return ConfigurationContextChangeBuilder.of(configurationContext).build();
- }
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- ConfigurationContextChange(ConfigurationContextChangeBuilder builder) {
- this.changedPropertySources.addAll(builder.changedPropertySources);
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- this.configurationContext = builder.configurationContext;
- }
-
- @Override
- public Class<ConfigurationContext> getResourceType() {
- return ConfigurationContext.class;
- }
-
- @Override
- public ConfigurationContext getResource() {
- return configurationContext;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySourceChange> getPropertySourceChanges(){
- return Collections.unmodifiableCollection(this.changedPropertySources);
- }
-
- /**
- * Get the property source updates.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySourceChange> getPropertySourceUpdates(){
- List<PropertySourceChange> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.UPDATED) {
- result.add(pc);
- }
- }
- return result;
-// return Collections.unmodifiableCollection(this.changedPropertySources).stream()
-// .filter(pc -> pc.getChangeType()==ChangeType.UPDATED).collect(Collectors.toList());
- }
-
- /**
- * Get the property sources to be removed.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySource> getRemovedPropertySources(){
- List<PropertySource> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.DELETED) {
- result.add(pc.getResource());
- }
- }
- return result;
-// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.DELETED).
-// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
- }
-
- /**
- * Get the property sources to be added.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySource> getAddedPropertySources(){
- List<PropertySource> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.NEW) {
- result.add(pc.getResource());
- }
- }
- return result;
-// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.NEW).
-// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
- }
-
- /**
- * Get the property sources to be updated.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySource> getUpdatedPropertySources(){
- List<PropertySource> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.UPDATED) {
- result.add(pc.getResource());
- }
- }
- return result;
-// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.UPDATED).
-// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
- }
-
- /**
- * Checks if the given propertySource is affected (added, changed or removed).
- * @param propertySource the propertySource, not null.
- * @return true, if the given propertySource ia affected.
- */
- public boolean isAffected(PropertySource propertySource) {
- for (PropertySourceChange ps : this.changedPropertySources) {
- if (ps.getResource() == propertySource ||
- ps.getResource().getName().equals(propertySource.getName())) {
- return true;
- }
- }
- return false;
-// return this.changedPropertySources.stream().filter(ps -> ps.getPropertySource()==propertySource ||
-// ps.getPropertySource().getName().equals(propertySource.getName())).findAny().isPresent();
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changedPropertySources.isEmpty();
- }
-
-
- @Override
- public String toString() {
- return "ConfigurationContextChange{" +
- "changedPropertySources=" + changedPropertySources +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
deleted file mode 100644
index b586428..0000000
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
+++ /dev/null
@@ -1,174 +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.events;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Models a set of current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observe changes to property sources and
- * <ol>
- * <li>check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference to a property source is never affected by a
- * change, it is the data of the property source only).</li>
- * <li>if so, a corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class ConfigurationContextChangeBuilder {
- /**
- * The recorded changes.
- */
- final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- final ConfigurationContext configurationContext;
-
- /**
- * Constructor.
- */
- private ConfigurationContextChangeBuilder(ConfigurationContext configurationContext) {
- this.configurationContext = Objects.requireNonNull(configurationContext);
- }
-
- /**
- * Just creates a new ConfigurationContextBuilder using the current COnfigurationContext has root resource.
- * @return a new ConfigurationContextBuilder, never null.
- */
- public static ConfigurationContextChangeBuilder of() {
- return of(ConfigurationProvider.getConfigurationContext());
- }
-
- /**
- * Creates a new instance current this builder.
- *
- * @param context context to use for creating changesets.
- * @return the builder for chaining.
- */
- public static ConfigurationContextChangeBuilder of(ConfigurationContext context) {
- return new ConfigurationContextChangeBuilder(context);
- }
-
- /**
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /**
- * Apply given timestamp to the set being built.
- * @param timestamp timestamp to set.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param propertySource the new target state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder newPropertySource(PropertySource propertySource) {
- this.changedPropertySources.add(PropertySourceChange.ofAdded(propertySource));
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param propertySource the new target state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder removedPropertySource(PropertySource propertySource) {
- this.changedPropertySources.add(PropertySourceChange.ofDeleted(propertySource));
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param propertySourceChange the change state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder changedPropertySource(PropertySourceChange propertySourceChange) {
- this.changedPropertySources.add(Objects.requireNonNull(propertySourceChange));
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.changedPropertySources.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.changedPropertySources.clear();
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public ConfigurationContextChange build() {
- return new ConfigurationContextChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "ConfigurationContextChangeBuilder [propertySources=" + changedPropertySources + "]";
- }
-
-
-}
[15/50] [abbrv] incubator-tamaya-extensions git commit: Added dep to
functions module for EMPTY instances.
Posted by pl...@apache.org.
Added dep to functions module for EMPTY instances.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/8fb49b77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/8fb49b77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/8fb49b77
Branch: refs/heads/old_master
Commit: 8fb49b77ddbebfcb5d04e6ec6ea5b9e775418205
Parents: 0a9aeae
Author: anatole <an...@apache.org>
Authored: Mon Mar 14 00:41:46 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/8fb49b77/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4bd0ee4..0535316 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
- <!--<dependency>-->
- <!--<groupId>org.apache.tamaya.ext</groupId>-->
- <!--<artifactId>tamaya-formats</artifactId>-->
- <!--<version>${project.version}</version>-->
- <!--</dependency>-->
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-functions</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.tamaya</groupId>
<artifactId>tamaya-core</artifactId>
[42/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare for next development iteration
Posted by pl...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/75827f2c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/75827f2c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/75827f2c
Branch: refs/heads/old_master
Commit: 75827f2c7c9b2e66eb98cbcd45012566ad6ef4c8
Parents: 6a6b4a0
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 20:39:16 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/75827f2c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a59a968..d9d4854 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[22/50] [abbrv] incubator-tamaya-extensions git commit: Added license
headers.
Posted by pl...@apache.org.
Added license headers.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/032322bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/032322bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/032322bd
Branch: refs/heads/old_master
Commit: 032322bdf76c0cac82adb110983fb6fd62cc5bd0
Parents: c7828a4
Author: anatole <an...@apache.org>
Authored: Sat Apr 16 08:37:42 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
src/main/resources/ui/lang/tamaya.properties | 19 +++++++++++++++++++
.../tamaya/events/RandomPropertySource.java | 18 ++++++++++++++++++
src/test/resources/config/application.yml | 18 ++++++++++++++++++
3 files changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/032322bd/src/main/resources/ui/lang/tamaya.properties
----------------------------------------------------------------------
diff --git a/src/main/resources/ui/lang/tamaya.properties b/src/main/resources/ui/lang/tamaya.properties
index 37ca420..8f83a5c 100644
--- a/src/main/resources/ui/lang/tamaya.properties
+++ b/src/main/resources/ui/lang/tamaya.properties
@@ -1,3 +1,22 @@
+#
+# 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.
+#
+
view.events.name=Configuration Events
view.events.table.name=Observed Events
view.events.button.enableMonitoring=Change Monitor active
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/032322bd/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/RandomPropertySource.java b/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
index f32ead7..dead0d9 100644
--- a/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
+++ b/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
@@ -1,3 +1,21 @@
+/*
+ * 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.events;
import org.apache.tamaya.spi.PropertySource;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/032322bd/src/test/resources/config/application.yml
----------------------------------------------------------------------
diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml
index 9ec8d5b..00d6d43 100644
--- a/src/test/resources/config/application.yml
+++ b/src/test/resources/config/application.yml
@@ -1,3 +1,21 @@
+#
+# 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.
+#
server:
type: default
maxThreads: 1024
[49/50] [abbrv] incubator-tamaya-extensions git commit: [TAMAYA-175]
Added .gitignore.
Posted by pl...@apache.org.
[TAMAYA-175] Added .gitignore.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/4900aa7f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/4900aa7f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/4900aa7f
Branch: refs/heads/old_master
Commit: 4900aa7fa0f09ce6e65d52a03dae014f026fe067
Parents: 669277d
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Mon Oct 10 20:39:41 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Mon Oct 10 20:39:41 2016 +0200
----------------------------------------------------------------------
.gitignore | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4900aa7f/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..20c0163
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+dependency-reduced-pom.xml
+release.properties
+.idea
+*.iml
+*.log
+*~
+.DS_Store
+.project
+.settings
+.classpath
+**/*.checkstyle
+**/*.fbExcludeFilterFile
+
+
[05/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-134:
Gitignore improvements and second batch of Javadoc fixes done by Philipp
Ottlinger.
Posted by pl...@apache.org.
TAMAYA-134: Gitignore improvements and second batch of
Javadoc fixes done by Philipp Ottlinger.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/245defb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/245defb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/245defb2
Branch: refs/heads/old_master
Commit: 245defb26bad2f11551a35218aecbd7419019f7a
Parents: e0cd657
Author: anatole <an...@apache.org>
Authored: Tue Jan 19 01:11:27 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../tamaya/events/ConfigEventManager.java | 17 ++++-
.../events/ConfigurationContextChange.java | 4 +-
.../ConfigurationContextChangeBuilder.java | 19 ++---
.../events/PropertySourceChangeBuilder.java | 4 +-
.../ObservingPropertySourceProvider.java | 77 ++++++++++++--------
.../events/spi/ConfigEventManagerSpi.java | 19 +++--
6 files changed, 87 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/245defb2/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
index 6b206c8..9989fbb 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -55,6 +55,7 @@ public final class ConfigEventManager {
/**
* Adds a Config listener that listens to all kind of {@link ConfigEvent}.
+ * @param <T> the type of the event.
* @param l the listener not null.
* @param eventType the event type to which this listener listens to.
*/
@@ -82,7 +83,8 @@ public final class ConfigEventManager {
/**
* Removes a listener registered for the given event type.
*
- * @param l the listener not null.
+ * @param <T> the type of the event.
+ * @param l the listener, not null.
* @param eventType the event type to which this listener listens to.
*/
public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
@@ -106,6 +108,8 @@ public final class ConfigEventManager {
/**
* Access all registered ConfigEventListeners listening to a all kind of event types globally.
+ *
+ * @param <T> the type of the event.
* @return a list with the listeners found, never null.
*/
public static <T extends ConfigEvent>
@@ -115,7 +119,8 @@ public final class ConfigEventManager {
/**
* Publishes a {@link ConfigurationChange} synchronously to all interested listeners.
- *
+ *
+ * @param <T> the type of the event.
* @param event the event, not null.
*/
public static <T> void fireEvent(ConfigEvent<?> event) {
@@ -125,6 +130,7 @@ public final class ConfigEventManager {
/**
* Publishes a {@link ConfigurationChange} asynchronously/multithreaded to all interested listeners.
*
+ * @param <T> the type of the event.
* @param event the event, not null.
*/
public static <T> void fireEventAsynch(ConfigEvent<?> event) {
@@ -133,10 +139,13 @@ public final class ConfigEventManager {
/**
* Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and triggers ConfigurationChange events is something changed. This is quite handy for publishing
+ * and trigger ConfigurationChange events if something changed. This is quite handy for publishing
* configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotedly. FOr handling corresponding {@link ConfigEventListener} have
+ * can be on this machine, or also remotely. For handling corresponding {@link ConfigEventListener} have
* to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
+ *
+ * @param enable whether to enable or disable the change monitoring.
+ *
* @see #isChangeMonitoring()
* @see #getChangeMonitoringPeriod()
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/245defb2/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
index 8c9ceef..4e12d42 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.UUID;
/**
- * Event that contains a set current changes that were applied or could be applied.
+ * Event that contains a set of current changes that were applied or can be applied.
* This class is immutable and thread-safe. To create instances use
* {@link PropertySourceChangeBuilder}.
*
@@ -49,6 +49,8 @@ public final class ConfigurationContextChange implements ConfigEvent<Configurati
/**
* Get an empty change set for the given provider.
+ *
+ * @param configurationContext context to use for creating changesets.
* @return an empty ConfigurationContextChange instance.
*/
public static ConfigurationContextChange emptyChangeSet(ConfigurationContext configurationContext){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/245defb2/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
index a48107a..b586428 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
@@ -27,13 +27,13 @@ import java.util.List;
import java.util.Objects;
/**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
+ * Models a set of current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
+ * can observe changes to property sources and
* <ol>
- * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- * change, its only the data of the property source).</li>
- * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
+ * <li>check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
+ * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference to a property source is never affected by a
+ * change, it is the data of the property source only).</li>
+ * <li>if so, a corresponding action may be taken, such as reevaluating the configuration values (depending on
* the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
* event on configuration level.
* </ol>
@@ -72,13 +72,14 @@ public final class ConfigurationContextChangeBuilder {
/**
* Creates a new instance current this builder.
*
+ * @param context context to use for creating changesets.
* @return the builder for chaining.
*/
public static ConfigurationContextChangeBuilder of(ConfigurationContext context) {
return new ConfigurationContextChangeBuilder(context);
}
- /*
+ /**
* Apply a version/UUID to the set being built.
* @param version the version to apply, or null, to let the system generate a version for you.
* @return the builder for chaining.
@@ -88,9 +89,9 @@ public final class ConfigurationContextChangeBuilder {
return this;
}
- /*
+ /**
* Apply given timestamp to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
+ * @param timestamp timestamp to set.
* @return the builder for chaining.
*/
public ConfigurationContextChangeBuilder setTimestamp(long timestamp) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/245defb2/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
index 009cb11..cefa4f4 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -66,6 +66,7 @@ public final class PropertySourceChangeBuilder {
* Constructor.
*
* @param source the underlying configuration/provider, not null.
+ * @param changeType kind of change.
*/
private PropertySourceChangeBuilder(PropertySource source, ChangeType changeType) {
this.source = Objects.requireNonNull(source);
@@ -73,9 +74,10 @@ public final class PropertySourceChangeBuilder {
}
/**
- * Creates a new instance current this builder.
+ * Creates a new instance of this builder.
*
* @param source the underlying property provider/configuration, not null.
+ * @param changeType kind of change.
* @return the builder for chaining.
*/
public static PropertySourceChangeBuilder of(PropertySource source, ChangeType changeType) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/245defb2/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
index 6082dd0..347576f 100644
--- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
@@ -18,14 +18,6 @@
*/
package org.apache.tamaya.events.folderobserver;
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
@@ -33,18 +25,34 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+import org.apache.tamaya.events.ConfigEventManager;
+import org.apache.tamaya.events.ConfigurationContextChange;
+import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+
/**
- * This implementation run in a folder taking up all file compatible with the given
+ * This implementation runs in a folder taking up all files compatible with the given
* ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider
* will adapt the changes automatically and trigger according
* {@link org.apache.tamaya.events.PropertySourceChange} events.
- * The default folder is META-INF/config, but you can change using the absolute path in
+ * The default folder is META-INF/config, but you can change it via an absolute path in the
* "-Dtamaya.configdir" parameter.
*/
public class ObservingPropertySourceProvider implements PropertySourceProvider, FileChangeObserver {
@@ -74,7 +82,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
synchronized (this.propertySources) {
this.propertySources.addAll(readConfiguration(directory));
}
- Runnable runnable = new FileChangeListener(directory, this);
+ final Runnable runnable = new FileChangeListener(directory, this);
executor.execute(runnable);
} else {
executor.shutdown();
@@ -87,20 +95,26 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
* @param directory the target directory, not null.
*/
private List<PropertySource> readConfiguration(Path directory) {
- List<PropertySource> result = new ArrayList<>();
+ final List<PropertySource> result = new ArrayList<>();
try {
synchronized (propertySources) {
- for (Path path : Files.newDirectoryStream(directory, "*")) {
+ for (final Path path : Files.newDirectoryStream(directory, "*")) {
result.addAll(getPropertySources(path));
}
return result;
}
- } catch (IOException e) {
+ } catch (final IOException e) {
LOG.log(Level.WARNING, "Failed to read configuration from dir: " + directory, e);
}
return result;
}
+ /**
+ * Read property sources from the given file.
+ *
+ * @param file source of the property sources.
+ * @return property sources from the given file.
+ */
protected Collection<PropertySource> getPropertySources(final Path file) {
return Arrays.asList(new PropertySource[]{new BasePropertySource() {
private final Map<String,String> props = readProperties(file);
@@ -115,17 +129,18 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
* Load a single file.
*
* @param file the file, not null.
+ * @return properties as read from the given file.
*/
protected static Map<String,String> readProperties(Path file) {
try (InputStream is = file.toUri().toURL().openStream()){
- Properties props = new Properties();
+ final Properties props = new Properties();
props.load(is);
- Map<String,String> result = new HashMap<>();
- for(Map.Entry en:props.entrySet()){
- result.put(en.getKey().toString(), en.getValue().toString());
+ final Map<String,String> result = new HashMap<>();
+ for(final Map.Entry<Object,Object> en:props.entrySet()){
+ result.put(String.valueOf(en.getKey()), String.valueOf(en.getValue()));
}
return result;
- } catch (Exception e) {
+ } catch (final Exception e) {
LOG.log(Level.INFO, "Error reading file: " + file.toString() +
", using format: properties", e);
}
@@ -139,18 +154,18 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
* @return the directory to be read, or null.
*/
private Path getDirectory() {
- String absolutePath = System.getProperty("tamaya.configdir");
+ final String absolutePath = System.getProperty("tamaya.configdir");
if (null!=absolutePath) {
- Path path = Paths.get(absolutePath);
+ final Path path = Paths.get(absolutePath);
if (Files.isDirectory(path)) {
return path;
}
}
- URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
+ final URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
if (null!=resource) {
try {
return Paths.get(resource.toURI());
- } catch (URISyntaxException e) {
+ } catch (final URISyntaxException e) {
throw new ConfigException("An error to find the directory to watch", e);
}
}
@@ -161,9 +176,9 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
@Override
public void directoryChanged(Path directory) {
synchronized (this.propertySources) {
- List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
+ final List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
propertySources.clear();
- Collection<PropertySource> sourcesRead = readConfiguration(directory);
+ final Collection<PropertySource> sourcesRead = readConfiguration(directory);
this.propertySources.addAll(sourcesRead);
triggerConfigChange(existingPropertySources, propertySources);
}
@@ -172,14 +187,14 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
private void triggerConfigChange(List<PropertySource> originalPropertySources,
List<PropertySource> newPropertySources) {
- ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
- for (PropertySource ps : originalPropertySources) {
+ final ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
+ for (final PropertySource ps : originalPropertySources) {
b.removedPropertySource(ps);
}
- for (PropertySource ps : newPropertySources) {
+ for (final PropertySource ps : newPropertySources) {
b.newPropertySource(ps);
}
- ConfigurationContextChange changeEvent = b.build();
+ final ConfigurationContextChange changeEvent = b.build();
LOG.fine("Trigger Config Context Change: " + changeEvent);
ConfigEventManager.fireEvent(changeEvent);
}
@@ -190,4 +205,4 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
return new ArrayList<>(this.propertySources);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/245defb2/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
index 93c813d..66a8f73 100644
--- a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
+++ b/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
@@ -27,13 +27,14 @@ import java.util.Collection;
* SPI interface to implement the {@link org.apache.tamaya.events.ConfigEventManager} singleton.
* Implementations of this interface must be registered with the current {@link org.apache.tamaya.spi.ServiceContext},
* by default this equals to registering it with {@link java.util.ServiceLoader}. Add {@link javax.annotation.Priority}
- * annotations for overriding (higher values overriden lower values).
+ * annotations for overriding (higher values override lower values).
*/
public interface ConfigEventManagerSpi {
/**
- * Add a listener for observing events. References of this
+ * Adds a listener for observing events. References of this
* component to the listeners must be managed as weak references.
- *
+ *
+ * @param <T> the type of the events listened to.
* @param l the listener not null.
*/
<T> void addListener(ConfigEventListener l);
@@ -41,9 +42,10 @@ public interface ConfigEventManagerSpi {
/**
* Adds a listener for observing events of a given type.
*
+ * @param <T> the type of the events listened to.
* @param l the listener not null.
* @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
+ * event types will never be delivered to this listener instance.
*/
<T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType);
@@ -57,6 +59,7 @@ public interface ConfigEventManagerSpi {
/**
* Removes a listener for observing events of a certain type.
*
+ * @param <T> the type of the events listened to.
* @param l the listener not null.
* @param eventType the type of concrete configuration event this listeners should be informed about. All other
* event types will never be delivered toe this listener instance.
@@ -111,11 +114,13 @@ public interface ConfigEventManagerSpi {
boolean isChangeMonitorActive();
/**
- * Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and triggers ConfigurationChange events is something changed. This is quite handy for publishing
+ * Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly
+ * and trigger ConfigurationChange events if something is changed. This is quite handy for publishing
* configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotedly. FOr handling corresponding {@link ConfigEventListener} have
+ * can be on this machine, or also remotedly. For handling corresponding {@link ConfigEventListener} have
* to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
+ *
+ * @param enable whether to enable or disable the change monitoring.
*/
void enableChangeMonitor(boolean enable);
[25/50] [abbrv] incubator-tamaya-extensions git commit: Implemented
UI improvements and bugfixes. Fixed some impl details.
Posted by pl...@apache.org.
Implemented UI improvements and bugfixes.
Fixed some impl details.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/81b05eb0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/81b05eb0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/81b05eb0
Branch: refs/heads/old_master
Commit: 81b05eb0c793e700cfbd3f0cc7213cab317d5081
Parents: df14719
Author: anatole <an...@apache.org>
Authored: Sat Jun 25 01:21:16 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
src/main/java/org/apache/tamaya/events/ui/EventView.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/81b05eb0/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ui/EventView.java b/src/main/java/org/apache/tamaya/events/ui/EventView.java
index bee6e7b..2c4dead 100644
--- a/src/main/java/org/apache/tamaya/events/ui/EventView.java
+++ b/src/main/java/org/apache/tamaya/events/ui/EventView.java
@@ -59,17 +59,22 @@ public class EventView extends VerticalSpacedLayout implements View {
}
@Override
+ public String getName() {
+ return "view.events.name";
+ }
+
+ @Override
public String getUrlPattern() {
return "/events";
}
@Override
public String getDisplayName() {
- return "view.events.name";
+ return getName();
}
@Override
- public View createView(){
+ public View createView(Object... params){
return new EventView();
}
}
[10/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare for next development iteration
Posted by pl...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/a519ddda
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/a519ddda
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/a519ddda
Branch: refs/heads/old_master
Commit: a519ddda49bc4945d92e7a3bfbc407ca07d10e44
Parents: dd25aa8
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 17:40:05 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a519ddda/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0fece2a..e843ec8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-events</artifactId>
[11/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release 0.2-incubating-rc1
Posted by pl...@apache.org.
[maven-release-plugin] prepare release 0.2-incubating-rc1
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/14b9e6ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/14b9e6ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/14b9e6ea
Branch: refs/heads/old_master
Commit: 14b9e6ea916a439d1ce519f8db2a0c6df9056337
Parents: a519ddd
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 20:39:05 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/14b9e6ea/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e843ec8..0fece2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-events</artifactId>
[24/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-150
Added UI module and related functionality.
Posted by pl...@apache.org.
TAMAYA-150 Added UI module and related functionality.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/df14719d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/df14719d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/df14719d
Branch: refs/heads/old_master
Commit: df14719d0b4489edabf5ff6d15cc8f8d03388fbb
Parents: 6ca5def
Author: anatole <an...@apache.org>
Authored: Tue Apr 19 13:52:19 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../java/org/apache/tamaya/events/ui/EventView.java | 15 +++++++++++++--
.../tamaya/events/delta/ConfigurationChangeTest.java | 8 +++++++-
2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/df14719d/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ui/EventView.java b/src/main/java/org/apache/tamaya/events/ui/EventView.java
index 56e4b35..bee6e7b 100644
--- a/src/main/java/org/apache/tamaya/events/ui/EventView.java
+++ b/src/main/java/org/apache/tamaya/events/ui/EventView.java
@@ -23,7 +23,13 @@ import com.vaadin.data.Property;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.ui.*;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
import org.apache.tamaya.events.ConfigEvent;
import org.apache.tamaya.events.ConfigEventListener;
import org.apache.tamaya.events.ConfigEventManager;
@@ -36,9 +42,14 @@ import org.apache.tamaya.ui.services.MessageProvider;
import javax.annotation.Priority;
import java.util.Date;
-
+/**
+ * Tamaya View for observing the current event stream.
+ */
public class EventView extends VerticalSpacedLayout implements View {
+ /**
+ * Provider used to register the view.
+ */
@Priority(20)
public static final class Provider implements ViewProvider{
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/df14719d/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java b/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
index 95269e2..b20ebef 100644
--- a/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
+++ b/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
@@ -45,9 +45,15 @@ public class ConfigurationChangeTest {
Configuration config = ConfigurationProvider.getConfiguration();
ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
assertNotNull(change);
- assertTrue(change.isEmpty());
+ assertTrue(change.getUpdatedSize()==0);
+ assertTrue(change.getAddedSize()==0);
+ assertTrue(change.getRemovedSize()==0);
+ assertTrue(change.getChanges().size()==0);
for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
if (!"[meta]frozenAt".equals(en.getKey())) {
+ if(en.getKey().contains("random.new")){ // dynamic generated value!
+ continue;
+ }
assertEquals("Error for " + en.getKey(), en.getValue(), change.getResource().get(en.getKey()));
}
}
[33/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-175
Moved the events module to the directory events after extracting it for the
Tamaya main repository.
Posted by pl...@apache.org.
TAMAYA-175 Moved the events module to the directory events after extracting it for the Tamaya main repository.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/89223dcd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/89223dcd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/89223dcd
Branch: refs/heads/old_master
Commit: 89223dcd49f9045f01ed04b803add7cabe746cbd
Parents: 9bf98fe
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Tue Sep 27 00:17:11 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
events/pom.xml | 100 +++++++
.../org/apache/tamaya/events/ChangeType.java | 31 +++
.../org/apache/tamaya/events/ConfigEvent.java | 55 ++++
.../tamaya/events/ConfigEventListener.java | 31 +++
.../tamaya/events/ConfigEventManager.java | 186 +++++++++++++
.../tamaya/events/ConfigurationChange.java | 218 +++++++++++++++
.../events/ConfigurationChangeBuilder.java | 274 +++++++++++++++++++
.../events/ConfigurationContextChange.java | 210 ++++++++++++++
.../ConfigurationContextChangeBuilder.java | 174 ++++++++++++
.../tamaya/events/FrozenConfiguration.java | 194 +++++++++++++
.../tamaya/events/FrozenPropertySource.java | 126 +++++++++
.../tamaya/events/PropertySourceChange.java | 242 ++++++++++++++++
.../events/PropertySourceChangeBuilder.java | 263 ++++++++++++++++++
.../tamaya/events/delta/package-info.java | 23 ++
.../folderobserver/FileChangeListener.java | 144 ++++++++++
.../folderobserver/FileChangeObserver.java | 33 +++
.../ObservingPropertySourceProvider.java | 209 ++++++++++++++
.../events/folderobserver/package-info.java | 24 ++
.../internal/DefaultConfigChangeObserver.java | 111 ++++++++
.../internal/DefaultConfigEventManagerSpi.java | 202 ++++++++++++++
...faultConfigurationContextChangeListener.java | 74 +++++
.../events/internal/LoggingConfigListener.java | 40 +++
.../tamaya/events/internal/package-info.java | 22 ++
.../org/apache/tamaya/events/package-info.java | 24 ++
.../tamaya/events/spi/BaseConfigEvent.java | 69 +++++
.../events/spi/ConfigEventManagerSpi.java | 128 +++++++++
.../apache/tamaya/events/spi/package-info.java | 23 ++
...org.apache.tamaya.events.ConfigEventListener | 19 ++
...ache.tamaya.events.spi.ConfigEventManagerSpi | 19 ++
.../events/ChangeableGlobalPropertySource.java | 62 +++++
.../ChangeableThreadLocalPropertySource.java | 57 ++++
.../tamaya/events/ConfigEventManagerTest.java | 66 +++++
.../tamaya/events/FrozenPropertySourceTest.java | 106 +++++++
.../tamaya/events/ObservedConfigTest.java | 69 +++++
.../tamaya/events/RandomPropertySource.java | 66 +++++
.../org/apache/tamaya/events/SimpleEvent.java | 32 +++
.../apache/tamaya/events/TestConfigView.java | 156 +++++++++++
.../tamaya/events/TestObservingProvider.java | 92 +++++++
.../events/delta/ConfigurationChangeTest.java | 163 +++++++++++
.../delta/ConfigurationContextChangeTest.java | 138 ++++++++++
.../events/delta/PropertySourceChangeTest.java | 209 ++++++++++++++
.../DefaultConfigEventManagerSpiTest.java | 66 +++++
...org.apache.tamaya.events.ConfigEventListener | 19 ++
.../org.apache.tamaya.spi.PropertySource | 19 ++
...org.apache.tamaya.spi.PropertySourceProvider | 19 ++
events/src/test/resources/data/test1.properties | 20 ++
.../src/test/resources/data/test1b.properties | 20 ++
events/src/test/resources/data/test2.properties | 20 ++
events/src/test/resources/data/test3.properties | 20 ++
events/src/test/resources/test.properties | 21 ++
pom.xml | 100 -------
.../org/apache/tamaya/events/ChangeType.java | 31 ---
.../org/apache/tamaya/events/ConfigEvent.java | 55 ----
.../tamaya/events/ConfigEventListener.java | 31 ---
.../tamaya/events/ConfigEventManager.java | 186 -------------
.../tamaya/events/ConfigurationChange.java | 218 ---------------
.../events/ConfigurationChangeBuilder.java | 274 -------------------
.../events/ConfigurationContextChange.java | 210 --------------
.../ConfigurationContextChangeBuilder.java | 174 ------------
.../tamaya/events/FrozenConfiguration.java | 194 -------------
.../tamaya/events/FrozenPropertySource.java | 126 ---------
.../tamaya/events/PropertySourceChange.java | 242 ----------------
.../events/PropertySourceChangeBuilder.java | 263 ------------------
.../tamaya/events/delta/package-info.java | 23 --
.../folderobserver/FileChangeListener.java | 144 ----------
.../folderobserver/FileChangeObserver.java | 33 ---
.../ObservingPropertySourceProvider.java | 209 --------------
.../events/folderobserver/package-info.java | 24 --
.../internal/DefaultConfigChangeObserver.java | 111 --------
.../internal/DefaultConfigEventManagerSpi.java | 202 --------------
...faultConfigurationContextChangeListener.java | 74 -----
.../events/internal/LoggingConfigListener.java | 40 ---
.../tamaya/events/internal/package-info.java | 22 --
.../org/apache/tamaya/events/package-info.java | 24 --
.../tamaya/events/spi/BaseConfigEvent.java | 69 -----
.../events/spi/ConfigEventManagerSpi.java | 128 ---------
.../apache/tamaya/events/spi/package-info.java | 23 --
...org.apache.tamaya.events.ConfigEventListener | 19 --
...ache.tamaya.events.spi.ConfigEventManagerSpi | 19 --
.../events/ChangeableGlobalPropertySource.java | 62 -----
.../ChangeableThreadLocalPropertySource.java | 57 ----
.../tamaya/events/ConfigEventManagerTest.java | 66 -----
.../tamaya/events/FrozenPropertySourceTest.java | 106 -------
.../tamaya/events/ObservedConfigTest.java | 69 -----
.../tamaya/events/RandomPropertySource.java | 66 -----
.../org/apache/tamaya/events/SimpleEvent.java | 32 ---
.../apache/tamaya/events/TestConfigView.java | 156 -----------
.../tamaya/events/TestObservingProvider.java | 92 -------
.../events/delta/ConfigurationChangeTest.java | 163 -----------
.../delta/ConfigurationContextChangeTest.java | 138 ----------
.../events/delta/PropertySourceChangeTest.java | 209 --------------
.../DefaultConfigEventManagerSpiTest.java | 66 -----
...org.apache.tamaya.events.ConfigEventListener | 19 --
.../org.apache.tamaya.spi.PropertySource | 19 --
...org.apache.tamaya.spi.PropertySourceProvider | 19 --
src/test/resources/data/test1.properties | 20 --
src/test/resources/data/test1b.properties | 20 --
src/test/resources/data/test2.properties | 20 --
src/test/resources/data/test3.properties | 20 --
src/test/resources/test.properties | 21 --
100 files changed, 4708 insertions(+), 4708 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/pom.xml
----------------------------------------------------------------------
diff --git a/events/pom.xml b/events/pom.xml
new file mode 100644
index 0000000..d274633
--- /dev/null
+++ b/events/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.3-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>tamaya-events</artifactId>
+ <name>Apache Tamaya Modules - Event and dynamic Update Extensions</name>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <jdkVersion>1.7</jdkVersion>
+ </properties>
+
+ <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-functions</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</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
+ </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.events,
+ org.apache.tamaya.events.delta,
+ org.apache.tamaya.events.folderobserver,
+ org.apache.tamaya.events.spi
+ </Export-Package>
+ <Private-Package>
+ org.apache.tamaya.events.internal
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ChangeType.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ChangeType.java b/events/src/main/java/org/apache/tamaya/events/ChangeType.java
new file mode 100644
index 0000000..2059017
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ChangeType.java
@@ -0,0 +1,31 @@
+/*
+ * 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.events;
+
+/**
+ * Enum describing the type of configuration change.
+ */
+public enum ChangeType {
+ /** Configuration hase been added. */
+ NEW,
+ /** Configuration hase been removed. */
+ DELETED,
+ /** Configuration hase been changed. */
+ UPDATED,
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java b/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java
new file mode 100644
index 0000000..5a713d7
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java
@@ -0,0 +1,55 @@
+/*
+ * 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.events;
+
+
+/**
+ * Event that contains a set current changes that were applied or could be applied.
+ * @param <T> the resource type.
+ */
+public interface ConfigEvent<T>{
+
+ /**
+ * Access the type of resource. This allows to easily determine the resource an event wants to observe.
+ * @return the resource type.
+ */
+ Class<T> getResourceType();
+
+ /**
+ * Get the underlying property provider/configuration.
+ * @return the underlying property provider/configuration, never null.
+ */
+ T getResource();
+
+ /**
+ * Get the version relative to the observed resource. The version is required to be unique for
+ * each change emmitted for a resource. There is no further requirement how this uniqueness is
+ * modelled, so returning a UUID is a completely valid strategy.
+ * @return the base version.
+ */
+ String getVersion();
+
+ /**
+ * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
+ * identify a changeset.
+ * @return the timestamp, when this changeset was created.
+ */
+ long getTimestamp();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java b/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
new file mode 100644
index 0000000..7fb32c8
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
@@ -0,0 +1,31 @@
+/*
+ * 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.events;
+
+/**
+ * Interface to be implemented for listening on changes on {@link org.apache.tamaya.Configuration} instances.
+ */
+public interface ConfigEventListener {
+ /**
+ * Called if an event occurred.
+ * @param event the event, not null.
+ */
+ void onConfigEvent(ConfigEvent<?> event);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
new file mode 100644
index 0000000..f6bd3da
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -0,0 +1,186 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.util.Collection;
+
+/**
+ * Singleton accessor for accessing the event support component that distributes change events of
+ * {@link org.apache.tamaya.spi.PropertySource} and {@link org.apache.tamaya.Configuration}.
+ */
+public final class ConfigEventManager {
+ /**
+ * The backing SPI.
+ */
+ private static final ConfigEventManagerSpi SPI = ServiceContextManager.getServiceContext()
+ .getService(ConfigEventManagerSpi.class);
+
+ /**
+ * Private singleton constructor.
+ */
+ private ConfigEventManager() {
+ }
+
+ /**
+ * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
+ * @param l the listener not null.
+ */
+ public static void addListener(ConfigEventListener l) {
+ if (SPI == null) {
+ throw new ConfigException("No SPI registered for " +
+ ConfigEventManager.class.getName());
+ }
+ SPI.addListener(l);
+ }
+
+ /**
+ * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
+ * @param <T> the type of the event.
+ * @param l the listener not null.
+ * @param eventType the event type to which this listener listens to.
+ */
+ public static <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType) {
+ if (SPI == null) {
+ throw new ConfigException("No SPI registered for " +
+ ConfigEventManager.class.getName());
+ }
+ SPI.addListener(l);
+ }
+
+ /**
+ * Removes a listener registered globally.
+ *
+ * @param l the listener not null.
+ */
+ public static void removeListener(ConfigEventListener l) {
+ if (SPI == null) {
+ throw new ConfigException("No SPI registered for " +
+ ConfigEventManager.class.getName());
+ }
+ SPI.removeListener(l);
+ }
+
+ /**
+ * Removes a listener registered for the given event type.
+ *
+ * @param <T> the type of the event.
+ * @param l the listener, not null.
+ * @param eventType the event type to which this listener listens to.
+ */
+ public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
+ if (SPI == null) {
+ throw new ConfigException("No SPI registered for " +
+ ConfigEventManager.class.getName());
+ }
+ SPI.removeListener(l);
+ }
+
+ /**
+ * Access all registered ConfigEventListeners listening to a given event type.
+ * @param type the event type
+ * @param <T> type param
+ * @return a list with the listeners found, never null.
+ */
+ public static <T extends ConfigEvent>
+ Collection<? extends ConfigEventListener> getListeners(Class<T> type) {
+ return SPI.getListeners(type);
+ }
+
+ /**
+ * Access all registered ConfigEventListeners listening to a all kind of event types globally.
+ *
+ * @param <T> the type of the event.
+ * @return a list with the listeners found, never null.
+ */
+ public static <T extends ConfigEvent>
+ Collection<? extends ConfigEventListener> getListeners() {
+ return SPI.getListeners();
+ }
+
+ /**
+ * Publishes a {@link ConfigurationChange} synchronously to all interested listeners.
+ *
+ * @param <T> the type of the event.
+ * @param event the event, not null.
+ */
+ public static <T> void fireEvent(ConfigEvent<?> event) {
+ SPI.fireEvent(event);
+ }
+
+ /**
+ * Publishes a {@link ConfigurationChange} asynchronously/multithreaded to all interested listeners.
+ *
+ * @param <T> the type of the event.
+ * @param event the event, not null.
+ */
+ public static <T> void fireEventAsynch(ConfigEvent<?> event) {
+ SPI.fireEventAsynch(event);
+ }
+
+ /**
+ * Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
+ * and trigger ConfigurationChange events if something changed. This is quite handy for publishing
+ * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
+ * can be on this machine, or also remotely. For handling corresponding {@link ConfigEventListener} have
+ * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
+ *
+ * @param enable whether to enable or disable the change monitoring.
+ *
+ * @see #isChangeMonitoring()
+ * @see #getChangeMonitoringPeriod()
+ */
+ public static void enableChangeMonitoring(boolean enable) {
+ SPI.enableChangeMonitor(enable);
+ }
+
+ /**
+ * Check if the observer is running currently.
+ *
+ * @return true, if the change monitoring service is currently running.
+ * @see #enableChangeMonitoring(boolean)
+ */
+ public static boolean isChangeMonitoring() {
+ return SPI.isChangeMonitorActive();
+ }
+
+ /**
+ * Get the current check period to check for configuration changes.
+ *
+ * @return the check period in ms.
+ */
+ public static long getChangeMonitoringPeriod(){
+ return SPI.getChangeMonitoringPeriod();
+ }
+
+ /**
+ * Sets the current monitoring period and restarts the monitor. You still have to enable the monitor if
+ * it is currently not enabled.
+ * @param millis the monitoring period in ms.
+ * @see #enableChangeMonitoring(boolean)
+ * @see #isChangeMonitoring()
+ */
+ public static void setChangeMonitoringPeriod(long millis){
+ SPI.setChangeMonitoringPeriod(millis);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java b/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
new file mode 100644
index 0000000..c31cda2
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
@@ -0,0 +1,218 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.Configuration;
+
+import java.beans.PropertyChangeEvent;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Event that contains a set current changes that were applied or could be applied.
+ * This class is immutable and thread-safe. To create instances use
+ * {@link PropertySourceChangeBuilder}.
+ *
+ * Created by Anatole on 22.10.2014.
+ */
+public final class ConfigurationChange implements ConfigEvent<Configuration>, Serializable{
+
+ private static final long serialVersionUID = 1L;
+ /** The base property provider/configuration. */
+ private final FrozenConfiguration configuration;
+ /** The base version, usable for optimistic locking. */
+ private String version = UUID.randomUUID().toString();
+ /** The timestamp of the change set in millis from the epoch. */
+ private long timestamp = System.currentTimeMillis();
+ /** The recorded changes. */
+ private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
+
+ /**
+ * Get an empty change set for the given provider.
+ * @param configuration The configuration changed, not null.
+ * @return an empty ConfigurationChangeSet instance.
+ */
+ public static ConfigurationChange emptyChangeSet(Configuration configuration){
+ return ConfigurationChangeBuilder.of(configuration).build();
+ }
+
+ /**
+ * Constructor used by {@link PropertySourceChangeBuilder}.
+ * @param builder The builder used, not null.
+ */
+ ConfigurationChange(ConfigurationChangeBuilder builder) {
+ this.configuration = FrozenConfiguration.of(builder.source);
+ for(PropertyChangeEvent ev:builder.delta.values()){
+ this.changes.put(ev.getPropertyName(), ev);
+ }
+ if(builder.version!=null){
+ this.version = builder.version;
+ }
+ if(builder.timestamp!=null){
+ this.timestamp = builder.timestamp;
+ }
+ }
+
+ @Override
+ public Class<Configuration> getResourceType() {
+ return Configuration.class;
+ }
+
+ /**
+ * Get the underlying property provider/configuration.
+ * @return the underlying property provider/configuration, never null.
+ */
+ @Override
+ public Configuration getResource(){
+ return this.configuration;
+ }
+
+ /**
+ * Get the base version, usable for optimistic locking.
+ * @return the base version.
+ */
+ @Override
+ public String getVersion(){
+ return version;
+ }
+
+ /**
+ * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
+ * identify a changeset.
+ * @return the timestamp, when this changeset was created.
+ */
+ @Override
+ public long getTimestamp(){
+ return timestamp;
+ }
+
+ /**
+ * Get the changes recorded.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertyChangeEvent> getChanges(){
+ return Collections.unmodifiableCollection(this.changes.values());
+ }
+
+ /**
+ * Access the number current removed entries.
+ * @return the number current removed entries.
+ */
+ public int getRemovedSize() {
+ int removedCount = 0;
+ for(PropertyChangeEvent ev:this.changes.values()){
+ if(ev.getNewValue() == null){
+ removedCount++;
+ }
+ }
+ return removedCount;
+ }
+
+ /**
+ * Access the number current added entries.
+ * @return the number current added entries.
+ */
+ public int getAddedSize() {
+ int addedCount = 0;
+ for(PropertyChangeEvent ev:this.changes.values()){
+ if(ev.getOldValue() == null &&
+ ev.getNewValue() != null){
+ addedCount++;
+ }
+ }
+ return addedCount;
+ }
+
+ /**
+ * Access the number current updated entries.
+ * @return the number current updated entries.
+ */
+ public int getUpdatedSize() {
+ int updatedCount = 0;
+ for(PropertyChangeEvent ev:this.changes.values()){
+ if( ev.getOldValue()!=null && ev.getNewValue()!=null){
+ updatedCount++;
+ }
+ }
+ return updatedCount;
+ }
+
+
+ /**
+ * Checks if the given key was removed.
+ * @param key the target key, not null.
+ * @return true, if the given key was removed.
+ */
+ public boolean isRemoved(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getNewValue() == null;
+ }
+
+ /**
+ * Checks if the given key was added.
+ * @param key the target key, not null.
+ * @return true, if the given key was added.
+ */
+ public boolean isAdded(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getOldValue() == null;
+ }
+
+ /**
+ * Checks if the given key was updated.
+ * @param key the target key, not null.
+ * @return true, if the given key was updated.
+ */
+ public boolean isUpdated(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getOldValue() != null && change.getNewValue() != null;
+ }
+
+ /**
+ * Checks if the given key is added, or updated AND NOT removed.
+ * @param key the target key, not null.
+ * @return true, if the given key was added, or updated BUT NOT removed.
+ */
+ public boolean isKeyAffected(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getNewValue() != null;
+ }
+
+ /**
+ * CHecks if the current change set does not contain any changes.
+ * @return tru, if the change set is empty.
+ */
+ public boolean isEmpty(){
+ return this.changes.isEmpty();
+ }
+
+
+ @Override
+ public String toString() {
+ return "ConfigurationChange{" +
+ "configuration=" + configuration +
+ ", version='" + version + '\'' +
+ ", timestamp=" + timestamp +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java b/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
new file mode 100644
index 0000000..1fd228a
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
@@ -0,0 +1,274 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
+ * can observing changes to property sources and
+ * <ol>
+ * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
+ * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
+ * change, its only the data of the property source).</li>
+ * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
+ * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
+ * event on configuration level.
+ * </ol>
+ */
+public final class ConfigurationChangeBuilder {
+ /**
+ * The recorded changes.
+ */
+ final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
+ /**
+ * The underlying configuration/provider.
+ */
+ final Configuration source;
+ /**
+ * The version configured, or null, for generating a default.
+ */
+ String version;
+ /**
+ * The optional timestamp in millis of this epoch.
+ */
+ Long timestamp;
+
+ /**
+ * Constructor.
+ *
+ * @param configuration the underlying configuration, not null.
+ */
+ private ConfigurationChangeBuilder(Configuration configuration) {
+ this.source = Objects.requireNonNull(configuration);
+ }
+
+ /**
+ * Creates a new instance current this builder using the current COnfiguration as root resource.
+ *
+ * @return the builder for chaining.
+ */
+ public static ConfigurationChangeBuilder of() {
+ return new ConfigurationChangeBuilder(ConfigurationProvider.getConfiguration());
+ }
+
+ /**
+ * Creates a new instance current this builder.
+ *
+ * @param configuration the configuration changed, not null.
+ * @return the builder for chaining.
+ */
+ public static ConfigurationChangeBuilder of(Configuration configuration) {
+ return new ConfigurationChangeBuilder(configuration);
+ }
+
+ /**
+ * Compares the two property config/configurations and creates a collection current all changes
+ * that must be appied to render {@code map1} into {@code map2}.
+ *
+ * @param map1 the source map, not null.
+ * @param map2 the target map, not null.
+ * @return a collection current change events, never null.
+ */
+ public static Collection<PropertyChangeEvent> compare(Configuration map1, Configuration map2) {
+ List<PropertyChangeEvent> changes = new ArrayList<>();
+ for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
+ String val = map2.get(en.getKey());
+ if (val == null) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
+ } else if (!val.equals(en.getValue())) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
+ }
+ }
+ for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
+ String val = map1.get(en.getKey());
+ if (val == null) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
+ } else if (!val.equals(en.getValue())) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
+ }
+ }
+ return changes;
+ }
+
+ /*
+ * Apply a version/UUID to the set being built.
+ * @param version the version to apply, or null, to let the system generate a version for you.
+ * @return the builder for chaining.
+ */
+ public ConfigurationChangeBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ /*
+ * Apply given timestamp to the set being built.
+ * @param version the version to apply, or null, to let the system generate a version for you.
+ * @return the builder for chaining.
+ */
+ public ConfigurationChangeBuilder setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ /**
+ * This method records all changes to be applied to the base property provider/configuration to
+ * achieve the given target state.
+ *
+ * @param newState the new target state, not null.
+ * @return the builder for chaining.
+ */
+ public ConfigurationChangeBuilder addChanges(Configuration newState) {
+ for (PropertyChangeEvent c : compare(newState, this.source)) {
+ this.delta.put(c.getPropertyName(), c);
+ }
+ return this;
+ }
+
+ /**
+ * Applies a single key/value change.
+ *
+ * @param key the changed key
+ * @param value the new value.
+ * @return this instance for chining.
+ */
+ public ConfigurationChangeBuilder addChange(String key, String value) {
+ this.delta.put(key, new PropertyChangeEvent(this.source, key, this.source.get(key), value));
+ return this;
+ }
+
+ /**
+ * Get the current values, also considering any changes recorded within this change set.
+ *
+ * @param key the key current the entry, not null.
+ * @return the keys, or null.
+ */
+ public String get(String key) {
+ PropertyChangeEvent change = this.delta.get(key);
+ if (change != null && !(change.getNewValue() == null)) {
+ return (String) change.getNewValue();
+ }
+ return null;
+ }
+
+ /**
+ * Marks the given key(s) fromMap the configuration/properties to be removed.
+ *
+ * @param key the key current the entry, not null.
+ * @param otherKeys additional keys to be removed (convenience), not null.
+ * @return the builder for chaining.
+ */
+ public ConfigurationChangeBuilder removeKey(String key, String... otherKeys) {
+ String oldValue = this.source.get(key);
+ if (oldValue == null) {
+ this.delta.remove(key);
+ }
+ this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
+ for (String addKey : otherKeys) {
+ oldValue = this.source.get(addKey);
+ if (oldValue == null) {
+ this.delta.remove(addKey);
+ }
+ this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
+ }
+ return this;
+ }
+
+ /**
+ * Apply all the given values to the base configuration/properties.
+ * Note that all values passed must be convertible to String, either
+ * <ul>
+ * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
+ * <li>default codecs are present for the given type, or</li>
+ * <li>the value is an instanceof String</li>
+ * </ul>
+ *
+ * @param changes the changes to be applied, not null.
+ * @return the builder for chaining.
+ */
+ public ConfigurationChangeBuilder putAll(Map<String, String> changes) {
+ for (Map.Entry<String, String> en : changes.entrySet()) {
+ this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
+ }
+ return this;
+ }
+
+ /**
+ * This method will create a change set that clears all entries fromMap the given base configuration/properties.
+ *
+ * @return the builder for chaining.
+ */
+ public ConfigurationChangeBuilder removeAllKeys() {
+ this.delta.clear();
+ for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
+ this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
+ }
+// this.source.getProperties().forEach((k, v) ->
+// this.delta.put(k, new PropertyChangeEvent(this.source, k, v, null)));
+ return this;
+ }
+
+ /**
+ * Checks if the change set is empty, i.e. does not contain any changes.
+ *
+ * @return true, if the set is empty.
+ */
+ public boolean isEmpty() {
+ return this.delta.isEmpty();
+ }
+
+ /**
+ * Resets this change set instance. This will clear all changes done to this builder, so the
+ * set will be empty.
+ */
+ public void reset() {
+ this.delta.clear();
+ }
+
+ /**
+ * Builds the corresponding change set.
+ *
+ * @return the new change set, never null.
+ */
+ public ConfigurationChange build() {
+ return new ConfigurationChange(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "ConfigurationChangeSetBuilder [config=" + source + ", " +
+ ", delta=" + delta + "]";
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
new file mode 100644
index 0000000..4e12d42
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
@@ -0,0 +1,210 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Event that contains a set of current changes that were applied or can be applied.
+ * This class is immutable and thread-safe. To create instances use
+ * {@link PropertySourceChangeBuilder}.
+ *
+ * Created by Anatole on 22.10.2014.
+ */
+public final class ConfigurationContextChange implements ConfigEvent<ConfigurationContext>, Serializable{
+
+ private static final long serialVersionUID = 1L;
+ /** The base property provider/configuration. */
+ private final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
+ /** The base version, usable for optimistic locking. */
+ private String version = UUID.randomUUID().toString();
+ /** The timestamp of the change set in millis from the epoch. */
+ private long timestamp = System.currentTimeMillis();
+ /** The configuration context. */
+ private final ConfigurationContext configurationContext;
+
+ /**
+ * Get an empty change set for the given provider.
+ *
+ * @param configurationContext context to use for creating changesets.
+ * @return an empty ConfigurationContextChange instance.
+ */
+ public static ConfigurationContextChange emptyChangeSet(ConfigurationContext configurationContext){
+ return ConfigurationContextChangeBuilder.of(configurationContext).build();
+ }
+
+ /**
+ * Constructor used by {@link PropertySourceChangeBuilder}.
+ * @param builder The builder used, not null.
+ */
+ ConfigurationContextChange(ConfigurationContextChangeBuilder builder) {
+ this.changedPropertySources.addAll(builder.changedPropertySources);
+ if(builder.version!=null){
+ this.version = builder.version;
+ }
+ if(builder.timestamp!=null){
+ this.timestamp = builder.timestamp;
+ }
+ this.configurationContext = builder.configurationContext;
+ }
+
+ @Override
+ public Class<ConfigurationContext> getResourceType() {
+ return ConfigurationContext.class;
+ }
+
+ @Override
+ public ConfigurationContext getResource() {
+ return configurationContext;
+ }
+
+ /**
+ * Get the base version, usable for optimistic locking.
+ * @return the base version.
+ */
+ @Override
+ public String getVersion(){
+ return version;
+ }
+
+ /**
+ * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
+ * identify a changeset.
+ * @return the timestamp, when this changeset was created.
+ */
+ @Override
+ public long getTimestamp(){
+ return timestamp;
+ }
+
+ /**
+ * Get the changes recorded.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertySourceChange> getPropertySourceChanges(){
+ return Collections.unmodifiableCollection(this.changedPropertySources);
+ }
+
+ /**
+ * Get the property source updates.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertySourceChange> getPropertySourceUpdates(){
+ List<PropertySourceChange> result = new ArrayList<>();
+ for (PropertySourceChange pc : this.changedPropertySources) {
+ if (pc.getChangeType() == ChangeType.UPDATED) {
+ result.add(pc);
+ }
+ }
+ return result;
+// return Collections.unmodifiableCollection(this.changedPropertySources).stream()
+// .filter(pc -> pc.getChangeType()==ChangeType.UPDATED).collect(Collectors.toList());
+ }
+
+ /**
+ * Get the property sources to be removed.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertySource> getRemovedPropertySources(){
+ List<PropertySource> result = new ArrayList<>();
+ for (PropertySourceChange pc : this.changedPropertySources) {
+ if (pc.getChangeType() == ChangeType.DELETED) {
+ result.add(pc.getResource());
+ }
+ }
+ return result;
+// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.DELETED).
+// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
+ }
+
+ /**
+ * Get the property sources to be added.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertySource> getAddedPropertySources(){
+ List<PropertySource> result = new ArrayList<>();
+ for (PropertySourceChange pc : this.changedPropertySources) {
+ if (pc.getChangeType() == ChangeType.NEW) {
+ result.add(pc.getResource());
+ }
+ }
+ return result;
+// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.NEW).
+// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
+ }
+
+ /**
+ * Get the property sources to be updated.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertySource> getUpdatedPropertySources(){
+ List<PropertySource> result = new ArrayList<>();
+ for (PropertySourceChange pc : this.changedPropertySources) {
+ if (pc.getChangeType() == ChangeType.UPDATED) {
+ result.add(pc.getResource());
+ }
+ }
+ return result;
+// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.UPDATED).
+// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
+ }
+
+ /**
+ * Checks if the given propertySource is affected (added, changed or removed).
+ * @param propertySource the propertySource, not null.
+ * @return true, if the given propertySource ia affected.
+ */
+ public boolean isAffected(PropertySource propertySource) {
+ for (PropertySourceChange ps : this.changedPropertySources) {
+ if (ps.getResource() == propertySource ||
+ ps.getResource().getName().equals(propertySource.getName())) {
+ return true;
+ }
+ }
+ return false;
+// return this.changedPropertySources.stream().filter(ps -> ps.getPropertySource()==propertySource ||
+// ps.getPropertySource().getName().equals(propertySource.getName())).findAny().isPresent();
+ }
+
+ /**
+ * CHecks if the current change set does not contain any changes.
+ * @return tru, if the change set is empty.
+ */
+ public boolean isEmpty(){
+ return this.changedPropertySources.isEmpty();
+ }
+
+
+ @Override
+ public String toString() {
+ return "ConfigurationContextChange{" +
+ "changedPropertySources=" + changedPropertySources +
+ ", version='" + version + '\'' +
+ ", timestamp=" + timestamp +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
new file mode 100644
index 0000000..b586428
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
@@ -0,0 +1,174 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Models a set of current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
+ * can observe changes to property sources and
+ * <ol>
+ * <li>check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
+ * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference to a property source is never affected by a
+ * change, it is the data of the property source only).</li>
+ * <li>if so, a corresponding action may be taken, such as reevaluating the configuration values (depending on
+ * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
+ * event on configuration level.
+ * </ol>
+ */
+public final class ConfigurationContextChangeBuilder {
+ /**
+ * The recorded changes.
+ */
+ final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
+ /**
+ * The version configured, or null, for generating a default.
+ */
+ String version;
+ /**
+ * The optional timestamp in millis of this epoch.
+ */
+ Long timestamp;
+
+ final ConfigurationContext configurationContext;
+
+ /**
+ * Constructor.
+ */
+ private ConfigurationContextChangeBuilder(ConfigurationContext configurationContext) {
+ this.configurationContext = Objects.requireNonNull(configurationContext);
+ }
+
+ /**
+ * Just creates a new ConfigurationContextBuilder using the current COnfigurationContext has root resource.
+ * @return a new ConfigurationContextBuilder, never null.
+ */
+ public static ConfigurationContextChangeBuilder of() {
+ return of(ConfigurationProvider.getConfigurationContext());
+ }
+
+ /**
+ * Creates a new instance current this builder.
+ *
+ * @param context context to use for creating changesets.
+ * @return the builder for chaining.
+ */
+ public static ConfigurationContextChangeBuilder of(ConfigurationContext context) {
+ return new ConfigurationContextChangeBuilder(context);
+ }
+
+ /**
+ * Apply a version/UUID to the set being built.
+ * @param version the version to apply, or null, to let the system generate a version for you.
+ * @return the builder for chaining.
+ */
+ public ConfigurationContextChangeBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ /**
+ * Apply given timestamp to the set being built.
+ * @param timestamp timestamp to set.
+ * @return the builder for chaining.
+ */
+ public ConfigurationContextChangeBuilder setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ /**
+ * This method records all changes to be applied to the base property provider/configuration to
+ * achieve the given target state.
+ *
+ * @param propertySource the new target state, not null.
+ * @return the builder for chaining.
+ */
+ public ConfigurationContextChangeBuilder newPropertySource(PropertySource propertySource) {
+ this.changedPropertySources.add(PropertySourceChange.ofAdded(propertySource));
+ return this;
+ }
+
+ /**
+ * This method records all changes to be applied to the base property provider/configuration to
+ * achieve the given target state.
+ *
+ * @param propertySource the new target state, not null.
+ * @return the builder for chaining.
+ */
+ public ConfigurationContextChangeBuilder removedPropertySource(PropertySource propertySource) {
+ this.changedPropertySources.add(PropertySourceChange.ofDeleted(propertySource));
+ return this;
+ }
+
+ /**
+ * This method records all changes to be applied to the base property provider/configuration to
+ * achieve the given target state.
+ *
+ * @param propertySourceChange the change state, not null.
+ * @return the builder for chaining.
+ */
+ public ConfigurationContextChangeBuilder changedPropertySource(PropertySourceChange propertySourceChange) {
+ this.changedPropertySources.add(Objects.requireNonNull(propertySourceChange));
+ return this;
+ }
+
+ /**
+ * Checks if the change set is empty, i.e. does not contain any changes.
+ *
+ * @return true, if the set is empty.
+ */
+ public boolean isEmpty() {
+ return this.changedPropertySources.isEmpty();
+ }
+
+ /**
+ * Resets this change set instance. This will clear all changes done to this builder, so the
+ * set will be empty.
+ */
+ public void reset() {
+ this.changedPropertySources.clear();
+ }
+
+ /**
+ * Builds the corresponding change set.
+ *
+ * @return the new change set, never null.
+ */
+ public ConfigurationContextChange build() {
+ return new ConfigurationContextChange(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "ConfigurationContextChangeBuilder [propertySources=" + changedPropertySources + "]";
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
new file mode 100644
index 0000000..304ddba
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
@@ -0,0 +1,194 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.ConfigOperator;
+import org.apache.tamaya.ConfigQuery;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.functions.ConfigurationFunctions;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * /**
+ * Configuration implementation that stores all current values of a given (possibly dynamic, contextual and non server
+ * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
+ */
+public final class FrozenConfiguration implements Configuration, Serializable {
+ private static final long serialVersionUID = -6373137316556444171L;
+ /**
+ * The properties frozen.
+ */
+ private Map<String, String> properties = new HashMap<>();
+
+ /**
+ * Constructor.
+ *
+ * @param config The base configuration.
+ */
+ private FrozenConfiguration(Configuration config) {
+ this.properties.putAll(config.getProperties());
+ this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
+ this.properties = Collections.unmodifiableMap(this.properties);
+ }
+
+ /**
+ * Creates a new FrozenConfiguration instance based on a Configuration given.
+ *
+ * @param config the configuration to be frozen, not null.
+ * @return the frozen Configuration.
+ */
+ public static FrozenConfiguration of(Configuration config) {
+ if (config instanceof FrozenConfiguration) {
+ return (FrozenConfiguration) config;
+ }
+ return new FrozenConfiguration(config);
+ }
+
+ @Override
+ public String get(String key) {
+ return this.properties.get(key);
+ }
+
+ @Override
+ public String getOrDefault(String key, String defaultValue) {
+ String val = get(key);
+ if(val==null){
+ return defaultValue;
+ }
+ return val;
+ }
+
+ @Override
+ public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
+ T val = get(key, type);
+ if(val==null){
+ return defaultValue;
+ }
+ return val;
+ }
+
+ @Override
+ public <T> T get(String key, Class<T> type) {
+ return (T) get(key, TypeLiteral.of(type));
+ }
+
+ /**
+ * Accesses the current String value for the given key and tries to convert it
+ * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
+ * {@link org.apache.tamaya.spi.ConfigurationContext}.
+ *
+ * @param key the property's absolute, or relative path, e.g. @code
+ * a/b/c/d.myProperty}.
+ * @param type The target type required, not null.
+ * @param <T> the value type
+ * @return the converted value, never null.
+ */
+ @Override
+ public <T> T get(String key, TypeLiteral<T> type) {
+ String value = get(key);
+ if (value != null) {
+ List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
+ .getPropertyConverters(type);
+ ConversionContext context = new ConversionContext.Builder(this,
+ ConfigurationProvider.getConfigurationContext(), key,type).build();
+ for (PropertyConverter<T> converter : converters) {
+ try {
+ T t = converter.convert(value, context);
+ if (t != null) {
+ return t;
+ }
+ } catch (Exception e) {
+ Logger.getLogger(getClass().getName())
+ .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value,
+ e);
+ }
+ }
+ throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key
+ + ", supported formats: " + context.getSupportedFormats());
+ }
+
+ return null;
+ }
+
+ @Override
+ public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
+ T val = get(key, type);
+ if(val==null){
+ return defaultValue;
+ }
+ return val;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public Configuration with(ConfigOperator operator) {
+ return operator.operate(this);
+ }
+
+ @Override
+ public <T> T query(ConfigQuery<T> query) {
+ return query.query(this);
+ }
+
+ @Override
+ public ConfigurationContext getContext() {
+ return ConfigurationFunctions.emptyConfigurationContext();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ FrozenConfiguration that = (FrozenConfiguration) o;
+ return properties.equals(that.properties);
+ }
+
+ @Override
+ public int hashCode() {
+ return properties.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "FrozenConfiguration{" +
+ "properties=" + properties +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
new file mode 100644
index 0000000..81e6dca
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
@@ -0,0 +1,126 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PropertySource implementation that stores all current values of a given (possibly dynamic, contextual and non server
+ * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
+ */
+public final class FrozenPropertySource implements PropertySource, Serializable {
+ private static final long serialVersionUID = -6373137316556444171L;
+ /**
+ * The ordinal.
+ */
+ private final int ordinal;
+ /**
+ * The properties read.
+ */
+ private Map<String, String> properties = new HashMap<>();
+ /**
+ * The PropertySource's name.
+ */
+ private final String name;
+
+ /**
+ * Constructor.
+ *
+ * @param propertySource The base PropertySource.
+ */
+ private FrozenPropertySource(PropertySource propertySource) {
+ this.properties.putAll(propertySource.getProperties());
+ this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
+ this.properties = Collections.unmodifiableMap(this.properties);
+ this.ordinal = propertySource.getOrdinal();
+ this.name = propertySource.getName();
+ }
+
+ /**
+ * Creates a new FrozenPropertySource instance based on a PropertySource given.
+ *
+ * @param propertySource the property source to be frozen, not null.
+ * @return the frozen property source.
+ */
+ public static FrozenPropertySource of(PropertySource propertySource) {
+ if (propertySource instanceof FrozenPropertySource) {
+ return (FrozenPropertySource) propertySource;
+ }
+ return new FrozenPropertySource(propertySource);
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public int getOrdinal() {
+ return this.ordinal;
+ }
+
+ @Override
+ public PropertyValue get(String key) {
+ return PropertyValue.of(key, this.properties.get(key), getName());
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public boolean isScannable() {
+ return true;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof FrozenPropertySource)) {
+ return false;
+ }
+ FrozenPropertySource that = (FrozenPropertySource) o;
+ return ordinal == that.ordinal && properties.equals(that.properties);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = ordinal;
+ result = 31 * result + properties.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "FrozenPropertySource{" +
+ "name=" + name +
+ ", ordinal=" + ordinal +
+ ", properties=" + properties +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java b/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
new file mode 100644
index 0000000..063612c
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
@@ -0,0 +1,242 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.beans.PropertyChangeEvent;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Event that contains a set current changes that were applied or could be applied.
+ * This class is immutable and thread-safe. To create instances use
+ * {@link PropertySourceChangeBuilder}.
+ *
+ * Created by Anatole on 22.10.2014.
+ */
+public final class PropertySourceChange implements ConfigEvent<PropertySource>, Serializable{
+
+ private static final long serialVersionUID = 1L;
+ /** The base property provider/configuration. */
+ private final FrozenPropertySource propertySource;
+ /** The base version, usable for optimistic locking. */
+ private String version = UUID.randomUUID().toString();
+ /** The timestamp of the change set in millis from the epoch. */
+ private long timestamp = System.currentTimeMillis();
+ /** The recorded changes. */
+ private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
+ /** The overall type of change. */
+ private final ChangeType changeType;
+
+ /**
+ * Constructor used by {@link PropertySourceChangeBuilder}.
+ * @param builder The builder used, not null.
+ */
+ PropertySourceChange(PropertySourceChangeBuilder builder) {
+ this.propertySource = FrozenPropertySource.of(builder.source);
+ for (PropertyChangeEvent c : builder.delta.values()) {
+ this.changes.put(c.getPropertyName(), c);
+ }
+ if(builder.version!=null){
+ this.version = builder.version;
+ }
+ if(builder.timestamp!=null){
+ this.timestamp = builder.timestamp;
+ }
+ this.changeType = builder.changeType;
+ }
+
+ /**
+ * Gets the type of change for this PropertySource.
+ * @return the type of change for this PropertySource, never null.
+ */
+ public ChangeType getChangeType(){
+ return this.changeType;
+ }
+
+ @Override
+ public Class<PropertySource> getResourceType() {
+ return PropertySource.class;
+ }
+
+ /**
+ * Get the underlying property provider/configuration.
+ * @return the underlying property provider/configuration, or null, if the change instance was deserialized.
+ */
+ @Override
+ public PropertySource getResource(){
+ return this.propertySource;
+ }
+
+ /**
+ * Get the base version, usable for optimistic locking.
+ * @return the base version.
+ */
+ @Override
+ public String getVersion(){
+ return version;
+ }
+
+ /**
+ * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
+ * identify a changeset.
+ * @return the timestamp, when this changeset was created.
+ */
+ @Override
+ public long getTimestamp(){
+ return timestamp;
+ }
+
+ /**
+ * Get the changes recorded.
+ * @return the recorded changes, never null.
+ */
+ public Collection<PropertyChangeEvent> getChanges(){
+ return Collections.unmodifiableCollection(this.changes.values());
+ }
+
+ /**
+ * Access the number current removed entries.
+ * @return the number current removed entries.
+ */
+ public int getRemovedSize() {
+ int removedCount = 0;
+ for (PropertyChangeEvent ev : this.changes.values()) {
+ if (ev.getNewValue() == null) {
+ removedCount++;
+ }
+ }
+ return removedCount;
+// return (int) this.changes.values().stream().filter((e) -> e.getNewValue() == null).count();
+ }
+
+ /**
+ * Access the number current added entries.
+ * @return the number current added entries.
+ */
+ public int getAddedSize() {
+ int addedCount = 0;
+ for (PropertyChangeEvent ev : this.changes.values()) {
+ if (ev.getOldValue() == null &&
+ ev.getNewValue() != null) {
+ addedCount++;
+ }
+ }
+ return addedCount;
+// return (int) this.changes.values().stream().filter((e) -> e.getOldValue() == null).count();
+ }
+
+ /**
+ * Access the number current updated entries.
+ * @return the number current updated entries.
+ */
+ public int getUpdatedSize() {
+ int updatedCount = 0;
+ for (PropertyChangeEvent ev : this.changes.values()) {
+ if (ev.getOldValue() != null && ev.getNewValue() != null) {
+ updatedCount++;
+ }
+ }
+ return updatedCount;
+// return (int) this.changes.values().stream().filter((e) -> e.getOldValue()!=null && e.getNewValue()!=null).count();
+ }
+
+
+ /**
+ * Checks if the given key was removed.
+ * @param key the target key, not null.
+ * @return true, if the given key was removed.
+ */
+ public boolean isRemoved(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getNewValue() == null;
+ }
+
+ /**
+ * Checks if the given key was added.
+ * @param key the target key, not null.
+ * @return true, if the given key was added.
+ */
+ public boolean isAdded(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getOldValue() == null;
+ }
+
+ /**
+ * Checks if the given key was updated.
+ * @param key the target key, not null.
+ * @return true, if the given key was updated.
+ */
+ public boolean isUpdated(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getOldValue() != null && change.getNewValue() != null;
+ }
+
+ /**
+ * Checks if the given key is added, or updated AND NOT removed.
+ * @param key the target key, not null.
+ * @return true, if the given key was added, or updated BUT NOT removed.
+ */
+ public boolean isKeyAffected(String key) {
+ PropertyChangeEvent change = this.changes.get(key);
+ return change != null && change.getNewValue() != null;
+ }
+
+ /**
+ * CHecks if the current change set does not contain any changes.
+ * @return tru, if the change set is empty.
+ */
+ public boolean isEmpty(){
+ return this.changes.isEmpty();
+ }
+
+
+ /**
+ * Create a change event for a new PropertySource that was added.
+ * @param propertySource the new property source, not null.
+ * @return a new PropertySourceChange, representing a PropertySource that was added.
+ */
+ public static PropertySourceChange ofAdded(PropertySource propertySource) {
+ return PropertySourceChangeBuilder.of(propertySource, ChangeType.NEW).build();
+ }
+
+ /**
+ * Create a change event for a deleted PropertySource.
+ * @param propertySource the deleted property source, not null.
+ * @return a new PropertySourceChange, representing a PropertySource that was deleted.
+ */
+ public static PropertySourceChange ofDeleted(PropertySource propertySource) {
+ return PropertySourceChangeBuilder.of(propertySource, ChangeType.DELETED).build();
+ }
+
+ @Override
+ public String toString() {
+ return "PropertySourceChange{" +
+ "changeType=" + changeType +
+ ", propertySource=" + propertySource +
+ ", version='" + version + '\'' +
+ ", timestamp=" + timestamp +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
new file mode 100644
index 0000000..b7a4483
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -0,0 +1,263 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
+ * can observing changes to property sources and
+ * <ol>
+ * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
+ * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
+ * change, its only the data of the property source).</li>
+ * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
+ * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
+ * event on configuration level.
+ * </ol>
+ */
+public final class PropertySourceChangeBuilder {
+ /**
+ * The recorded changes.
+ */
+ final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
+ /**
+ * The underlying configuration/provider.
+ */
+ final PropertySource source;
+ /**
+ * The version configured, or null, for generating a default.
+ */
+ String version;
+ /**
+ * The optional timestamp in millis of this epoch.
+ */
+ Long timestamp;
+
+ /** The type of change. */
+ ChangeType changeType;
+
+ /**
+ * Constructor.
+ *
+ * @param source the underlying configuration/provider, not null.
+ * @param changeType kind of change.
+ */
+ private PropertySourceChangeBuilder(PropertySource source, ChangeType changeType) {
+ this.source = Objects.requireNonNull(source);
+ this.changeType = Objects.requireNonNull(changeType);
+ }
+
+ /**
+ * Creates a new instance of this builder.
+ *
+ * @param source the underlying property provider/configuration, not null.
+ * @param changeType kind of change.
+ * @return the builder for chaining.
+ */
+ public static PropertySourceChangeBuilder of(PropertySource source, ChangeType changeType) {
+ return new PropertySourceChangeBuilder(source, changeType);
+ }
+
+ /**
+ * Compares the two property config/configurations and creates a collection current all changes
+ * that must be applied to render {@code map1} into {@code map2}.
+ *
+ * @param map1 the source map, not null.
+ * @param map2 the target map, not null.
+ * @return a collection current change events, never null.
+ */
+ public static Collection<PropertyChangeEvent> compare(PropertySource map1, PropertySource map2) {
+ List<PropertyChangeEvent> changes = new ArrayList<>();
+ for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
+ PropertyValue val = map2.get(en.getKey());
+ if (val == null) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
+ } else if (!val.getValue().equals(en.getValue())) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue()));
+ }
+ }
+ for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
+ PropertyValue val = map1.get(en.getKey());
+ if (val == null) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), null));
+ } else if (!val.equals(en.getValue())) {
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), val.getValue()));
+ }
+ }
+ return changes;
+ }
+
+ /*
+ * Apply a version/UUID to the set being built.
+ * @param version the version to apply, or null, to let the system generate a version for you.
+ * @return the builder for chaining.
+ */
+ public PropertySourceChangeBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ /*
+ * Apply given timestamp to the set being built.
+ * @param version the version to apply, or null, to let the system generate a version for you.
+ * @return the builder for chaining.
+ */
+ public PropertySourceChangeBuilder setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ /**
+ * This method records all changes to be applied to the base property provider/configuration to
+ * achieve the given target state.
+ *
+ * @param newState the new target state, not null.
+ * @return the builder for chaining.
+ */
+ public PropertySourceChangeBuilder addChanges(PropertySource newState) {
+ Collection<PropertyChangeEvent> events = PropertySourceChangeBuilder.compare(newState, this.source);
+ for (PropertyChangeEvent c : events) {
+ this.delta.put(c.getPropertyName(), c);
+ }
+ return this;
+ }
+
+ /**
+ * Get the current values, also considering any changes recorded within this change set.
+ *
+ * @param key the key current the entry, not null.
+ * @return the keys, or null.
+ */
+ public String get(String key) {
+ PropertyChangeEvent change = this.delta.get(key);
+ if (change != null && !(change.getNewValue() == null)) {
+ return (String) change.getNewValue();
+ }
+ return null;
+ }
+
+ /**
+ * Marks the given key(s) fromMap the configuration/properties to be removed.
+ *
+ * @param key the key current the entry, not null.
+ * @param otherKeys additional keys to be removed (convenience), not null.
+ * @return the builder for chaining.
+ */
+ public PropertySourceChangeBuilder remove(String key, String... otherKeys) {
+ PropertyValue oldValue = this.source.get(key);
+ if (oldValue == null) {
+ this.delta.remove(key);
+ }
+ this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
+ for (String addKey : otherKeys) {
+ oldValue = this.source.get(addKey);
+ if (oldValue == null) {
+ this.delta.remove(addKey);
+ }
+ this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
+ }
+ return this;
+ }
+
+ /**
+ * Apply all the given values to the base configuration/properties.
+ * Note that all values passed must be convertible to String, either
+ * <ul>
+ * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
+ * <li>default codecs are present for the given type, or</li>
+ * <li>the value is an instanceof String</li>
+ * </ul>
+ *
+ * @param changes the changes to be applied, not null.
+ * @return the builder for chaining.
+ */
+ public PropertySourceChangeBuilder putAll(Map<String, String> changes) {
+ for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
+ this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
+ }
+ return this;
+ }
+
+ /**
+ * This method will create a change set that clears all entries fromMap the given base configuration/properties.
+ *
+ * @return the builder for chaining.
+ */
+ public PropertySourceChangeBuilder deleteAll() {
+ this.delta.clear();
+ for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
+ this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
+ }
+ return this;
+ }
+
+ /**
+ * Checks if the change set is empty, i.e. does not contain any changes.
+ *
+ * @return true, if the set is empty.
+ */
+ public boolean isEmpty() {
+ return this.delta.isEmpty();
+ }
+
+ /**
+ * Resets this change set instance. This will clear all changes done to this builder, so the
+ * set will be empty.
+ */
+ public void reset() {
+ this.delta.clear();
+ }
+
+ public PropertySourceChangeBuilder setChangeType(ChangeType changeType) {
+ this.changeType = changeType;
+ return this;
+ }
+
+ /**
+ * Builds the corresponding change set.
+ *
+ * @return the new change set, never null.
+ */
+ public PropertySourceChange build() {
+ return new PropertySourceChange(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "PropertiesChangeBuilder [source=" + source + ", " +
+ ", delta=" + delta + "]";
+ }
+
+
+}
[12/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare for next development iteration
Posted by pl...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/b42c4ad1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/b42c4ad1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/b42c4ad1
Branch: refs/heads/old_master
Commit: b42c4ad1d0e39343967e481f33b86b909f85a0c3
Parents: 14b9e6e
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 20:39:16 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b42c4ad1/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0fece2a..e843ec8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-events</artifactId>
[04/50] [abbrv] incubator-tamaya-extensions git commit: Fixed UI
module, adding modularity. Added initial version for the vents module.
Posted by pl...@apache.org.
Fixed UI module, adding modularity. Added initial version for the vents module.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/f3d32886
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/f3d32886
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/f3d32886
Branch: refs/heads/old_master
Commit: f3d3288621598c622defb8ab33bf09cf7f9ff056
Parents: 3833438
Author: anatole <an...@apache.org>
Authored: Sat Apr 16 08:21:36 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 14 ++++++++++++--
.../ObservingPropertySourceProvider.java | 3 ++-
2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/f3d32886/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d43379c..7294789 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,6 @@ under the License.
<groupId>org.apache.tamaya</groupId>
<artifactId>tamaya-api</artifactId>
<version>${project.version}</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tamaya.ext</groupId>
@@ -48,10 +47,21 @@ under the License.
<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</groupId>
<artifactId>tamaya-core</artifactId>
<version>${project.version}</version>
- <scope>provided</scope>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-ui</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/f3d32886/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
index 347576f..feddd70 100644
--- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
@@ -40,12 +40,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.propertysource.BasePropertySource;
import org.apache.tamaya.events.ConfigEventManager;
import org.apache.tamaya.events.ConfigurationContextChange;
import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertySourceProvider;
+import org.apache.tamaya.spisupport.BasePropertySource;
/**
* This implementation runs in a folder taking up all files compatible with the given
@@ -118,6 +118,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
protected Collection<PropertySource> getPropertySources(final Path file) {
return Arrays.asList(new PropertySource[]{new BasePropertySource() {
private final Map<String,String> props = readProperties(file);
+
@Override
public Map<String, String> getProperties() {
return props;
[36/50] [abbrv] incubator-tamaya-extensions git commit: Synched with
head.
Posted by pl...@apache.org.
Synched with head.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/b16020f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/b16020f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/b16020f4
Branch: refs/heads/old_master
Commit: b16020f4a0bae22110f34e2b25f11c994b9c1e6a
Parents: 3fffcb0
Author: anatole <an...@apache.org>
Authored: Thu Feb 11 20:31:24 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../apache/tamaya/filter/ConfigurationFilter.java | 15 ++++++++++++---
.../org/apache/tamaya/filter/ProgrammableFilter.java | 6 +++---
.../apache/tamaya/filter/RegexPropertyFilter.java | 2 +-
.../filter/internal/DefaultMetadataFilter.java | 2 +-
4 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b16020f4/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
index 99ab27f..30ba3e2 100644
--- a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
@@ -62,12 +62,21 @@ public final class ConfigurationFilter implements PropertyFilter{
};
/**
+ * Flag if metadata entries (starting with an '_') are filtered out on when accessing multiple properties, default
+ * is {@code true}.
+ * @return true, if metadata entries (starting with an '_') are to be filtered.
+ */
+ public static boolean isMetadataFiltered(){
+ return THREADED_METADATA_FILTERED.get();
+ }
+
+ /**
* Seactivates metadata filtering also on global map access for this thread.
* @see #clearFilters()
- * @param active true,to enable metadata filtering (default).
+ * @param filtered true,to enable metadata filtering (default).
*/
- public static void setMetadataFilter(boolean active){
- THREADED_METADATA_FILTERED.set(active);
+ public static void setMetadataFiltered(boolean filtered){
+ THREADED_METADATA_FILTERED.set(filtered);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b16020f4/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java b/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
index 8589faa..18a7e08 100644
--- a/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
@@ -80,8 +80,8 @@ public final class ProgrammableFilter implements PropertyFilter{
* @param filters the filters to be applied.
*/
public void setFilters(Collection<PropertyFilter> filters) {
- filters.clear();
- filters.addAll(filters);
+ this.filters.clear();
+ this.filters.addAll(filters);
}
/**
@@ -102,7 +102,7 @@ public final class ProgrammableFilter implements PropertyFilter{
@Override
public String toString() {
- return "FilterConfig{" +
+ return "ProgrammableFilter{" +
"filters=" + filters +
'}';
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b16020f4/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java b/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
index 616f2cf..1ed43ba 100644
--- a/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
@@ -48,7 +48,7 @@ public final class RegexPropertyFilter implements PropertyFilter{
@Override
public String toString() {
- return "RegexPredicate{" +
+ return "RegexPropertyFilter{" +
"expression='" + expression + '\'' +
'}';
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/b16020f4/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java b/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
index 1119cba..95e9d25 100644
--- a/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
@@ -32,7 +32,7 @@ public final class DefaultMetadataFilter implements PropertyFilter{
// When accessing keys explicitly, do not hide anything.
return valueToBeFiltered;
}
- if(ConfigurationFilter.THREADED_METADATA_FILTERED.get()) {
+ if(ConfigurationFilter.isMetadataFiltered()) {
if (context.getKey().startsWith("_")) {
// Hide metadata entries.
return null;
[48/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare for next development iteration
Posted by pl...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/a23ed993
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/a23ed993
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/a23ed993
Branch: refs/heads/old_master
Commit: a23ed993ecaa42be9ac4f70ec29b8af2aabc3a1a
Parents: 566982c
Author: anatole <an...@apache.org>
Authored: Wed Mar 16 16:20:17 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/a23ed993/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a59a968..d9d4854 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[18/50] [abbrv] incubator-tamaya-extensions git commit: Reset version,
integrated docs into site.
Posted by pl...@apache.org.
Reset version, integrated docs into site.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/c5a7508c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/c5a7508c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/c5a7508c
Branch: refs/heads/old_master
Commit: c5a7508c6527f41bba93520b9ec9e3eca911ed88
Parents: 4299859
Author: anatole <an...@apache.org>
Authored: Wed Mar 16 21:54:18 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/c5a7508c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d43379c..0535316 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
+ <version>0.2-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-events</artifactId>
[26/50] [abbrv] incubator-tamaya-extensions git commit: Unified
module name in poms.
Posted by pl...@apache.org.
Unified module name in poms.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/e0cd6576
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/e0cd6576
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/e0cd6576
Branch: refs/heads/old_master
Commit: e0cd6576c85086b3c788932ba75301b95ad5d559
Parents: fefbeca
Author: anatole <an...@apache.org>
Authored: Sat Jan 16 07:40:08 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e0cd6576/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f5b384b..9d2f59d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@ under the License.
</parent>
<artifactId>tamaya-events</artifactId>
- <name>Apache Tamaya Event and dynamic Update Extensions</name>
+ <name>Apache Tamaya Modules - Event and dynamic Update Extensions</name>
<packaging>bundle</packaging>
<properties>
[06/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-136:
Adding PropertyValue for PropertySource SPI. All changes and test fixes in
all modules/examples relevant for release.
Posted by pl...@apache.org.
TAMAYA-136: Adding PropertyValue for PropertySource SPI. All changes and test fixes in all modules/examples relevant for release.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/2e229513
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/2e229513
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/2e229513
Branch: refs/heads/old_master
Commit: 2e229513e335c6c3a59a42b7093413081cacaaf2
Parents: 245defb
Author: anatole <an...@apache.org>
Authored: Tue Feb 2 17:15:53 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../org/apache/tamaya/events/FrozenPropertySource.java | 5 +++--
.../tamaya/events/PropertySourceChangeBuilder.java | 11 ++++++-----
.../apache/tamaya/events/FrozenPropertySourceTest.java | 2 +-
3 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2e229513/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
index a8167f2..81e6dca 100644
--- a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
@@ -19,6 +19,7 @@
package org.apache.tamaya.events;
import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
import java.io.Serializable;
import java.util.Collections;
@@ -81,8 +82,8 @@ public final class FrozenPropertySource implements PropertySource, Serializable
}
@Override
- public String get(String key) {
- return this.properties.get(key);
+ public PropertyValue get(String key) {
+ return PropertyValue.of(key, this.properties.get(key), getName());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2e229513/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
index cefa4f4..0858fdb 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -19,6 +19,7 @@
package org.apache.tamaya.events;
import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
@@ -95,19 +96,19 @@ public final class PropertySourceChangeBuilder {
public static Collection<PropertyChangeEvent> compare(PropertySource map1, PropertySource map2) {
List<PropertyChangeEvent> changes = new ArrayList<>();
for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
- String val = map2.get(en.getKey());
+ PropertyValue val = map2.get(en.getKey());
if (val == null) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
} else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue()));
}
}
for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
- String val = map1.get(en.getKey());
+ PropertyValue val = map1.get(en.getKey());
if (val == null) {
changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), null));
} else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), val));
+ changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), val.getValue()));
}
}
return changes;
@@ -170,7 +171,7 @@ public final class PropertySourceChangeBuilder {
* @return the builder for chaining.
*/
public PropertySourceChangeBuilder remove(String key, String... otherKeys) {
- String oldValue = this.source.get(key);
+ PropertyValue oldValue = this.source.get(key);
if (oldValue == null) {
this.delta.remove(key);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2e229513/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java b/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
index 0c61e0b..1431228 100644
--- a/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
+++ b/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
@@ -58,7 +58,7 @@ public class FrozenPropertySourceTest {
PropertySource ps = FrozenPropertySource.of(myPS);
assertNotNull(ps);
for (Map.Entry<String, String> e : myPS.getProperties().entrySet()) {
- assertEquals(ps.get(e.getKey()), e.getValue());
+ assertEquals(ps.get(e.getKey()).getValue(), e.getValue());
}
}
[37/50] [abbrv] incubator-tamaya-extensions git commit: Synched.
Posted by pl...@apache.org.
Synched.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/1aefa98c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/1aefa98c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/1aefa98c
Branch: refs/heads/old_master
Commit: 1aefa98c68e1d3fc1d788397c0d163facf451980
Parents: b16020f
Author: anatole <an...@apache.org>
Authored: Thu Feb 11 20:37:31 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../tamaya/filter/ConfigurationFilter.java | 2 +-
.../tamaya/filter/ConfigurationFilterTest.java | 32 ++++-
.../tamaya/filter/ProgrammableFilterTest.java | 131 +++++++++++++++----
.../tamaya/filter/RegexPropertyFilterTest.java | 42 +++++-
4 files changed, 173 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/1aefa98c/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
index 30ba3e2..b5bb45e 100644
--- a/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
+++ b/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
@@ -31,12 +31,12 @@ import org.apache.tamaya.spi.PropertyFilter;
* <li><b>Map</b> filters are applied when values are filtered as part of a full properties access.
* Often filtering in these cases is more commonly applied, e.g. you dont want to show up all kind of metadata.
* </li>
+ * </ul>
* For both variants individual filter rules can be applied here. All filters configured are managed on a
* thread-local level, so this class is typically used to temporarely filter out some values. Do not forget to
* restore its state, when not using a thread anymore (especially important in multi-threaded environments), not
* doing so will create nasty side effects of configuration not being visisble depending on the thread
* active.
- * </ul>
*/
public final class ConfigurationFilter implements PropertyFilter{
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/1aefa98c/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java b/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
index b4f3fa3..bbfe72d 100644
--- a/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
+++ b/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.filter;
import org.junit.Test;
@@ -5,37 +23,37 @@ import org.junit.Test;
import static org.junit.Assert.*;
/**
- * Created by atsticks on 11.02.16.
+ * Tests for {@link ConfigurationFilter}. Created by atsticks on 11.02.16.
*/
public class ConfigurationFilterTest {
@Test
public void testIsMetadataFiltered() throws Exception {
-
+// TODO
}
@Test
public void testSetMetadataFiltered() throws Exception {
-
+// TODO
}
@Test
public void testGetSingleFilters() throws Exception {
-
+// TODO
}
@Test
public void testGetMapFilters() throws Exception {
-
+// TODO
}
@Test
public void testClearFilters() throws Exception {
-
+// TODO
}
@Test
public void testFilterProperty() throws Exception {
-
+// TODO
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/1aefa98c/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java b/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
index 0a30dc4..73db677 100644
--- a/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
+++ b/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
@@ -1,56 +1,141 @@
+/*
+ * 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.filter;
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyFilter;
import org.junit.Test;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
import static org.junit.Assert.*;
/**
- * Created by atsticks on 11.02.16.
+ * Tests for {@link ProgrammableFilter}. Created by atsticks on 11.02.16.
*/
public class ProgrammableFilterTest {
@Test
- public void testAddFilter() throws Exception {
-
- }
-
- @Test
- public void testAddFilter1() throws Exception {
-
- }
-
- @Test
- public void testRemoveFilter() throws Exception {
-
+ public void testAddRemoveFilter() throws Exception {
+ ProgrammableFilter filter = new ProgrammableFilter();
+ RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
+ Map<String,String> map = new HashMap<>();
+ map.put("test1", "test1");
+ map.put("test2", "test2");
+ map.put("test.test3", "test.test3");
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
+ filter.addFilter(regexFilter);
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
+ filter.removeFilter(0);
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
+ filter.addFilter(0, regexFilter);
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
}
@Test
public void testClearFilters() throws Exception {
-
+ ProgrammableFilter filter = new ProgrammableFilter();
+ RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
+ Map<String,String> map = new HashMap<>();
+ map.put("test1", "test1");
+ map.put("test2", "test2");
+ map.put("test.test3", "test.test3");
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
+ filter.addFilter(regexFilter);
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
+ filter.clearFilters();
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
}
@Test
public void testSetFilters() throws Exception {
-
+ ProgrammableFilter filter = new ProgrammableFilter();
+ RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
+ Map<String,String> map = new HashMap<>();
+ map.put("test1", "test1");
+ map.put("test2", "test2");
+ map.put("test.test3", "test.test3");
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
+ filter.setFilters(regexFilter);
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
}
@Test
public void testSetFilters1() throws Exception {
-
+ ProgrammableFilter filter = new ProgrammableFilter();
+ RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
+ Map<String,String> map = new HashMap<>();
+ map.put("test1", "test1");
+ map.put("test2", "test2");
+ map.put("test.test3", "test.test3");
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
+ filter.setFilters(Arrays.asList(new PropertyFilter[]{regexFilter}));
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
}
@Test
public void testGetFilters() throws Exception {
-
- }
-
- @Test
- public void testFilterProperty() throws Exception {
-
+ ProgrammableFilter filter = new ProgrammableFilter();
+ assertNotNull(filter.getFilters());
+ assertTrue(filter.getFilters().isEmpty());
+ RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
+ filter.addFilter(regexFilter);
+ assertNotNull(filter.getFilters());
+ assertFalse(filter.getFilters().isEmpty());
+ assertEquals(1, filter.getFilters().size());
+ assertEquals(regexFilter, filter.getFilters().get(0));
}
@Test
public void testToString() throws Exception {
-
+ ProgrammableFilter filter = new ProgrammableFilter();
+ assertFalse(filter.toString().contains("test\\..*"));
+ assertTrue(filter.toString().contains("ProgrammableFilter"));
+ assertFalse(filter.toString().contains("RegexPropertyFilter"));
+ RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
+ filter.addFilter(regexFilter);
+ assertTrue(filter.toString().contains("test\\..*"));
+ assertTrue(filter.toString().contains("ProgrammableFilter"));
+ assertTrue(filter.toString().contains("RegexPropertyFilter"));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/1aefa98c/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java b/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
index 7583a86..a560b04 100644
--- a/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
+++ b/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
@@ -1,19 +1,55 @@
+/*
+ * 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.filter;
+import org.apache.tamaya.spi.FilterContext;
+
+import java.util.HashMap;
+import java.util.Map;
+
import static org.junit.Assert.*;
/**
- * Created by atsticks on 11.02.16.
+ * Tests for {@link RegexPropertyFilter}. Created by anatole on 11.02.16.
*/
public class RegexPropertyFilterTest {
@org.junit.Test
public void testFilterProperty() throws Exception {
-
+ RegexPropertyFilter filter = new RegexPropertyFilter("test\\..*");
+ Map<String,String> map = new HashMap<>();
+ map.put("test1", "test1");
+ map.put("test2", "test2");
+ map.put("test.test3", "test.test3");
+ assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
+ assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
+ filter = new RegexPropertyFilter(".*");
+ assertNull(filter.filterProperty("test1", new FilterContext("test1", map, true)));
+ assertNull(filter.filterProperty("test2", new FilterContext("test2", map, true)));
+ assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
}
@org.junit.Test
public void testToString() throws Exception {
-
+ RegexPropertyFilter filter = new RegexPropertyFilter("test\\..*");
+ assertTrue(filter.toString().contains("test\\..*"));
+ assertTrue(filter.toString().contains("RegexPropertyFilter"));
}
}
\ No newline at end of file
[44/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release tamaya-all-0.2-incubating
Posted by pl...@apache.org.
[maven-release-plugin] prepare release tamaya-all-0.2-incubating
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/566982cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/566982cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/566982cf
Branch: refs/heads/old_master
Commit: 566982cf8fc3b4a8a37229468281af15ac38e557
Parents: 3d48e37
Author: anatole <an...@apache.org>
Authored: Wed Mar 16 16:20:07 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/566982cf/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6222349..a59a968 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[23/50] [abbrv] incubator-tamaya-extensions git commit: ixed table
rendering and setting of polling interval.
Posted by pl...@apache.org.
ixed table rendering and setting of polling interval.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/6ca5def8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/6ca5def8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/6ca5def8
Branch: refs/heads/old_master
Commit: 6ca5def80fe586081bf9297dfbeb8b68fa27f710
Parents: 032322b
Author: anatole <an...@apache.org>
Authored: Sun Apr 17 23:55:50 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
.../tamaya/events/ConfigEventManager.java | 4 +-
.../internal/DefaultConfigChangeObserver.java | 9 ++--
.../org/apache/tamaya/events/ui/EventView.java | 53 ++++++++++++++++----
3 files changed, 49 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6ca5def8/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
index 9989fbb..f6bd3da 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -168,7 +168,7 @@ public final class ConfigEventManager {
*
* @return the check period in ms.
*/
- public long getChangeMonitoringPeriod(){
+ public static long getChangeMonitoringPeriod(){
return SPI.getChangeMonitoringPeriod();
}
@@ -179,7 +179,7 @@ public final class ConfigEventManager {
* @see #enableChangeMonitoring(boolean)
* @see #isChangeMonitoring()
*/
- public void setChangeMonitoringPeriod(long millis){
+ public static void setChangeMonitoringPeriod(long millis){
SPI.setChangeMonitoringPeriod(millis);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6ca5def8/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
index 5cd3f6c..f4457b2 100644
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
+++ b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
@@ -36,7 +36,7 @@ public class DefaultConfigChangeObserver {
private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
- private final Timer timer = new Timer("DefaultConfigChangeObserver", true);
+ private Timer timer = new Timer("DefaultConfigChangeObserver", true);
private long checkPeriod = 2000L;
@@ -52,9 +52,9 @@ public class DefaultConfigChangeObserver {
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
+ if(running) {
+ checkConfigurationUpdate();
+ }
}
}, START_DELAY, checkPeriod);
}
@@ -98,6 +98,7 @@ public class DefaultConfigChangeObserver {
LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
this.checkPeriod = checkPeriod;
timer.cancel();
+ timer = new Timer("DefaultConfigChangeObserver", true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6ca5def8/src/main/java/org/apache/tamaya/events/ui/EventView.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ui/EventView.java b/src/main/java/org/apache/tamaya/events/ui/EventView.java
index a69b04c..56e4b35 100644
--- a/src/main/java/org/apache/tamaya/events/ui/EventView.java
+++ b/src/main/java/org/apache/tamaya/events/ui/EventView.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.events.ui;
+import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
@@ -33,6 +34,7 @@ import org.apache.tamaya.ui.components.VerticalSpacedLayout;
import org.apache.tamaya.ui.services.MessageProvider;
import javax.annotation.Priority;
+import java.util.Date;
public class EventView extends VerticalSpacedLayout implements View {
@@ -65,6 +67,8 @@ public class EventView extends VerticalSpacedLayout implements View {
.getService(MessageProvider.class).getMessage("view.events.button.enableMonitoring"));
private Button clearViewButton = new Button(ServiceContextManager.getServiceContext()
.getService(MessageProvider.class).getMessage("view.events.button.clearView"));
+ private TextField pollingInterval = new TextField(ServiceContextManager.getServiceContext()
+ .getService(MessageProvider.class).getMessage("view.events.field.pollingInterval"));
private Table eventsTable = new Table(ServiceContextManager.getServiceContext()
.getService(MessageProvider.class).getMessage("view.events.table.name"));
@@ -86,35 +90,62 @@ public class EventView extends VerticalSpacedLayout implements View {
@Override
public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
ConfigEventManager.enableChangeMonitoring(changeMonitorEnabled.getValue());
+ if(changeMonitorEnabled.getValue()) {
+ Notification.show("Event Monitoring (Polling) active.");
+ }else{
+ Notification.show("Event Monitoring (Polling) inactive.");
+ }
}
});
clearViewButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent clickEvent) {
eventsTable.removeAllItems();
+ Notification.show("Events cleared.");
}
});
- changeMonitorEnabled.setData(ConfigEventManager.isChangeMonitoring());
- eventsTable.addContainerProperty("Timestamp", Long.class, null);
- eventsTable.addContainerProperty("Type", Class.class, null);
- eventsTable.addContainerProperty("Payload", String.class, null);
- eventsTable.addContainerProperty("Version", String.class, null);
+ HorizontalLayout eventSettings = new HorizontalLayout();
+ eventSettings.addComponents(changeMonitorEnabled, new Label(" Polling Interval"), pollingInterval, clearViewButton);
+ changeMonitorEnabled.setValue(ConfigEventManager.isChangeMonitoring());
+ pollingInterval.setValue(String.valueOf(ConfigEventManager.getChangeMonitoringPeriod()));
+ pollingInterval.setRequired(true);
+ pollingInterval.addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
+ try{
+ long millis = Long.parseLong((String)valueChangeEvent.getProperty().getValue());
+ ConfigEventManager.setChangeMonitoringPeriod(millis);
+ Notification.show("Updated Event Monitoring Poll Interval to " + millis + " milliseconds.");
+ }catch(Exception e){
+ Notification.show("Cannot update Event Monitoring Poll Interval to "
+ + valueChangeEvent.getProperty().getValue(), Notification.Type.ERROR_MESSAGE);
+ }
+ }
+ });
+ eventsTable.addContainerProperty("Timestamp", Date.class, null);
+ eventsTable.addContainerProperty("Type", String.class, "?");
+ eventsTable.addContainerProperty("Payload", String.class, "<empty>");
+ eventsTable.addContainerProperty("Version", String.class, "?");
eventsTable.setPageLength(20);
eventsTable.setWidth("100%");
eventsTable.setResponsive(true);
- HorizontalLayout hl = new HorizontalLayout();
- hl.addComponents(changeMonitorEnabled, clearViewButton);
+
caption.addStyleName(UIConstants.LABEL_HUGE);
description.addStyleName(UIConstants.LABEL_LARGE);
- addComponents(caption, description, hl, eventsTable);
+ addComponents(caption, description, eventSettings, eventsTable);
}
private void addEvent(ConfigEvent<?> evt){
- eventsTable.addItem(new Object[]{evt.getTimestamp(), evt.getResourceType().getSimpleName(),
- String.valueOf(evt.getResource()),evt.getVersion()});
- this.markAsDirty();
+ Object newItemId = eventsTable.addItem();
+ Item row = eventsTable.getItem(newItemId);
+ row.getItemProperty("Timestamp").setValue(new Date(evt.getTimestamp()));
+ row.getItemProperty("Type").setValue(evt.getResourceType().getSimpleName());
+ String value = String.valueOf(evt.getResource());
+ String valueShort = value.length()<150?value:value.substring(0,147)+"...";
+ row.getItemProperty("Payload").setValue(valueShort);
+ row.getItemProperty("Version").setValue(evt.getVersion());
}
[47/50] [abbrv] incubator-tamaya-extensions git commit: Set new
development version.
Posted by pl...@apache.org.
Set new development version.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/537d61f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/537d61f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/537d61f4
Branch: refs/heads/old_master
Commit: 537d61f46d098304bd2d466e9b6a2f9cd82c3eae
Parents: 03ee689
Author: anatole <an...@apache.org>
Authored: Thu Apr 14 00:47:11 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/537d61f4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a59a968..d9d4854 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[30/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-175
Moved the events module to the directory events after extracting it for the
Tamaya main repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
deleted file mode 100644
index 304ddba..0000000
--- a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
+++ /dev/null
@@ -1,194 +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.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * /**
- * Configuration implementation that stores all current values of a given (possibly dynamic, contextual and non server
- * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
- */
-public final class FrozenConfiguration implements Configuration, Serializable {
- private static final long serialVersionUID = -6373137316556444171L;
- /**
- * The properties frozen.
- */
- private Map<String, String> properties = new HashMap<>();
-
- /**
- * Constructor.
- *
- * @param config The base configuration.
- */
- private FrozenConfiguration(Configuration config) {
- this.properties.putAll(config.getProperties());
- this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
- this.properties = Collections.unmodifiableMap(this.properties);
- }
-
- /**
- * Creates a new FrozenConfiguration instance based on a Configuration given.
- *
- * @param config the configuration to be frozen, not null.
- * @return the frozen Configuration.
- */
- public static FrozenConfiguration of(Configuration config) {
- if (config instanceof FrozenConfiguration) {
- return (FrozenConfiguration) config;
- }
- return new FrozenConfiguration(config);
- }
-
- @Override
- public String get(String key) {
- return this.properties.get(key);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = get(key);
- if (value != null) {
- List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
- .getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(this,
- ConfigurationProvider.getConfigurationContext(), key,type).build();
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value, context);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- Logger.getLogger(getClass().getName())
- .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value,
- e);
- }
- }
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key
- + ", supported formats: " + context.getSupportedFormats());
- }
-
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return ConfigurationFunctions.emptyConfigurationContext();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- FrozenConfiguration that = (FrozenConfiguration) o;
- return properties.equals(that.properties);
- }
-
- @Override
- public int hashCode() {
- return properties.hashCode();
- }
-
- @Override
- public String toString() {
- return "FrozenConfiguration{" +
- "properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
deleted file mode 100644
index 81e6dca..0000000
--- a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ /dev/null
@@ -1,126 +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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * PropertySource implementation that stores all current values of a given (possibly dynamic, contextual and non server
- * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
- */
-public final class FrozenPropertySource implements PropertySource, Serializable {
- private static final long serialVersionUID = -6373137316556444171L;
- /**
- * The ordinal.
- */
- private final int ordinal;
- /**
- * The properties read.
- */
- private Map<String, String> properties = new HashMap<>();
- /**
- * The PropertySource's name.
- */
- private final String name;
-
- /**
- * Constructor.
- *
- * @param propertySource The base PropertySource.
- */
- private FrozenPropertySource(PropertySource propertySource) {
- this.properties.putAll(propertySource.getProperties());
- this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
- this.properties = Collections.unmodifiableMap(this.properties);
- this.ordinal = propertySource.getOrdinal();
- this.name = propertySource.getName();
- }
-
- /**
- * Creates a new FrozenPropertySource instance based on a PropertySource given.
- *
- * @param propertySource the property source to be frozen, not null.
- * @return the frozen property source.
- */
- public static FrozenPropertySource of(PropertySource propertySource) {
- if (propertySource instanceof FrozenPropertySource) {
- return (FrozenPropertySource) propertySource;
- }
- return new FrozenPropertySource(propertySource);
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public int getOrdinal() {
- return this.ordinal;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, this.properties.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof FrozenPropertySource)) {
- return false;
- }
- FrozenPropertySource that = (FrozenPropertySource) o;
- return ordinal == that.ordinal && properties.equals(that.properties);
- }
-
- @Override
- public int hashCode() {
- int result = ordinal;
- result = 31 * result + properties.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "FrozenPropertySource{" +
- "name=" + name +
- ", ordinal=" + ordinal +
- ", properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java b/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
deleted file mode 100644
index 063612c..0000000
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
+++ /dev/null
@@ -1,242 +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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class PropertySourceChange implements ConfigEvent<PropertySource>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final FrozenPropertySource propertySource;
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The recorded changes. */
- private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
- /** The overall type of change. */
- private final ChangeType changeType;
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- PropertySourceChange(PropertySourceChangeBuilder builder) {
- this.propertySource = FrozenPropertySource.of(builder.source);
- for (PropertyChangeEvent c : builder.delta.values()) {
- this.changes.put(c.getPropertyName(), c);
- }
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- this.changeType = builder.changeType;
- }
-
- /**
- * Gets the type of change for this PropertySource.
- * @return the type of change for this PropertySource, never null.
- */
- public ChangeType getChangeType(){
- return this.changeType;
- }
-
- @Override
- public Class<PropertySource> getResourceType() {
- return PropertySource.class;
- }
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, or null, if the change instance was deserialized.
- */
- @Override
- public PropertySource getResource(){
- return this.propertySource;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertyChangeEvent> getChanges(){
- return Collections.unmodifiableCollection(this.changes.values());
- }
-
- /**
- * Access the number current removed entries.
- * @return the number current removed entries.
- */
- public int getRemovedSize() {
- int removedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getNewValue() == null) {
- removedCount++;
- }
- }
- return removedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getNewValue() == null).count();
- }
-
- /**
- * Access the number current added entries.
- * @return the number current added entries.
- */
- public int getAddedSize() {
- int addedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getOldValue() == null &&
- ev.getNewValue() != null) {
- addedCount++;
- }
- }
- return addedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue() == null).count();
- }
-
- /**
- * Access the number current updated entries.
- * @return the number current updated entries.
- */
- public int getUpdatedSize() {
- int updatedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getOldValue() != null && ev.getNewValue() != null) {
- updatedCount++;
- }
- }
- return updatedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue()!=null && e.getNewValue()!=null).count();
- }
-
-
- /**
- * Checks if the given key was removed.
- * @param key the target key, not null.
- * @return true, if the given key was removed.
- */
- public boolean isRemoved(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() == null;
- }
-
- /**
- * Checks if the given key was added.
- * @param key the target key, not null.
- * @return true, if the given key was added.
- */
- public boolean isAdded(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() == null;
- }
-
- /**
- * Checks if the given key was updated.
- * @param key the target key, not null.
- * @return true, if the given key was updated.
- */
- public boolean isUpdated(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() != null && change.getNewValue() != null;
- }
-
- /**
- * Checks if the given key is added, or updated AND NOT removed.
- * @param key the target key, not null.
- * @return true, if the given key was added, or updated BUT NOT removed.
- */
- public boolean isKeyAffected(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() != null;
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changes.isEmpty();
- }
-
-
- /**
- * Create a change event for a new PropertySource that was added.
- * @param propertySource the new property source, not null.
- * @return a new PropertySourceChange, representing a PropertySource that was added.
- */
- public static PropertySourceChange ofAdded(PropertySource propertySource) {
- return PropertySourceChangeBuilder.of(propertySource, ChangeType.NEW).build();
- }
-
- /**
- * Create a change event for a deleted PropertySource.
- * @param propertySource the deleted property source, not null.
- * @return a new PropertySourceChange, representing a PropertySource that was deleted.
- */
- public static PropertySourceChange ofDeleted(PropertySource propertySource) {
- return PropertySourceChangeBuilder.of(propertySource, ChangeType.DELETED).build();
- }
-
- @Override
- public String toString() {
- return "PropertySourceChange{" +
- "changeType=" + changeType +
- ", propertySource=" + propertySource +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
deleted file mode 100644
index b7a4483..0000000
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ /dev/null
@@ -1,263 +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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
- * <ol>
- * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- * change, its only the data of the property source).</li>
- * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class PropertySourceChangeBuilder {
- /**
- * The recorded changes.
- */
- final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
- /**
- * The underlying configuration/provider.
- */
- final PropertySource source;
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- /** The type of change. */
- ChangeType changeType;
-
- /**
- * Constructor.
- *
- * @param source the underlying configuration/provider, not null.
- * @param changeType kind of change.
- */
- private PropertySourceChangeBuilder(PropertySource source, ChangeType changeType) {
- this.source = Objects.requireNonNull(source);
- this.changeType = Objects.requireNonNull(changeType);
- }
-
- /**
- * Creates a new instance of this builder.
- *
- * @param source the underlying property provider/configuration, not null.
- * @param changeType kind of change.
- * @return the builder for chaining.
- */
- public static PropertySourceChangeBuilder of(PropertySource source, ChangeType changeType) {
- return new PropertySourceChangeBuilder(source, changeType);
- }
-
- /**
- * Compares the two property config/configurations and creates a collection current all changes
- * that must be applied to render {@code map1} into {@code map2}.
- *
- * @param map1 the source map, not null.
- * @param map2 the target map, not null.
- * @return a collection current change events, never null.
- */
- public static Collection<PropertyChangeEvent> compare(PropertySource map1, PropertySource map2) {
- List<PropertyChangeEvent> changes = new ArrayList<>();
- for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
- PropertyValue val = map2.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.getValue().equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue()));
- }
- }
- for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
- PropertyValue val = map1.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), null));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), val.getValue()));
- }
- }
- return changes;
- }
-
- /*
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /*
- * Apply given timestamp to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param newState the new target state, not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder addChanges(PropertySource newState) {
- Collection<PropertyChangeEvent> events = PropertySourceChangeBuilder.compare(newState, this.source);
- for (PropertyChangeEvent c : events) {
- this.delta.put(c.getPropertyName(), c);
- }
- return this;
- }
-
- /**
- * Get the current values, also considering any changes recorded within this change set.
- *
- * @param key the key current the entry, not null.
- * @return the keys, or null.
- */
- public String get(String key) {
- PropertyChangeEvent change = this.delta.get(key);
- if (change != null && !(change.getNewValue() == null)) {
- return (String) change.getNewValue();
- }
- return null;
- }
-
- /**
- * Marks the given key(s) fromMap the configuration/properties to be removed.
- *
- * @param key the key current the entry, not null.
- * @param otherKeys additional keys to be removed (convenience), not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder remove(String key, String... otherKeys) {
- PropertyValue oldValue = this.source.get(key);
- if (oldValue == null) {
- this.delta.remove(key);
- }
- this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
- for (String addKey : otherKeys) {
- oldValue = this.source.get(addKey);
- if (oldValue == null) {
- this.delta.remove(addKey);
- }
- this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
- }
- return this;
- }
-
- /**
- * Apply all the given values to the base configuration/properties.
- * Note that all values passed must be convertible to String, either
- * <ul>
- * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
- * <li>default codecs are present for the given type, or</li>
- * <li>the value is an instanceof String</li>
- * </ul>
- *
- * @param changes the changes to be applied, not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder putAll(Map<String, String> changes) {
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
- }
- return this;
- }
-
- /**
- * This method will create a change set that clears all entries fromMap the given base configuration/properties.
- *
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder deleteAll() {
- this.delta.clear();
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
- }
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.delta.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.delta.clear();
- }
-
- public PropertySourceChangeBuilder setChangeType(ChangeType changeType) {
- this.changeType = changeType;
- return this;
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public PropertySourceChange build() {
- return new PropertySourceChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "PropertiesChangeBuilder [source=" + source + ", " +
- ", delta=" + delta + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/delta/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/delta/package-info.java b/src/main/java/org/apache/tamaya/events/delta/package-info.java
deleted file mode 100644
index 2006717..0000000
--- a/src/main/java/org/apache/tamaya/events/delta/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-/**
- * This package contains artifacts to describe the changes (delta) of a
- * Configuration or a PropertySource.
- */
-package org.apache.tamaya.events.delta;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
deleted file mode 100644
index 283719e..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
+++ /dev/null
@@ -1,144 +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.events.folderobserver;
-
-import org.apache.tamaya.ConfigException;
-
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * Class that has the responsibility to watch the folder and then publish the changes to a
- * {@link org.apache.tamaya.events.PropertySourceChange}.
- * @see ObservingPropertySourceProvider
- * This listener will wait to events and wait to one second to watch again.
- * <p>If new file was created or modified will commit from this file.</p>
- * <p>If a file was removed then the listener will load using all files left.</p>
- * @author otaviojava
- */
-class FileChangeListener implements Runnable {
-
- private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName());
-
- private final WatchService watchService;
-
- private final FileChangeObserver observer;
-
- private final Path directory;
-
- private volatile boolean running = true;
-
- public FileChangeListener(Path directory, FileChangeObserver observer) {
- this.observer = observer;
- this.directory = directory;
- this.watchService = getWatchService();
-
- if (watchService!=null && directory!=null) {
- try {
- directory.register(watchService,
- StandardWatchEventKinds.ENTRY_DELETE,
- StandardWatchEventKinds.ENTRY_MODIFY,
- StandardWatchEventKinds.ENTRY_CREATE);
- } catch (IOException e) {
- throw new FileChangeListenerException("An error happened when does try to registry to watch the folder", e);
- }
- }
- }
-
- /**
- * Stops the listener service from observing the target directory.
- */
- public void stopListener(){
- running = false;
- }
-
- @Override
- public void run() {
- if (watchService!=null || directory!=null) {
- return;
- }
- while (running) {
- watchFolder();
- }
- }
-
- /**
- * Start watching the current folder.
- */
- private void watchFolder() {
- try {
- WatchKey watckKey = watchService.take();
- for (WatchEvent<?> event : watckKey.pollEvents()) {
- Path filePath = (Path) watckKey.watchable();
- if(event.kind().equals(StandardWatchEventKinds.ENTRY_CREATE)||
- event.kind().equals(StandardWatchEventKinds.ENTRY_MODIFY) ||
- event.kind().equals(StandardWatchEventKinds.ENTRY_DELETE)){
- LOGGER.info("File change detected in: " + filePath.getFileName());
- observer.directoryChanged(filePath);
- }
- }
- watckKey.reset();
- Thread.sleep(1_000L);
- } catch (Exception e) {
- throw new FileChangeListenerException("An error happened when does try to watch the folder", e);
- }
- }
-
- /**
- * Get the watch service.
- * @return the watch service, or null, if the watch service is not supported.
- */
- private WatchService getWatchService() {
- try {
- FileSystem fileSystem = Paths.get(".").getFileSystem();
- return fileSystem.newWatchService();
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "The file System does not supports WatchService", e);
- return null;
- }
-
- }
-
- /**
- * Exception if file listening fails.
- */
- static class FileChangeListenerException extends ConfigException {
- /** Serialversion UID. */
- private static final long serialVersionUID = -8965486770881001513L;
-
- /**
- * Constructor.
- * @param message a message
- * @param cause an (optional) root cause.
- */
- public FileChangeListenerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
deleted file mode 100644
index 63d25cd..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
+++ /dev/null
@@ -1,33 +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.events.folderobserver;
-
-import java.nio.file.Path;
-
-/**
- * Observer to be used in {@link FileChangeListener} to commit all configurations and provider.
- */
-interface FileChangeObserver {
- /**
- * Called when a file has been modified.
- * @param path the file path, not null.
- */
- void directoryChanged(Path path);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
deleted file mode 100644
index feddd70..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ /dev/null
@@ -1,209 +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.events.folderobserver;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-/**
- * This implementation runs in a folder taking up all files compatible with the given
- * ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider
- * will adapt the changes automatically and trigger according
- * {@link org.apache.tamaya.events.PropertySourceChange} events.
- * The default folder is META-INF/config, but you can change it via an absolute path in the
- * "-Dtamaya.configdir" parameter.
- */
-public class ObservingPropertySourceProvider implements PropertySourceProvider, FileChangeObserver {
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(ObservingPropertySourceProvider.class.getName());
- /**
- * The current active property sources of this provider.
- */
- private final List<PropertySource> propertySources = Collections.synchronizedList(new LinkedList<PropertySource>());
- /**
- * The thread pool used.
- */
- private final ExecutorService executor = Executors.newSingleThreadExecutor();
-
- /**
- * Constructorm using an explicit directory, ignoring all kind of configuration, if set.
- *
- * @param directory the target directory. If null, the default configuration and system property are used.
- */
- public ObservingPropertySourceProvider(Path directory) {
- if (directory == null) {
- directory = getDirectory();
- }
- if (directory!=null){
- synchronized (this.propertySources) {
- this.propertySources.addAll(readConfiguration(directory));
- }
- final Runnable runnable = new FileChangeListener(directory, this);
- executor.execute(runnable);
- } else {
- executor.shutdown();
- }
- }
-
- /**
- * Read the initial configuration.
- *
- * @param directory the target directory, not null.
- */
- private List<PropertySource> readConfiguration(Path directory) {
- final List<PropertySource> result = new ArrayList<>();
- try {
- synchronized (propertySources) {
- for (final Path path : Files.newDirectoryStream(directory, "*")) {
- result.addAll(getPropertySources(path));
- }
- return result;
- }
- } catch (final IOException e) {
- LOG.log(Level.WARNING, "Failed to read configuration from dir: " + directory, e);
- }
- return result;
- }
-
- /**
- * Read property sources from the given file.
- *
- * @param file source of the property sources.
- * @return property sources from the given file.
- */
- protected Collection<PropertySource> getPropertySources(final Path file) {
- return Arrays.asList(new PropertySource[]{new BasePropertySource() {
- private final Map<String,String> props = readProperties(file);
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
- }});
- }
-
- /**
- * Load a single file.
- *
- * @param file the file, not null.
- * @return properties as read from the given file.
- */
- protected static Map<String,String> readProperties(Path file) {
- try (InputStream is = file.toUri().toURL().openStream()){
- final Properties props = new Properties();
- props.load(is);
- final Map<String,String> result = new HashMap<>();
- for(final Map.Entry<Object,Object> en:props.entrySet()){
- result.put(String.valueOf(en.getKey()), String.valueOf(en.getValue()));
- }
- return result;
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error reading file: " + file.toString() +
- ", using format: properties", e);
- }
- return Collections.emptyMap();
- }
-
-
- /**
- * Evaluates the target directory from system property (tamaya.configdir) or classpath.
- *
- * @return the directory to be read, or null.
- */
- private Path getDirectory() {
- final String absolutePath = System.getProperty("tamaya.configdir");
- if (null!=absolutePath) {
- final Path path = Paths.get(absolutePath);
- if (Files.isDirectory(path)) {
- return path;
- }
- }
- final URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
- if (null!=resource) {
- try {
- return Paths.get(resource.toURI());
- } catch (final URISyntaxException e) {
- throw new ConfigException("An error to find the directory to watch", e);
- }
- }
- return null;
- }
-
-
- @Override
- public void directoryChanged(Path directory) {
- synchronized (this.propertySources) {
- final List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
- propertySources.clear();
- final Collection<PropertySource> sourcesRead = readConfiguration(directory);
- this.propertySources.addAll(sourcesRead);
- triggerConfigChange(existingPropertySources, propertySources);
- }
- }
-
-
- private void triggerConfigChange(List<PropertySource> originalPropertySources,
- List<PropertySource> newPropertySources) {
- final ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
- for (final PropertySource ps : originalPropertySources) {
- b.removedPropertySource(ps);
- }
- for (final PropertySource ps : newPropertySources) {
- b.newPropertySource(ps);
- }
- final ConfigurationContextChange changeEvent = b.build();
- LOG.fine("Trigger Config Context Change: " + changeEvent);
- ConfigEventManager.fireEvent(changeEvent);
- }
-
- @Override
- public Collection<PropertySource> getPropertySources() {
- synchronized (propertySources) {
- return new ArrayList<>(this.propertySources);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java b/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
deleted file mode 100644
index 347f2d8..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
+++ /dev/null
@@ -1,24 +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.
- */
-/**
- * This package contains code to observe a folder for file changes and to trigger
- * corresponding events, that are handled by an according {@link org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider}
- * instance.
- */
-package org.apache.tamaya.events.folderobserver;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
deleted file mode 100644
index f4457b2..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
+++ /dev/null
@@ -1,111 +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.events.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationChange;
-import org.apache.tamaya.events.ConfigurationChangeBuilder;
-import org.apache.tamaya.events.FrozenConfiguration;
-
-import java.util.*;
-import java.util.logging.Logger;
-
-/**
- * Timer task that regularly checks the configuration for changes.
- */
-public class DefaultConfigChangeObserver {
-
- private static final long START_DELAY = 5000L;
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
-
- private Timer timer = new Timer("DefaultConfigChangeObserver", true);
-
- private long checkPeriod = 2000L;
-
- private volatile FrozenConfiguration lastConfig;
-
- private volatile boolean running;
-
- /**
- * Constructor. Also loads all registered listeners.
- */
- public DefaultConfigChangeObserver() {
- LOG.info("Registering config change observer, rechecking config changes every " + checkPeriod + " ms.");
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
- }
- }, START_DELAY, checkPeriod);
- }
-
-
- public void checkConfigurationUpdate() {
- LOG.finest("Checking configuration for changes...");
- FrozenConfiguration newConfig = FrozenConfiguration.of(ConfigurationProvider.getConfiguration());
- ConfigurationChange changes;
- if(lastConfig==null){
- changes = ConfigurationChangeBuilder.of(newConfig).putAll(newConfig.getProperties())
- .build();
- }else{
- changes = ConfigurationChangeBuilder.of(lastConfig).addChanges(newConfig)
- .build();
- }
- if(!changes.isEmpty()) {
- LOG.info("Identified configuration changes, publishing change event...");
- ConfigEventManager.fireEvent(changes);
- }
- }
-
- public long getCheckPeriod() {
- return checkPeriod;
- }
-
- public boolean isMonitoring(){
- return running;
- }
-
- public void enableMonitoring(boolean enable){
- this.running = true;
- }
-
- /**
- * Sets the new check period, cancels the currently running timer and schedules a new task with the new checkperiod
- * and a startup delay of 500ms.
- * @param checkPeriod the period in ms, for checking on changes.
- */
- public void setCheckPeriod(long checkPeriod) {
- LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
- this.checkPeriod = checkPeriod;
- timer.cancel();
- timer = new Timer("DefaultConfigChangeObserver", true);
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
- }
- }, 500L, checkPeriod);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
deleted file mode 100644
index 586df5c..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
+++ /dev/null
@@ -1,202 +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.events.internal;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default implementation of {@link DefaultConfigEventManagerSpi} just forwarding all
- * events synchronously to the listeners.
- */
-public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi {
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigEventManagerSpi.class.getName());
-
- private final Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>();
-
- private final ExecutorService publisher = Executors.newCachedThreadPool();
-
- private final DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver();
-
- /**
- * Constructor. Also loads all registered listeners.
- */
- public DefaultConfigEventManagerSpi() {
- try {
- for (ConfigEventListener l : ServiceContextManager.getServiceContext().getServices(ConfigEventListener.class)) {
- try {
- addListener(l);
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to load configured listener: " + l.getClass().getName(), e);
- }
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to load configured listeners.", e);
- }
- }
-
- @Override
- public void addListener(ConfigEventListener l){
- addListener(l, ConfigEvent.class);
- }
-
- @Override
- public <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType){
- List<ConfigEventListener> ls = listeners.get(eventType);
- if(ls==null){
- ls = Collections.synchronizedList(new ArrayList<ConfigEventListener>());
- listeners.put(eventType, ls);
- }
- synchronized (ls){
- if(!ls.contains(l)){
- ls.add(l);
- }
- }
- }
-
- @Override
- public void removeListener(ConfigEventListener l){
- removeListener(l, ConfigEvent.class);
- }
-
- @Override
- public <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
- List<ConfigEventListener> targets = this.listeners.get(eventType);
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- targets.remove(l);
- }
- }
- }
-
- @Override
- public Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType) {
- List<ConfigEventListener> targets = this.listeners.get(eventType);
- if(targets!=null){
- synchronized(targets){
- return new ArrayList<>(targets);
- }
- }
- return Collections.emptyList();
- }
-
- @Override
- public Collection<? extends ConfigEventListener> getListeners() {
- Set<ConfigEventListener> targets = new HashSet<>();
- for(List<ConfigEventListener> l:this.listeners.values()){
- targets.addAll(l);
- }
- return targets;
- }
-
- @Override
- public void fireEvent(ConfigEvent<?> event) {
- List<ConfigEventListener> targets = this.listeners.get(event.getClass());
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- l.onConfigEvent(event);
- }
- }
- }
- // forward to global listeners
- targets = this.listeners.get(ConfigEvent.class);
- if(targets!=null) {
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- l.onConfigEvent(event);
- }
- }
- }
- }
-
- @Override
- public void fireEventAsynch(ConfigEvent<?> event) {
- List<ConfigEventListener> targets = this.listeners.get(event.getClass());
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- publisher.execute(new PublishConfigChangeTask(l, event));
- }
- }
- }
- // forward to global listeners
- targets = this.listeners.get(ConfigEvent.class);
- if(targets!=null) {
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- publisher.execute(new PublishConfigChangeTask(l, event));
- }
- }
- }
- }
-
- @Override
- public long getChangeMonitoringPeriod() {
- return changeObserver.getCheckPeriod();
- }
-
- @Override
- public void setChangeMonitoringPeriod(long millis){
- changeObserver.setCheckPeriod(millis);
- }
-
- @Override
- public boolean isChangeMonitorActive() {
- return changeObserver.isMonitoring();
- }
-
- @Override
- public void enableChangeMonitor(boolean enable) {
- changeObserver.enableMonitoring(enable);
- }
-
-
- /**
- * Tasks to inform observers on detected configuration changes.
- */
- private static final class PublishConfigChangeTask implements Runnable{
-
- private final ConfigEventListener l;
- private final ConfigEvent<?> changes;
-
- public PublishConfigChangeTask(ConfigEventListener l, ConfigEvent<?> changes) {
- this.l = Objects.requireNonNull(l);
- this.changes = Objects.requireNonNull(changes);
- }
-
- @Override
- public void run() {
- l.onConfigEvent(changes);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
deleted file mode 100644
index e49856d..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
+++ /dev/null
@@ -1,74 +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.events.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default ConfigEventListener for ConfigurationContextChange events that updates the current context, if resources were
- * affected.
- */
-public class DefaultConfigurationContextChangeListener implements ConfigEventListener {
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextChangeListener.class.getName());
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- if(event.getClass() == ConfigurationContextChange.class) {
- ConfigurationContextChange contextChange = (ConfigurationContextChange) event;
- ConfigurationContext context = ConfigurationProvider.getConfigurationContext();
- List<PropertySource> affectedPropertySources = new ArrayList<>();
- for (PropertySource ps : context.getPropertySources()) {
- if (contextChange.isAffected(ps)) {
- affectedPropertySources.add(ps);
- }
- }
- ConfigurationContextBuilder newContextBuilder = ConfigurationProvider.getConfigurationContextBuilder()
- .setContext(context);
- if (!affectedPropertySources.isEmpty()) {
- Set<String> propertySourceNames = new HashSet<>();
- for (PropertySource removed : contextChange.getRemovedPropertySources()) {
- propertySourceNames.add(removed.getName());
- }
- newContextBuilder.removePropertySources(propertySourceNames);
- }
- newContextBuilder.addPropertySources(contextChange.getAddedPropertySources());
- newContextBuilder.addPropertySources(contextChange.getUpdatedPropertySources());
- ConfigurationContext newContext = newContextBuilder.build();
- try {
- ConfigurationProvider.setConfigurationContext(newContext);
- } catch (Exception e) {
- LOG.log(Level.INFO, "Failed to update the current ConfigurationContext due to config model changes", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java b/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
deleted file mode 100644
index be8c404..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
+++ /dev/null
@@ -1,40 +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.events.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-
-import java.util.logging.Logger;
-
-/**
- * Simple ConfigListener that simply logs any detected config changes to INFO level.
- */
-public class LoggingConfigListener implements ConfigEventListener {
-
- private static final Logger LOG = Logger.getLogger(LoggingConfigListener.class.getName());
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- if(event.getResourceType()== Configuration.class) {
- LOG.info("Configuration changed: " + event);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/package-info.java b/src/main/java/org/apache/tamaya/events/internal/package-info.java
deleted file mode 100644
index 9df5ac3..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/package-info.java
+++ /dev/null
@@ -1,22 +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.
- */
-/**
- * This package contains internal default implementations for the config events module.
- */
-package org.apache.tamaya.events.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/package-info.java b/src/main/java/org/apache/tamaya/events/package-info.java
deleted file mode 100644
index e175ceb..0000000
--- a/src/main/java/org/apache/tamaya/events/package-info.java
+++ /dev/null
@@ -1,24 +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.
- */
-/**
- * This package provides the main building blocks for handling configuration changes, such as
- * {@link org.apache.tamaya.events.ConfigEventManager}, {@link org.apache.tamaya.events.ConfigEventListener} and
- * artifacts to describe the changes (delta) of a Configuration or a PropertySource.
- */
-package org.apache.tamaya.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java b/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
deleted file mode 100644
index f6856d9..0000000
--- a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
+++ /dev/null
@@ -1,69 +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.events.spi;
-
-import org.apache.tamaya.events.ConfigEvent;
-
-import java.util.Objects;
-import java.util.UUID;
-
-/**
- * Abstract base class for implementing your own configuration events.
- * @param <T> the vent type
- */
-public abstract class BaseConfigEvent<T> implements ConfigEvent<T> {
- protected long timestamp = System.currentTimeMillis();
- protected String version = UUID.randomUUID().toString();
- protected final T paylod;
- private final Class<T> type;
-
- public BaseConfigEvent(T paylod, Class<T> type){
- this.paylod = Objects.requireNonNull(paylod);
- this.type = Objects.requireNonNull(type);
- }
-
- @Override
- public Class<T> getResourceType() {
- return type;
- }
-
- @Override
- public T getResource() {
- return paylod;
- }
-
- @Override
- public String getVersion() {
- return version;
- }
-
- @Override
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + '{' +
- "timestamp=" + timestamp +
- ", version='" + version + '\'' +
- ", paylod='" + paylod + '\'' +
- '}';
- }
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
deleted file mode 100644
index 66a8f73..0000000
--- a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
+++ /dev/null
@@ -1,128 +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.events.spi;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-
-import java.util.Collection;
-
-/**
- * SPI interface to implement the {@link org.apache.tamaya.events.ConfigEventManager} singleton.
- * Implementations of this interface must be registered with the current {@link org.apache.tamaya.spi.ServiceContext},
- * by default this equals to registering it with {@link java.util.ServiceLoader}. Add {@link javax.annotation.Priority}
- * annotations for overriding (higher values override lower values).
- */
-public interface ConfigEventManagerSpi {
- /**
- * Adds a listener for observing events. References of this
- * component to the listeners must be managed as weak references.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- */
- <T> void addListener(ConfigEventListener l);
-
- /**
- * Adds a listener for observing events of a given type.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered to this listener instance.
- */
- <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType);
-
- /**
- * Removes a listener for observing events.
- *
- * @param l the listener not null.
- */
- void removeListener(ConfigEventListener l);
-
- /**
- * Removes a listener for observing events of a certain type.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
- */
- <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType);
-
- /**
- * Access all globally registered listeners.
- *
- * @return the listeners found, never null.
- */
- Collection<? extends ConfigEventListener> getListeners();
-
- /**
- * Access all listeners listening for a certain event type, including any global listeners.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
- * @return the listeners found, never null.
- */
- Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType);
-
- /**
- * Publishes an event to all interested listeners, hereby executing all registered listeners sequentually and
- * synchronously.,
- *
- * @param event the event, not null.
- */
- void fireEvent(ConfigEvent<?> event);
-
- /**
- * Publishes an event to all interested listeners, hereby publishing the change events asynchrously and in
- * parallel (multithreaded).
- *
- * @param event the event, not null.
- */
- void fireEventAsynch(ConfigEvent<?> event);
-
- /**
- * Get the current check period to check for configuration changes.
- *
- * @return the check period in ms.
- */
- long getChangeMonitoringPeriod();
-
- void setChangeMonitoringPeriod(long millis);
-
- /**
- * Check if the observer is running currently.
- *
- * @return true, if the change monitoring service is currently running.
- */
- boolean isChangeMonitorActive();
-
- /**
- * Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and trigger ConfigurationChange events if something is changed. This is quite handy for publishing
- * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotedly. For handling corresponding {@link ConfigEventListener} have
- * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
- *
- * @param enable whether to enable or disable the change monitoring.
- */
- void enableChangeMonitor(boolean enable);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/spi/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/package-info.java b/src/main/java/org/apache/tamaya/events/spi/package-info.java
deleted file mode 100644
index 63d2b3b..0000000
--- a/src/main/java/org/apache/tamaya/events/spi/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-/**
- * This package contains the SPI to implement the
- * {@link org.apache.tamaya.events.ConfigEventManager} singleton.
- */
-package org.apache.tamaya.events.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index f9942c1..0000000
--- a/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.internal.DefaultConfigurationContextChangeListener
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi b/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
deleted file mode 100644
index d45dc43..0000000
--- a/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.internal.DefaultConfigEventManagerSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
deleted file mode 100644
index 0384064..0000000
--- a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
+++ /dev/null
@@ -1,62 +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.events;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * PropertySource implementation that accesses properties that are statically stored.
- */
-public class ChangeableGlobalPropertySource extends BasePropertySource{
-
- private static final Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>();
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
- /**
- * Put a value (globally) into this property source.
- * @param key the key, not null
- * @param value the value, not null
- * @return the entry replaced, or null.
- */
- public static String put(String key, String value){
- return STORED_ENTRIES.put(key,value);
- }
-
- /**
- * Put all the properties, overriding any existing ones with the same key.
- * @param properties the properties, not null.
- */
- public static void putAll(Map<String,String> properties){
- STORED_ENTRIES.putAll(properties);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
deleted file mode 100644
index cc6c812..0000000
--- a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
+++ /dev/null
@@ -1,57 +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.events;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * PropertySource implementation that accesses properties that are stored on ThreadLocal level, e.g. good to use for
- * testing..
- */
-public class ChangeableThreadLocalPropertySource extends BasePropertySource{
-
- private static final ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){
- protected Map<String,String> initialValue(){
- return new HashMap<>();
- }
- };
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
- public static String put(String key, String value){
- return STORED_ENTRIES.get().put(key,value);
- }
-
- public static void putAll(Map<String,String> properties){
- STORED_ENTRIES.get().putAll(properties);
- }
-
-}
[29/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-175
Moved the events module to the directory events after extracting it for the
Tamaya main repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java b/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
deleted file mode 100644
index b56407c..0000000
--- a/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.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.events;
-
-import org.junit.Test;
-
-import java.util.UUID;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link ConfigEventManager}.
- */
-public class ConfigEventManagerTest {
-
- private Object testAddListenerValue;
-
- @Test
- public void testAddRemoveListener() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event.getResource();
- }
- };
- ConfigEventManager.addListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event1"));
- assertEquals(testAddListenerValue, "Event1");
- ConfigEventManager.removeListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event2"));
- assertEquals(testAddListenerValue, "Event1");
- }
-
- @Test
- public void testFireEvent() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event.getResource();
- }
- };
- ConfigEventManager.addListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event1"));
- assertEquals(testAddListenerValue, "Event1");
- ConfigEventManager.removeListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event2"));
- assertEquals(testAddListenerValue, "Event1");
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java b/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
deleted file mode 100644
index 1431228..0000000
--- a/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
+++ /dev/null
@@ -1,106 +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.events;
-
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link org.apache.tamaya.events.FrozenPropertySource}.
- */
-public class FrozenPropertySourceTest {
-
- private static final PropertySource myPS = new SystemPropertySource();
-
- @Test
- public void testOf() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertNotNull(ps);
- }
-
- @Test
- public void testGetName() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- String name = ps.getName();
- assertNotNull(name);
- assertEquals(name, ps.getName());
- }
-
- @Test
- public void testGetOrdinal() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertEquals(myPS.getOrdinal(), ps.getOrdinal());
- }
-
- @Test
- public void testGet() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertNotNull(ps);
- for (Map.Entry<String, String> e : myPS.getProperties().entrySet()) {
- assertEquals(ps.get(e.getKey()).getValue(), e.getValue());
- }
- }
-
- @Test
- public void testGetProperties() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertNotNull(ps);
- assertNotNull(ps.getProperties());
- assertFalse(ps.getProperties().isEmpty());
- }
-
- @Test
- public void testEquals() throws Exception {
- PropertySource ps1 = FrozenPropertySource.of(myPS);
- PropertySource ps2 = FrozenPropertySource.of(myPS);
- assertEquals(ps1.getName(), ps2.getName());
- assertEquals(ps1.getProperties().size(), ps2.getProperties().size());
- }
-
- @Test
- public void testHashCode() throws Exception {
- boolean alwaysDifferent = true;
- for(int i=0;i<10;i++){
- PropertySource ps1 = FrozenPropertySource.of(myPS);
- PropertySource ps2 = FrozenPropertySource.of(myPS);
- // sometimes not same, because frozenAt in ms maybe different
- if(ps1.hashCode()==ps2.hashCode()){
- alwaysDifferent=false;
- break;
- }
- }
- if(alwaysDifferent){
- fail("HashCode should be same if frozenAt is in the same ms...");
- }
- }
-
- @Test
- public void testToString() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- String toString = ps.toString();
- assertNotNull(toString);
- assertTrue(toString.contains("FrozenPropertySource"));
- assertTrue(toString.contains(myPS.getName()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java b/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
deleted file mode 100644
index 0cd9e2b..0000000
--- a/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
+++ /dev/null
@@ -1,69 +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.events;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test (currently manual) to test configuration changes.
- */
-public class ObservedConfigTest {
-
- @Test
- @Ignore // reactivate later...
- public void testChangingConfig() throws IOException {
- Configuration config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
-
- Map<String, String> props = config.getProperties();
- assertEquals(props.get("test"), "test2");
- assertEquals(props.get("testValue1"), "value");
- assertNull(props.get("testValue2"));
-
- //insert a new properties file into the tempdirectory
- FileUtils.writeStringToFile(
- new File(TestObservingProvider.propertyLocation.toFile(), "test2.properties"),
- "testValue2=anotherValue");
-
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
-
- props = config.getProperties();
-
- assertEquals(props.get("test"), "test2");
- assertEquals(props.get("testValue1"), "value");
- assertEquals(props.get("testValue2"), "anotherValue");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/RandomPropertySource.java b/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
deleted file mode 100644
index dead0d9..0000000
--- a/src/test/java/org/apache/tamaya/events/RandomPropertySource.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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * PropertySource that provides a randome entry, different on each access!
- */
-public class RandomPropertySource implements PropertySource{
-
- private Map<String, String> data = new HashMap<>();
-
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "random";
- }
-
- @Override
- public PropertyValue get(String key) {
- if(key.equals("random.new")){
- return PropertyValue.of(key, String.valueOf(Math.random()),getName());
- }
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- synchronized(data) {
- data.put("random.new", String.valueOf(Math.random()));
- data.put("_random.new.source", getName());
- data.put("_random.new.timestamp", String.valueOf(System.currentTimeMillis()));
- return new HashMap<>(data);
- }
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/SimpleEvent.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/SimpleEvent.java b/src/test/java/org/apache/tamaya/events/SimpleEvent.java
deleted file mode 100644
index 5017aa1..0000000
--- a/src/test/java/org/apache/tamaya/events/SimpleEvent.java
+++ /dev/null
@@ -1,32 +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.events;
-
-import org.apache.tamaya.events.spi.BaseConfigEvent;
-
-/**
- * Simple test event for testing only.
- */
-public class SimpleEvent extends BaseConfigEvent<String> {
-
- public SimpleEvent(String paylod) {
- super(paylod, String.class);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/TestConfigView.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/TestConfigView.java b/src/test/java/org/apache/tamaya/events/TestConfigView.java
deleted file mode 100644
index 8e5b397..0000000
--- a/src/test/java/org/apache/tamaya/events/TestConfigView.java
+++ /dev/null
@@ -1,156 +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.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Created by Anatole on 24.03.2015.
- */
-public class TestConfigView implements ConfigOperator{
-
- private static final TestConfigView INSTANCE = new TestConfigView();
-
- private TestConfigView(){}
-
- public static ConfigOperator of(){
- return INSTANCE;
- }
-
- @Override
- public Configuration operate(final Configuration config) {
- return new Configuration() {
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
- if (en.getKey().startsWith("test")) {
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
-// return config.getProperties().entrySet().stream().filter(e -> e.getKey().startsWith("test")).collect(
-// Collectors.toMap(en -> en.getKey(), en -> en.getValue()));
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return null;
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return null;
- }
-
- @Override
- public ConfigurationContext getContext() {
- return config.getContext();
- }
-
- @Override
- public String get(String key) {
- return getProperties().get(key);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = get(key);
- if (value != null) {
- List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
- .getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(
- key,type).build();
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value, context);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- Logger.getLogger(getClass().getName())
- .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: "
- + value, e);
- }
- }
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": "
- + key + ", supportedFormats: " + context.getSupportedFormats());
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/TestObservingProvider.java b/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
deleted file mode 100644
index 2685d3e..0000000
--- a/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
+++ /dev/null
@@ -1,92 +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.events;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Test configuration property source provider that observes a directory and updated the config if necessary.
- */
-public class TestObservingProvider extends ObservingPropertySourceProvider{
-
- public static Path propertyLocation;
-
- static{
- try {
- // create some temporary config
- Path tempDir = Files.createTempDirectory("observedFolder");
-
- TestObservingProvider.propertyLocation = tempDir;
-
- FileUtils.copyInputStreamToFile(
- TestObservingProvider.class.getResourceAsStream("/test.properties"),
- new File(tempDir.toFile(), "test.properties"));
-
- Runtime.getRuntime().addShutdownHook(new Thread(){
- @Override
- public void run(){
- try{
- // cleanup directory
- Files.deleteIfExists(getTargetFile("test1.properties"));
- Files.deleteIfExists(getTargetFile("test2.properties"));
- Files.deleteIfExists(getTargetFile("test3.properties"));
- }
- catch(Exception e){
- Logger.getLogger("TestObservingProvider").log(Level.WARNING,
- "Failed to cleanup config test dir", e);
- }
- }
- });
- }
- catch(Exception e){
- Logger.getLogger("TestObservingProvider").log(Level.WARNING, "Failed to init config test dir", e);
- }
- }
-
- private static Path getTargetFile(String name) {
- File testFile = new File(TestObservingProvider.getTestDirectory(), name);
- return Paths.get(testFile.toURI());
- }
-
- public TestObservingProvider(){
- super(propertyLocation);
- Logger.getLogger(getClass().getName()).info("Using test directory: " + getTestPath());
- }
-
- public static File getTestDirectory(){
- String tempDir = System.getProperty("java.io.tmpdir");
- File dir = new File(tempDir, "tamaya-events-testdir");
- if(!dir.exists()){
- dir.mkdirs();
- }
- return dir;
- }
-
- private static String getTestPath(){
- return getTestDirectory().getAbsolutePath();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java b/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
deleted file mode 100644
index b20ebef..0000000
--- a/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
+++ /dev/null
@@ -1,163 +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.events.delta;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigurationChange;
-import org.apache.tamaya.events.ConfigurationChangeBuilder;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for {@link ConfigurationChange}.
- */
-public class ConfigurationChangeTest {
-
- @Test
- public void testEmptyChangeSet() throws Exception {
- ConfigurationChange change = ConfigurationChange.emptyChangeSet(ConfigurationProvider.getConfiguration());
- assertNotNull(change);
- assertTrue(change.isEmpty());
- }
-
- @Test
- public void testGetConfiguration() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertNotNull(change);
- assertTrue(change.getUpdatedSize()==0);
- assertTrue(change.getAddedSize()==0);
- assertTrue(change.getRemovedSize()==0);
- assertTrue(change.getChanges().size()==0);
- for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
- if (!"[meta]frozenAt".equals(en.getKey())) {
- if(en.getKey().contains("random.new")){ // dynamic generated value!
- continue;
- }
- assertEquals("Error for " + en.getKey(), en.getValue(), change.getResource().get(en.getKey()));
- }
- }
- }
-
- @Test
- public void testGetVersion() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertNotNull(change.getVersion());
- change = ConfigurationChangeBuilder.of(config).setVersion("version2").build();
- assertNotNull(change.getVersion());
- assertEquals("version2", change.getVersion());
- }
-
- @Test
- public void testGetTimestamp() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertTrue((System.currentTimeMillis() - change.getTimestamp()) <= 10L);
- change = ConfigurationChangeBuilder.of(config).setTimestamp(10L).build();
- assertEquals(10L, change.getTimestamp());
- }
-
- @Test
- public void testGetEvents() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("key1", "key2").build();
- assertTrue(change.getChanges().size() == 2);
- change = ConfigurationChangeBuilder.of(config).addChange("key1Added", "value1Added").build();
- assertTrue(change.getChanges().size() == 1);
- }
-
- @Test
- public void testGetRemovedSize() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("java.version", "key2").build();
- assertTrue(change.getRemovedSize() == 2);
- assertTrue(change.getAddedSize() == 0);
- }
-
- @Test
- public void testGetAddedSize() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- assertTrue(change.getAddedSize() == 1);
- assertTrue(change.getRemovedSize() == 0);
- }
-
- @Test
- public void testGetUpdatedSize() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("java.version", "1.8").build();
- assertTrue(change.getUpdatedSize() == 1);
- }
-
- @Test
- public void testIsRemoved() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
- assertTrue(change.isRemoved("java.version"));
- }
-
- @Test
- public void testIsAdded() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- assertTrue(change.isAdded("key1"));
- }
-
- @Test
- public void testIsUpdated() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("java.version", "1.8").build();
- assertTrue(change.isUpdated("java.version"));
- }
-
- @Test
- public void testContainsKey() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- assertTrue(change.isKeyAffected("key1"));
- assertFalse(change.isKeyAffected("key2"));
- change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
- assertFalse(change.isKeyAffected("java.version"));
- assertFalse(change.isKeyAffected("key2"));
- }
-
- @Test
- public void testIsEmpty() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertTrue(change.isEmpty());
- }
-
- @Test
- public void testToString() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
- assertTrue(change.toString().contains("timestamp"));
- assertTrue(change.toString().contains("version"));
- assertTrue(change.toString().contains("configuration"));
- assertFalse(change.toString().contains("key1"));
- assertFalse(change.toString().contains("key2"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java b/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
deleted file mode 100644
index ee631ce..0000000
--- a/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
+++ /dev/null
@@ -1,138 +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.events.delta;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.events.ChangeType;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.events.PropertySourceChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for {@link ConfigurationContextChange}.
- */
-public class ConfigurationContextChangeTest {
-
- @Test
- public void testEmptyChangeSet() throws Exception {
- ConfigurationContextChange change = ConfigurationContextChange.emptyChangeSet(
- ConfigurationProvider.getConfigurationContext());
- assertNotNull(change);
- assertTrue(change.isEmpty());
- }
-
- @Test
- public void testGetVersion() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertNotNull(change.getVersion());
- change = ConfigurationContextChangeBuilder.of().setVersion("version2").build();
- assertNotNull(change.getVersion());
- assertEquals("version2", change.getVersion());
- }
-
- @Test
- public void testGetTimestamp() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue((System.currentTimeMillis() - change.getTimestamp()) <= 10L);
- change = ConfigurationContextChangeBuilder.of().setTimestamp(10L).build();
- assertEquals(10L, change.getTimestamp());
- }
-
- @Test
- public void testGetPropertySourceChanges() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- }
-
- @Test
- public void testGetPropertySourceUpdates() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceUpdates(). isEmpty());
- }
-
- @Test
- public void testGetRemovedPropertySources() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getRemovedPropertySources(). isEmpty());
- }
-
- @Test
- public void testGetAddedPropertySources() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getAddedPropertySources().isEmpty());
- }
-
- @Test
- public void testGetUpdatedPropertySources() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getUpdatedPropertySources().isEmpty());
- }
-
- @Test
- public void testIsAffected() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- PropertySource ps = new SystemPropertySource();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().changedPropertySource(
- PropertySourceChangeBuilder.of(ps, ChangeType.UPDATED).build()
- ).build();
- String toString = change.toString();
- assertTrue(change.isAffected(ps));
- }
-
- @Test
- public void testIsEmpty() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.isEmpty());
- change = ConfigurationContextChangeBuilder.of().newPropertySource(new SystemPropertySource()).build();
- assertFalse(change.isEmpty());
- }
-
- @Test
- public void testToString() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().newPropertySource(new SystemPropertySource()).build();
- String toString = change.toString();
- assertNotNull(toString);
- assertTrue(toString.contains(new SystemPropertySource().getName()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java b/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
deleted file mode 100644
index 0dcdfba..0000000
--- a/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
+++ /dev/null
@@ -1,209 +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.events.delta;
-
-import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
-import org.apache.tamaya.core.propertysource.SimplePropertySource;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.events.ChangeType;
-import org.apache.tamaya.events.PropertySourceChange;
-import org.apache.tamaya.events.PropertySourceChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link PropertySourceChange} and its builder.
- */
-public class PropertySourceChangeTest {
-
- private static final PropertySource myPS = new SystemPropertySource();
-
- @Test
- public void testGetChangeType() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED).build();
- assertEquals(change.getChangeType(), ChangeType.DELETED);
- change = PropertySourceChangeBuilder.of(myPS, ChangeType.UPDATED).build();
- assertEquals(change.getChangeType(), ChangeType.UPDATED);
- }
-
- @Test
- public void testGetPropertySource() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED).build();
- assertEquals(change.getResource().getName(), myPS.getName());
- }
-
- @Test
- public void testGetVersion() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .setVersion("myVersion1").build();
- assertEquals(change.getVersion(), "myVersion1");
- }
-
- @Test
- public void testGetTimestamp() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .setTimestamp(111L).build();
- assertEquals(change.getTimestamp(), 111L);
- }
-
- @Test
- public void testGetEvents() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getChanges().size()>0);
- }
-
- @Test
- public void testGetRemovedSize() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.UPDATED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getRemovedSize()>0);
- }
-
- @Test
- public void testGetAddedSize() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getAddedSize()>0);
- }
-
- @Test
- public void testGetUpdatedSize() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getUpdatedSize()==0);
- }
-
- @Test
- public void testIsRemoved() throws Exception {
- Map<String, String> testData = new HashMap<>();
- testData.put("key1", "value1");
- testData.put("key2", "value2");
- PropertySource ps1 = new SimplePropertySource("test", testData);
- testData = new HashMap<>();
- testData.put("key1", "value2");
- testData.put("key3", "value3");
- PropertySource ps2 = new SimplePropertySource("test", testData);
- PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
- .addChanges(
- ps2
- ).build();
- assertFalse(change.isRemoved("key1"));
- assertTrue(change.isRemoved("key2"));
- assertFalse(change.isRemoved("key3"));
- }
-
- @Test
- public void testIsAdded() throws Exception {
- Map<String, String> testData = new HashMap<>();
- testData.put("key1", "value1");
- testData.put("key2", "value2");
- PropertySource ps1 = new SimplePropertySource("test", testData);
- testData = new HashMap<>();
- testData.put("key1", "value2");
- testData.put("key3", "value3");
- PropertySource ps2 = new SimplePropertySource("test", testData);
- PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
- .addChanges(
- ps2
- ).build();
- assertTrue(change.isAdded("key3"));
- assertFalse(change.isAdded("key2"));
- assertFalse(change.isAdded("key1"));
- }
-
- @Test
- public void testIsUpdated() throws Exception {
- Map<String, String> testData = new HashMap<>();
- testData.put("key1", "value1");
- testData.put("key2", "value2");
- PropertySource ps1 = new SimplePropertySource("test", testData);
- testData = new HashMap<>();
- testData.put("key1", "value2");
- testData.put("key3", "value3");
- PropertySource ps2 = new SimplePropertySource("test", testData);
- PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
- .addChanges(
- ps2
- ).build();
- assertTrue(change.isUpdated("key1"));
- assertFalse(change.isUpdated("key2"));
- assertFalse(change.isUpdated("key3"));
- }
-
- @Test
- public void testContainsKey() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
- .addChanges(
- myPS
- ).build();
- assertTrue(change.isKeyAffected("java.version"));
- }
-
- @Test
- public void testIsEmpty() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
- .build();
- assertTrue(change.isEmpty());
- change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
- .addChanges(
- myPS
- ).build();
- assertFalse(change.isEmpty());
- }
-
- @Test
- public void testOfAdded() throws Exception {
- PropertySourceChange change = PropertySourceChange.ofAdded(myPS);
- assertNotNull(change);
- assertEquals(change.getChangeType(), ChangeType.NEW);
- }
-
- @Test
- public void testOfDeleted() throws Exception {
- PropertySourceChange change = PropertySourceChange.ofDeleted(myPS);
- assertNotNull(change);
- assertEquals(change.getChangeType(), ChangeType.DELETED);
- }
-
- @Test
- public void testToString() throws Exception {
- PropertySourceChange change = PropertySourceChange.ofAdded(myPS);
- String toString = change.toString();
- assertNotNull(toString);
- assertTrue(toString.contains(myPS.getName()));
- change = PropertySourceChange.ofDeleted(myPS);
- toString = change.toString();
- assertNotNull(toString);
- assertTrue(toString.contains(myPS.getName()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java b/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
deleted file mode 100644
index d54a66e..0000000
--- a/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.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.events.internal;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.SimpleEvent;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link DefaultConfigEventManagerSpi}.
- */
-public class DefaultConfigEventManagerSpiTest {
-
- private final DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi();
- private Object testAddListenerValue;
-
- @Test
- public void testAddListener() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event.getResource();
- }
- };
- spi.addListener(testListener);
- spi.fireEvent(new SimpleEvent("Event1"));
- assertEquals(testAddListenerValue, "Event1");
- spi.removeListener(testListener);
- spi.fireEvent(new SimpleEvent("Event2"));
- assertEquals(testAddListenerValue, "Event1");
-
- }
-
- @Test
- public void testRemoveListener() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event;
- }
- };
- spi.removeListener(testListener);
- spi.removeListener(testListener);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index f675fd6..0000000
--- a/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.internal.DefaultConfigurationContextChangeListener
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 9c2b9f6..0000000
--- a/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.RandomPropertySource
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
deleted file mode 100644
index d34b4a2..0000000
--- a/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.events.TestObservingProvider
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/data/test1.properties
----------------------------------------------------------------------
diff --git a/src/test/resources/data/test1.properties b/src/test/resources/data/test1.properties
deleted file mode 100644
index 0df3bd1..0000000
--- a/src/test/resources/data/test1.properties
+++ /dev/null
@@ -1,20 +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.
-#
-1=val1
-3=val3
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/data/test1b.properties
----------------------------------------------------------------------
diff --git a/src/test/resources/data/test1b.properties b/src/test/resources/data/test1b.properties
deleted file mode 100644
index ec57163..0000000
--- a/src/test/resources/data/test1b.properties
+++ /dev/null
@@ -1,20 +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.
-#
-1b=val1
-7=val7
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/data/test2.properties
----------------------------------------------------------------------
diff --git a/src/test/resources/data/test2.properties b/src/test/resources/data/test2.properties
deleted file mode 100644
index 0643c1d..0000000
--- a/src/test/resources/data/test2.properties
+++ /dev/null
@@ -1,20 +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.
-#
-4=val4
-6=val6
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/data/test3.properties
----------------------------------------------------------------------
diff --git a/src/test/resources/data/test3.properties b/src/test/resources/data/test3.properties
deleted file mode 100644
index bb856c7..0000000
--- a/src/test/resources/data/test3.properties
+++ /dev/null
@@ -1,20 +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.
-#
-2=val2
-5=val5
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/src/test/resources/test.properties b/src/test/resources/test.properties
deleted file mode 100644
index af06631..0000000
--- a/src/test/resources/test.properties
+++ /dev/null
@@ -1,21 +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.
-#
-testValue1=value
-test=test2
-a=b
\ No newline at end of file
[17/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare for next development iteration
Posted by pl...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/42998593
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/42998593
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/42998593
Branch: refs/heads/old_master
Commit: 42998593ac0f736d53aa042d5cd3c0108ce3c7a0
Parents: 64c43de
Author: anatole <an...@apache.org>
Authored: Wed Mar 16 16:20:17 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/42998593/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4f3a981..d43379c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.2-incubating</version>
+ <version>0.3-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-events</artifactId>
[03/50] [abbrv] incubator-tamaya-extensions git commit: Fixed further
issues from quality gates.
Posted by pl...@apache.org.
Fixed further issues from quality gates.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/fefbeca7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/fefbeca7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/fefbeca7
Branch: refs/heads/old_master
Commit: fefbeca7f3263e622d6f90dc87faf247c107c42b
Parents: 4d6c713
Author: anatole <an...@apache.org>
Authored: Sun Jan 10 02:14:41 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
src/main/java/org/apache/tamaya/events/ChangeType.java | 5 ++++-
.../java/org/apache/tamaya/events/ConfigEventManager.java | 2 +-
.../org/apache/tamaya/events/ConfigurationChange.java | 4 ++--
.../apache/tamaya/events/ConfigurationChangeBuilder.java | 6 ++++--
.../apache/tamaya/events/ConfigurationContextChange.java | 4 ++--
.../tamaya/events/ConfigurationContextChangeBuilder.java | 2 +-
.../org/apache/tamaya/events/FrozenPropertySource.java | 4 ++--
.../org/apache/tamaya/events/PropertySourceChange.java | 6 +++---
.../apache/tamaya/events/PropertySourceChangeBuilder.java | 6 ++++--
.../tamaya/events/folderobserver/FileChangeListener.java | 6 +++---
.../folderobserver/ObservingPropertySourceProvider.java | 4 ++--
.../events/internal/DefaultConfigChangeObserver.java | 6 +++---
.../events/internal/DefaultConfigEventManagerSpi.java | 10 +++++-----
.../org/apache/tamaya/events/spi/BaseConfigEvent.java | 6 +++---
.../tamaya/events/ChangeableGlobalPropertySource.java | 2 +-
.../events/ChangeableThreadLocalPropertySource.java | 2 +-
.../events/internal/DefaultConfigEventManagerSpiTest.java | 2 +-
17 files changed, 42 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ChangeType.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ChangeType.java b/src/main/java/org/apache/tamaya/events/ChangeType.java
index 4363579..2059017 100644
--- a/src/main/java/org/apache/tamaya/events/ChangeType.java
+++ b/src/main/java/org/apache/tamaya/events/ChangeType.java
@@ -19,10 +19,13 @@
package org.apache.tamaya.events;
/**
- * Created by Anatole on 20.02.2015.
+ * Enum describing the type of configuration change.
*/
public enum ChangeType {
+ /** Configuration hase been added. */
NEW,
+ /** Configuration hase been removed. */
DELETED,
+ /** Configuration hase been changed. */
UPDATED,
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
index f0bd0fa..6b206c8 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
@@ -166,7 +166,7 @@ public final class ConfigEventManager {
/**
* Sets the current monitoring period and restarts the monitor. You still have to enable the monitor if
* it is currently not enabled.
- * @param millis
+ * @param millis the monitoring period in ms.
* @see #enableChangeMonitoring(boolean)
* @see #isChangeMonitoring()
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
index 0366556..c31cda2 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
@@ -39,13 +39,13 @@ public final class ConfigurationChange implements ConfigEvent<Configuration>, Se
private static final long serialVersionUID = 1L;
/** The base property provider/configuration. */
- private FrozenConfiguration configuration;
+ private final FrozenConfiguration configuration;
/** The base version, usable for optimistic locking. */
private String version = UUID.randomUUID().toString();
/** The timestamp of the change set in millis from the epoch. */
private long timestamp = System.currentTimeMillis();
/** The recorded changes. */
- private Map<String,PropertyChangeEvent> changes = new HashMap<>();
+ private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
/**
* Get an empty change set for the given provider.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
index 78f60a9..1fd228a 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
@@ -50,7 +50,7 @@ public final class ConfigurationChangeBuilder {
/**
* The underlying configuration/provider.
*/
- Configuration source;
+ final Configuration source;
/**
* The version configured, or null, for generating a default.
*/
@@ -213,7 +213,9 @@ public final class ConfigurationChangeBuilder {
* @return the builder for chaining.
*/
public ConfigurationChangeBuilder putAll(Map<String, String> changes) {
- changes.putAll(changes);
+ for (Map.Entry<String, String> en : changes.entrySet()) {
+ this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
+ }
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
index eda5ab1..8c9ceef 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
@@ -39,13 +39,13 @@ public final class ConfigurationContextChange implements ConfigEvent<Configurati
private static final long serialVersionUID = 1L;
/** The base property provider/configuration. */
- private List<PropertySourceChange> changedPropertySources = new ArrayList<>();
+ private final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
/** The base version, usable for optimistic locking. */
private String version = UUID.randomUUID().toString();
/** The timestamp of the change set in millis from the epoch. */
private long timestamp = System.currentTimeMillis();
/** The configuration context. */
- private ConfigurationContext configurationContext;
+ private final ConfigurationContext configurationContext;
/**
* Get an empty change set for the given provider.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
index 2341f92..a48107a 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
@@ -52,7 +52,7 @@ public final class ConfigurationContextChangeBuilder {
*/
Long timestamp;
- ConfigurationContext configurationContext;
+ final ConfigurationContext configurationContext;
/**
* Constructor.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
index 12778be..a8167f2 100644
--- a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
@@ -34,7 +34,7 @@ public final class FrozenPropertySource implements PropertySource, Serializable
/**
* The ordinal.
*/
- private int ordinal;
+ private final int ordinal;
/**
* The properties read.
*/
@@ -42,7 +42,7 @@ public final class FrozenPropertySource implements PropertySource, Serializable
/**
* The PropertySource's name.
*/
- private String name;
+ private final String name;
/**
* Constructor.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java b/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
index a34e949..063612c 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
@@ -39,15 +39,15 @@ public final class PropertySourceChange implements ConfigEvent<PropertySource>,
private static final long serialVersionUID = 1L;
/** The base property provider/configuration. */
- private FrozenPropertySource propertySource;
+ private final FrozenPropertySource propertySource;
/** The base version, usable for optimistic locking. */
private String version = UUID.randomUUID().toString();
/** The timestamp of the change set in millis from the epoch. */
private long timestamp = System.currentTimeMillis();
/** The recorded changes. */
- private Map<String,PropertyChangeEvent> changes = new HashMap<>();
+ private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
/** The overall type of change. */
- private ChangeType changeType;
+ private final ChangeType changeType;
/**
* Constructor used by {@link PropertySourceChangeBuilder}.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
index 25f3620..009cb11 100644
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
@@ -49,7 +49,7 @@ public final class PropertySourceChangeBuilder {
/**
* The underlying configuration/provider.
*/
- PropertySource source;
+ final PropertySource source;
/**
* The version configured, or null, for generating a default.
*/
@@ -196,7 +196,9 @@ public final class PropertySourceChangeBuilder {
* @return the builder for chaining.
*/
public PropertySourceChangeBuilder putAll(Map<String, String> changes) {
- changes.putAll(changes);
+ for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
+ this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
+ }
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
index 3427ce8..283719e 100644
--- a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
+++ b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
@@ -45,11 +45,11 @@ class FileChangeListener implements Runnable {
private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName());
- private WatchService watchService;
+ private final WatchService watchService;
- private FileChangeObserver observer;
+ private final FileChangeObserver observer;
- private Path directory;
+ private final Path directory;
private volatile boolean running = true;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
index d8c869f..6082dd0 100644
--- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
@@ -59,7 +59,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
/**
* The thread pool used.
*/
- private ExecutorService executor = Executors.newSingleThreadExecutor();
+ private final ExecutorService executor = Executors.newSingleThreadExecutor();
/**
* Constructorm using an explicit directory, ignoring all kind of configuration, if set.
@@ -103,7 +103,7 @@ public class ObservingPropertySourceProvider implements PropertySourceProvider,
protected Collection<PropertySource> getPropertySources(final Path file) {
return Arrays.asList(new PropertySource[]{new BasePropertySource() {
- private Map<String,String> props = readProperties(file);
+ private final Map<String,String> props = readProperties(file);
@Override
public Map<String, String> getProperties() {
return props;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
index dfb3816..5cd3f6c 100644
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
+++ b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
@@ -36,7 +36,7 @@ public class DefaultConfigChangeObserver {
private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
- private Timer timer = new Timer("DefaultConfigChangeObserver", true);
+ private final Timer timer = new Timer("DefaultConfigChangeObserver", true);
private long checkPeriod = 2000L;
@@ -63,7 +63,7 @@ public class DefaultConfigChangeObserver {
public void checkConfigurationUpdate() {
LOG.finest("Checking configuration for changes...");
FrozenConfiguration newConfig = FrozenConfiguration.of(ConfigurationProvider.getConfiguration());
- ConfigurationChange changes = null;
+ ConfigurationChange changes;
if(lastConfig==null){
changes = ConfigurationChangeBuilder.of(newConfig).putAll(newConfig.getProperties())
.build();
@@ -92,7 +92,7 @@ public class DefaultConfigChangeObserver {
/**
* Sets the new check period, cancels the currently running timer and schedules a new task with the new checkperiod
* and a startup delay of 500ms.
- * @param checkPeriod
+ * @param checkPeriod the period in ms, for checking on changes.
*/
public void setCheckPeriod(long checkPeriod) {
LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
index 75f2c91..586df5c 100644
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
+++ b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
@@ -38,11 +38,11 @@ public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi {
private static final Logger LOG = Logger.getLogger(DefaultConfigEventManagerSpi.class.getName());
- private Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>();
+ private final Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>();
- private ExecutorService publisher = Executors.newCachedThreadPool();
+ private final ExecutorService publisher = Executors.newCachedThreadPool();
- private DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver();
+ private final DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver();
/**
* Constructor. Also loads all registered listeners.
@@ -186,8 +186,8 @@ public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi {
*/
private static final class PublishConfigChangeTask implements Runnable{
- private ConfigEventListener l;
- private ConfigEvent<?> changes;
+ private final ConfigEventListener l;
+ private final ConfigEvent<?> changes;
public PublishConfigChangeTask(ConfigEventListener l, ConfigEvent<?> changes) {
this.l = Objects.requireNonNull(l);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java b/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
index 15f3dfd..f6856d9 100644
--- a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
+++ b/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
@@ -28,10 +28,10 @@ import java.util.UUID;
* @param <T> the vent type
*/
public abstract class BaseConfigEvent<T> implements ConfigEvent<T> {
- private long timestamp = System.currentTimeMillis();
+ protected long timestamp = System.currentTimeMillis();
protected String version = UUID.randomUUID().toString();
- protected T paylod;
- private Class<T> type;
+ protected final T paylod;
+ private final Class<T> type;
public BaseConfigEvent(T paylod, Class<T> type){
this.paylod = Objects.requireNonNull(paylod);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
index c93b2ca..0384064 100644
--- a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
+++ b/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
@@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ChangeableGlobalPropertySource extends BasePropertySource{
- private static Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>();
+ private static final Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>();
@Override
public String getName() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
index 759d429..cc6c812 100644
--- a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
+++ b/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
@@ -30,7 +30,7 @@ import java.util.Map;
*/
public class ChangeableThreadLocalPropertySource extends BasePropertySource{
- private static ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){
+ private static final ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){
protected Map<String,String> initialValue(){
return new HashMap<>();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fefbeca7/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java b/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
index 55b49dc..d54a66e 100644
--- a/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
+++ b/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
@@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals;
*/
public class DefaultConfigEventManagerSpiTest {
- private DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi();
+ private final DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi();
private Object testAddListenerValue;
@Test
[39/50] [abbrv] incubator-tamaya-extensions git commit:
[maven-release-plugin] prepare release 0.2-incubating-rc1
Posted by pl...@apache.org.
[maven-release-plugin] prepare release 0.2-incubating-rc1
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/6a6b4a0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/6a6b4a0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/6a6b4a0b
Branch: refs/heads/old_master
Commit: 6a6b4a0bedeaba8f5f9062db23dc574ddd08fe90
Parents: ee43243
Author: anatole <an...@apache.org>
Authored: Tue Mar 8 20:39:05 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/6a6b4a0b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d9d4854..a59a968 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
+ <version>0.2-incubating</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[43/50] [abbrv] incubator-tamaya-extensions git commit: Reset version
for new release run.
Posted by pl...@apache.org.
Reset version for new release run.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/3d48e37c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/3d48e37c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/3d48e37c
Branch: refs/heads/old_master
Commit: 3d48e37c2b8d17001b8d00050172f68022e1551f
Parents: 75827f2
Author: anatole <an...@apache.org>
Authored: Wed Mar 9 14:09:25 2016 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3d48e37c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d9d4854..6222349 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
+ <version>0.2-incubating-SNAPSHOT</version>
</parent>
<artifactId>tamaya-filter</artifactId>
[02/50] [abbrv] incubator-tamaya-extensions git commit: Removed
useless comments.
Posted by pl...@apache.org.
Removed useless comments.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/4d6c7134
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/4d6c7134
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/4d6c7134
Branch: refs/heads/old_master
Commit: 4d6c7134355290d09c3de1d996c4dbb5e0461b77
Parents: f71dc11
Author: anatole <an...@apache.org>
Authored: Sun Dec 20 11:53:30 2015 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Fri Sep 30 21:29:37 2016 +0200
----------------------------------------------------------------------
src/main/java/org/apache/tamaya/events/ConfigurationChange.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4d6c7134/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
index a291084..0366556 100644
--- a/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
+++ b/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
@@ -126,7 +126,6 @@ public final class ConfigurationChange implements ConfigEvent<Configuration>, Se
}
}
return removedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getNewValue() == null).count();
}
/**
@@ -142,8 +141,6 @@ public final class ConfigurationChange implements ConfigEvent<Configuration>, Se
}
}
return addedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue() == null &&
-// e.getNewValue() != null).count();
}
/**
@@ -158,7 +155,6 @@ public final class ConfigurationChange implements ConfigEvent<Configuration>, Se
}
}
return updatedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue()!=null && e.getNewValue()!=null).count();
}
[32/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-175
Moved the events module to the directory events after extracting it for the
Tamaya main repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/delta/package-info.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/delta/package-info.java b/events/src/main/java/org/apache/tamaya/events/delta/package-info.java
new file mode 100644
index 0000000..2006717
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/delta/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * This package contains artifacts to describe the changes (delta) of a
+ * Configuration or a PropertySource.
+ */
+package org.apache.tamaya.events.delta;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java b/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
new file mode 100644
index 0000000..283719e
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
@@ -0,0 +1,144 @@
+/*
+ * 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.events.folderobserver;
+
+import org.apache.tamaya.ConfigException;
+
+import java.io.IOException;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardWatchEventKinds;
+import java.nio.file.WatchEvent;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchService;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ * Class that has the responsibility to watch the folder and then publish the changes to a
+ * {@link org.apache.tamaya.events.PropertySourceChange}.
+ * @see ObservingPropertySourceProvider
+ * This listener will wait to events and wait to one second to watch again.
+ * <p>If new file was created or modified will commit from this file.</p>
+ * <p>If a file was removed then the listener will load using all files left.</p>
+ * @author otaviojava
+ */
+class FileChangeListener implements Runnable {
+
+ private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName());
+
+ private final WatchService watchService;
+
+ private final FileChangeObserver observer;
+
+ private final Path directory;
+
+ private volatile boolean running = true;
+
+ public FileChangeListener(Path directory, FileChangeObserver observer) {
+ this.observer = observer;
+ this.directory = directory;
+ this.watchService = getWatchService();
+
+ if (watchService!=null && directory!=null) {
+ try {
+ directory.register(watchService,
+ StandardWatchEventKinds.ENTRY_DELETE,
+ StandardWatchEventKinds.ENTRY_MODIFY,
+ StandardWatchEventKinds.ENTRY_CREATE);
+ } catch (IOException e) {
+ throw new FileChangeListenerException("An error happened when does try to registry to watch the folder", e);
+ }
+ }
+ }
+
+ /**
+ * Stops the listener service from observing the target directory.
+ */
+ public void stopListener(){
+ running = false;
+ }
+
+ @Override
+ public void run() {
+ if (watchService!=null || directory!=null) {
+ return;
+ }
+ while (running) {
+ watchFolder();
+ }
+ }
+
+ /**
+ * Start watching the current folder.
+ */
+ private void watchFolder() {
+ try {
+ WatchKey watckKey = watchService.take();
+ for (WatchEvent<?> event : watckKey.pollEvents()) {
+ Path filePath = (Path) watckKey.watchable();
+ if(event.kind().equals(StandardWatchEventKinds.ENTRY_CREATE)||
+ event.kind().equals(StandardWatchEventKinds.ENTRY_MODIFY) ||
+ event.kind().equals(StandardWatchEventKinds.ENTRY_DELETE)){
+ LOGGER.info("File change detected in: " + filePath.getFileName());
+ observer.directoryChanged(filePath);
+ }
+ }
+ watckKey.reset();
+ Thread.sleep(1_000L);
+ } catch (Exception e) {
+ throw new FileChangeListenerException("An error happened when does try to watch the folder", e);
+ }
+ }
+
+ /**
+ * Get the watch service.
+ * @return the watch service, or null, if the watch service is not supported.
+ */
+ private WatchService getWatchService() {
+ try {
+ FileSystem fileSystem = Paths.get(".").getFileSystem();
+ return fileSystem.newWatchService();
+ } catch (IOException e) {
+ LOGGER.log(Level.WARNING, "The file System does not supports WatchService", e);
+ return null;
+ }
+
+ }
+
+ /**
+ * Exception if file listening fails.
+ */
+ static class FileChangeListenerException extends ConfigException {
+ /** Serialversion UID. */
+ private static final long serialVersionUID = -8965486770881001513L;
+
+ /**
+ * Constructor.
+ * @param message a message
+ * @param cause an (optional) root cause.
+ */
+ public FileChangeListenerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java b/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
new file mode 100644
index 0000000..63d25cd
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
@@ -0,0 +1,33 @@
+/*
+ * 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.events.folderobserver;
+
+import java.nio.file.Path;
+
+/**
+ * Observer to be used in {@link FileChangeListener} to commit all configurations and provider.
+ */
+interface FileChangeObserver {
+ /**
+ * Called when a file has been modified.
+ * @param path the file path, not null.
+ */
+ void directoryChanged(Path path);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
new file mode 100644
index 0000000..feddd70
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
@@ -0,0 +1,209 @@
+/*
+ * 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.events.folderobserver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.events.ConfigEventManager;
+import org.apache.tamaya.events.ConfigurationContextChange;
+import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+import org.apache.tamaya.spisupport.BasePropertySource;
+
+/**
+ * This implementation runs in a folder taking up all files compatible with the given
+ * ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider
+ * will adapt the changes automatically and trigger according
+ * {@link org.apache.tamaya.events.PropertySourceChange} events.
+ * The default folder is META-INF/config, but you can change it via an absolute path in the
+ * "-Dtamaya.configdir" parameter.
+ */
+public class ObservingPropertySourceProvider implements PropertySourceProvider, FileChangeObserver {
+ /**
+ * The logger.
+ */
+ private static final Logger LOG = Logger.getLogger(ObservingPropertySourceProvider.class.getName());
+ /**
+ * The current active property sources of this provider.
+ */
+ private final List<PropertySource> propertySources = Collections.synchronizedList(new LinkedList<PropertySource>());
+ /**
+ * The thread pool used.
+ */
+ private final ExecutorService executor = Executors.newSingleThreadExecutor();
+
+ /**
+ * Constructorm using an explicit directory, ignoring all kind of configuration, if set.
+ *
+ * @param directory the target directory. If null, the default configuration and system property are used.
+ */
+ public ObservingPropertySourceProvider(Path directory) {
+ if (directory == null) {
+ directory = getDirectory();
+ }
+ if (directory!=null){
+ synchronized (this.propertySources) {
+ this.propertySources.addAll(readConfiguration(directory));
+ }
+ final Runnable runnable = new FileChangeListener(directory, this);
+ executor.execute(runnable);
+ } else {
+ executor.shutdown();
+ }
+ }
+
+ /**
+ * Read the initial configuration.
+ *
+ * @param directory the target directory, not null.
+ */
+ private List<PropertySource> readConfiguration(Path directory) {
+ final List<PropertySource> result = new ArrayList<>();
+ try {
+ synchronized (propertySources) {
+ for (final Path path : Files.newDirectoryStream(directory, "*")) {
+ result.addAll(getPropertySources(path));
+ }
+ return result;
+ }
+ } catch (final IOException e) {
+ LOG.log(Level.WARNING, "Failed to read configuration from dir: " + directory, e);
+ }
+ return result;
+ }
+
+ /**
+ * Read property sources from the given file.
+ *
+ * @param file source of the property sources.
+ * @return property sources from the given file.
+ */
+ protected Collection<PropertySource> getPropertySources(final Path file) {
+ return Arrays.asList(new PropertySource[]{new BasePropertySource() {
+ private final Map<String,String> props = readProperties(file);
+
+ @Override
+ public Map<String, String> getProperties() {
+ return props;
+ }
+ }});
+ }
+
+ /**
+ * Load a single file.
+ *
+ * @param file the file, not null.
+ * @return properties as read from the given file.
+ */
+ protected static Map<String,String> readProperties(Path file) {
+ try (InputStream is = file.toUri().toURL().openStream()){
+ final Properties props = new Properties();
+ props.load(is);
+ final Map<String,String> result = new HashMap<>();
+ for(final Map.Entry<Object,Object> en:props.entrySet()){
+ result.put(String.valueOf(en.getKey()), String.valueOf(en.getValue()));
+ }
+ return result;
+ } catch (final Exception e) {
+ LOG.log(Level.INFO, "Error reading file: " + file.toString() +
+ ", using format: properties", e);
+ }
+ return Collections.emptyMap();
+ }
+
+
+ /**
+ * Evaluates the target directory from system property (tamaya.configdir) or classpath.
+ *
+ * @return the directory to be read, or null.
+ */
+ private Path getDirectory() {
+ final String absolutePath = System.getProperty("tamaya.configdir");
+ if (null!=absolutePath) {
+ final Path path = Paths.get(absolutePath);
+ if (Files.isDirectory(path)) {
+ return path;
+ }
+ }
+ final URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
+ if (null!=resource) {
+ try {
+ return Paths.get(resource.toURI());
+ } catch (final URISyntaxException e) {
+ throw new ConfigException("An error to find the directory to watch", e);
+ }
+ }
+ return null;
+ }
+
+
+ @Override
+ public void directoryChanged(Path directory) {
+ synchronized (this.propertySources) {
+ final List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
+ propertySources.clear();
+ final Collection<PropertySource> sourcesRead = readConfiguration(directory);
+ this.propertySources.addAll(sourcesRead);
+ triggerConfigChange(existingPropertySources, propertySources);
+ }
+ }
+
+
+ private void triggerConfigChange(List<PropertySource> originalPropertySources,
+ List<PropertySource> newPropertySources) {
+ final ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
+ for (final PropertySource ps : originalPropertySources) {
+ b.removedPropertySource(ps);
+ }
+ for (final PropertySource ps : newPropertySources) {
+ b.newPropertySource(ps);
+ }
+ final ConfigurationContextChange changeEvent = b.build();
+ LOG.fine("Trigger Config Context Change: " + changeEvent);
+ ConfigEventManager.fireEvent(changeEvent);
+ }
+
+ @Override
+ public Collection<PropertySource> getPropertySources() {
+ synchronized (propertySources) {
+ return new ArrayList<>(this.propertySources);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java b/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
new file mode 100644
index 0000000..347f2d8
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+/**
+ * This package contains code to observe a folder for file changes and to trigger
+ * corresponding events, that are handled by an according {@link org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider}
+ * instance.
+ */
+package org.apache.tamaya.events.folderobserver;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
new file mode 100644
index 0000000..f4457b2
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
@@ -0,0 +1,111 @@
+/*
+ * 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.events.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.events.ConfigEventManager;
+import org.apache.tamaya.events.ConfigurationChange;
+import org.apache.tamaya.events.ConfigurationChangeBuilder;
+import org.apache.tamaya.events.FrozenConfiguration;
+
+import java.util.*;
+import java.util.logging.Logger;
+
+/**
+ * Timer task that regularly checks the configuration for changes.
+ */
+public class DefaultConfigChangeObserver {
+
+ private static final long START_DELAY = 5000L;
+
+ private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
+
+ private Timer timer = new Timer("DefaultConfigChangeObserver", true);
+
+ private long checkPeriod = 2000L;
+
+ private volatile FrozenConfiguration lastConfig;
+
+ private volatile boolean running;
+
+ /**
+ * Constructor. Also loads all registered listeners.
+ */
+ public DefaultConfigChangeObserver() {
+ LOG.info("Registering config change observer, rechecking config changes every " + checkPeriod + " ms.");
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ if(running) {
+ checkConfigurationUpdate();
+ }
+ }
+ }, START_DELAY, checkPeriod);
+ }
+
+
+ public void checkConfigurationUpdate() {
+ LOG.finest("Checking configuration for changes...");
+ FrozenConfiguration newConfig = FrozenConfiguration.of(ConfigurationProvider.getConfiguration());
+ ConfigurationChange changes;
+ if(lastConfig==null){
+ changes = ConfigurationChangeBuilder.of(newConfig).putAll(newConfig.getProperties())
+ .build();
+ }else{
+ changes = ConfigurationChangeBuilder.of(lastConfig).addChanges(newConfig)
+ .build();
+ }
+ if(!changes.isEmpty()) {
+ LOG.info("Identified configuration changes, publishing change event...");
+ ConfigEventManager.fireEvent(changes);
+ }
+ }
+
+ public long getCheckPeriod() {
+ return checkPeriod;
+ }
+
+ public boolean isMonitoring(){
+ return running;
+ }
+
+ public void enableMonitoring(boolean enable){
+ this.running = true;
+ }
+
+ /**
+ * Sets the new check period, cancels the currently running timer and schedules a new task with the new checkperiod
+ * and a startup delay of 500ms.
+ * @param checkPeriod the period in ms, for checking on changes.
+ */
+ public void setCheckPeriod(long checkPeriod) {
+ LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
+ this.checkPeriod = checkPeriod;
+ timer.cancel();
+ timer = new Timer("DefaultConfigChangeObserver", true);
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ if(running) {
+ checkConfigurationUpdate();
+ }
+ }
+ }, 500L, checkPeriod);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java b/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
new file mode 100644
index 0000000..586df5c
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
@@ -0,0 +1,202 @@
+/*
+ * 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.events.internal;
+
+import org.apache.tamaya.events.ConfigEvent;
+import org.apache.tamaya.events.ConfigEventListener;
+import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Default implementation of {@link DefaultConfigEventManagerSpi} just forwarding all
+ * events synchronously to the listeners.
+ */
+public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi {
+
+ private static final Logger LOG = Logger.getLogger(DefaultConfigEventManagerSpi.class.getName());
+
+ private final Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>();
+
+ private final ExecutorService publisher = Executors.newCachedThreadPool();
+
+ private final DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver();
+
+ /**
+ * Constructor. Also loads all registered listeners.
+ */
+ public DefaultConfigEventManagerSpi() {
+ try {
+ for (ConfigEventListener l : ServiceContextManager.getServiceContext().getServices(ConfigEventListener.class)) {
+ try {
+ addListener(l);
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to load configured listener: " + l.getClass().getName(), e);
+ }
+ }
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to load configured listeners.", e);
+ }
+ }
+
+ @Override
+ public void addListener(ConfigEventListener l){
+ addListener(l, ConfigEvent.class);
+ }
+
+ @Override
+ public <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType){
+ List<ConfigEventListener> ls = listeners.get(eventType);
+ if(ls==null){
+ ls = Collections.synchronizedList(new ArrayList<ConfigEventListener>());
+ listeners.put(eventType, ls);
+ }
+ synchronized (ls){
+ if(!ls.contains(l)){
+ ls.add(l);
+ }
+ }
+ }
+
+ @Override
+ public void removeListener(ConfigEventListener l){
+ removeListener(l, ConfigEvent.class);
+ }
+
+ @Override
+ public <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
+ List<ConfigEventListener> targets = this.listeners.get(eventType);
+ if(targets!=null) {
+ // forward to explicit listeners
+ synchronized (targets) {
+ targets.remove(l);
+ }
+ }
+ }
+
+ @Override
+ public Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType) {
+ List<ConfigEventListener> targets = this.listeners.get(eventType);
+ if(targets!=null){
+ synchronized(targets){
+ return new ArrayList<>(targets);
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Collection<? extends ConfigEventListener> getListeners() {
+ Set<ConfigEventListener> targets = new HashSet<>();
+ for(List<ConfigEventListener> l:this.listeners.values()){
+ targets.addAll(l);
+ }
+ return targets;
+ }
+
+ @Override
+ public void fireEvent(ConfigEvent<?> event) {
+ List<ConfigEventListener> targets = this.listeners.get(event.getClass());
+ if(targets!=null) {
+ // forward to explicit listeners
+ synchronized (targets) {
+ for (ConfigEventListener l : targets) {
+ l.onConfigEvent(event);
+ }
+ }
+ }
+ // forward to global listeners
+ targets = this.listeners.get(ConfigEvent.class);
+ if(targets!=null) {
+ synchronized (targets) {
+ for (ConfigEventListener l : targets) {
+ l.onConfigEvent(event);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void fireEventAsynch(ConfigEvent<?> event) {
+ List<ConfigEventListener> targets = this.listeners.get(event.getClass());
+ if(targets!=null) {
+ // forward to explicit listeners
+ synchronized (targets) {
+ for (ConfigEventListener l : targets) {
+ publisher.execute(new PublishConfigChangeTask(l, event));
+ }
+ }
+ }
+ // forward to global listeners
+ targets = this.listeners.get(ConfigEvent.class);
+ if(targets!=null) {
+ synchronized (targets) {
+ for (ConfigEventListener l : targets) {
+ publisher.execute(new PublishConfigChangeTask(l, event));
+ }
+ }
+ }
+ }
+
+ @Override
+ public long getChangeMonitoringPeriod() {
+ return changeObserver.getCheckPeriod();
+ }
+
+ @Override
+ public void setChangeMonitoringPeriod(long millis){
+ changeObserver.setCheckPeriod(millis);
+ }
+
+ @Override
+ public boolean isChangeMonitorActive() {
+ return changeObserver.isMonitoring();
+ }
+
+ @Override
+ public void enableChangeMonitor(boolean enable) {
+ changeObserver.enableMonitoring(enable);
+ }
+
+
+ /**
+ * Tasks to inform observers on detected configuration changes.
+ */
+ private static final class PublishConfigChangeTask implements Runnable{
+
+ private final ConfigEventListener l;
+ private final ConfigEvent<?> changes;
+
+ public PublishConfigChangeTask(ConfigEventListener l, ConfigEvent<?> changes) {
+ this.l = Objects.requireNonNull(l);
+ this.changes = Objects.requireNonNull(changes);
+ }
+
+ @Override
+ public void run() {
+ l.onConfigEvent(changes);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java b/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
new file mode 100644
index 0000000..e49856d
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
@@ -0,0 +1,74 @@
+/*
+ * 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.events.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.events.ConfigEvent;
+import org.apache.tamaya.events.ConfigEventListener;
+import org.apache.tamaya.events.ConfigurationContextChange;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Default ConfigEventListener for ConfigurationContextChange events that updates the current context, if resources were
+ * affected.
+ */
+public class DefaultConfigurationContextChangeListener implements ConfigEventListener {
+
+ private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextChangeListener.class.getName());
+
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ if(event.getClass() == ConfigurationContextChange.class) {
+ ConfigurationContextChange contextChange = (ConfigurationContextChange) event;
+ ConfigurationContext context = ConfigurationProvider.getConfigurationContext();
+ List<PropertySource> affectedPropertySources = new ArrayList<>();
+ for (PropertySource ps : context.getPropertySources()) {
+ if (contextChange.isAffected(ps)) {
+ affectedPropertySources.add(ps);
+ }
+ }
+ ConfigurationContextBuilder newContextBuilder = ConfigurationProvider.getConfigurationContextBuilder()
+ .setContext(context);
+ if (!affectedPropertySources.isEmpty()) {
+ Set<String> propertySourceNames = new HashSet<>();
+ for (PropertySource removed : contextChange.getRemovedPropertySources()) {
+ propertySourceNames.add(removed.getName());
+ }
+ newContextBuilder.removePropertySources(propertySourceNames);
+ }
+ newContextBuilder.addPropertySources(contextChange.getAddedPropertySources());
+ newContextBuilder.addPropertySources(contextChange.getUpdatedPropertySources());
+ ConfigurationContext newContext = newContextBuilder.build();
+ try {
+ ConfigurationProvider.setConfigurationContext(newContext);
+ } catch (Exception e) {
+ LOG.log(Level.INFO, "Failed to update the current ConfigurationContext due to config model changes", e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java b/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
new file mode 100644
index 0000000..be8c404
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
@@ -0,0 +1,40 @@
+/*
+ * 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.events.internal;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.events.ConfigEvent;
+import org.apache.tamaya.events.ConfigEventListener;
+
+import java.util.logging.Logger;
+
+/**
+ * Simple ConfigListener that simply logs any detected config changes to INFO level.
+ */
+public class LoggingConfigListener implements ConfigEventListener {
+
+ private static final Logger LOG = Logger.getLogger(LoggingConfigListener.class.getName());
+
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ if(event.getResourceType()== Configuration.class) {
+ LOG.info("Configuration changed: " + event);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/internal/package-info.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/internal/package-info.java b/events/src/main/java/org/apache/tamaya/events/internal/package-info.java
new file mode 100644
index 0000000..9df5ac3
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/internal/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+/**
+ * This package contains internal default implementations for the config events module.
+ */
+package org.apache.tamaya.events.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/package-info.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/package-info.java b/events/src/main/java/org/apache/tamaya/events/package-info.java
new file mode 100644
index 0000000..e175ceb
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+/**
+ * This package provides the main building blocks for handling configuration changes, such as
+ * {@link org.apache.tamaya.events.ConfigEventManager}, {@link org.apache.tamaya.events.ConfigEventListener} and
+ * artifacts to describe the changes (delta) of a Configuration or a PropertySource.
+ */
+package org.apache.tamaya.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java b/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
new file mode 100644
index 0000000..f6856d9
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
@@ -0,0 +1,69 @@
+/*
+ * 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.events.spi;
+
+import org.apache.tamaya.events.ConfigEvent;
+
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * Abstract base class for implementing your own configuration events.
+ * @param <T> the vent type
+ */
+public abstract class BaseConfigEvent<T> implements ConfigEvent<T> {
+ protected long timestamp = System.currentTimeMillis();
+ protected String version = UUID.randomUUID().toString();
+ protected final T paylod;
+ private final Class<T> type;
+
+ public BaseConfigEvent(T paylod, Class<T> type){
+ this.paylod = Objects.requireNonNull(paylod);
+ this.type = Objects.requireNonNull(type);
+ }
+
+ @Override
+ public Class<T> getResourceType() {
+ return type;
+ }
+
+ @Override
+ public T getResource() {
+ return paylod;
+ }
+
+ @Override
+ public String getVersion() {
+ return version;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + '{' +
+ "timestamp=" + timestamp +
+ ", version='" + version + '\'' +
+ ", paylod='" + paylod + '\'' +
+ '}';
+ }
+ }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java b/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
new file mode 100644
index 0000000..66a8f73
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
@@ -0,0 +1,128 @@
+/*
+ * 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.events.spi;
+
+import org.apache.tamaya.events.ConfigEvent;
+import org.apache.tamaya.events.ConfigEventListener;
+
+import java.util.Collection;
+
+/**
+ * SPI interface to implement the {@link org.apache.tamaya.events.ConfigEventManager} singleton.
+ * Implementations of this interface must be registered with the current {@link org.apache.tamaya.spi.ServiceContext},
+ * by default this equals to registering it with {@link java.util.ServiceLoader}. Add {@link javax.annotation.Priority}
+ * annotations for overriding (higher values override lower values).
+ */
+public interface ConfigEventManagerSpi {
+ /**
+ * Adds a listener for observing events. References of this
+ * component to the listeners must be managed as weak references.
+ *
+ * @param <T> the type of the events listened to.
+ * @param l the listener not null.
+ */
+ <T> void addListener(ConfigEventListener l);
+
+ /**
+ * Adds a listener for observing events of a given type.
+ *
+ * @param <T> the type of the events listened to.
+ * @param l the listener not null.
+ * @param eventType the type of concrete configuration event this listeners should be informed about. All other
+ * event types will never be delivered to this listener instance.
+ */
+ <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType);
+
+ /**
+ * Removes a listener for observing events.
+ *
+ * @param l the listener not null.
+ */
+ void removeListener(ConfigEventListener l);
+
+ /**
+ * Removes a listener for observing events of a certain type.
+ *
+ * @param <T> the type of the events listened to.
+ * @param l the listener not null.
+ * @param eventType the type of concrete configuration event this listeners should be informed about. All other
+ * event types will never be delivered toe this listener instance.
+ */
+ <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType);
+
+ /**
+ * Access all globally registered listeners.
+ *
+ * @return the listeners found, never null.
+ */
+ Collection<? extends ConfigEventListener> getListeners();
+
+ /**
+ * Access all listeners listening for a certain event type, including any global listeners.
+ * @param eventType the type of concrete configuration event this listeners should be informed about. All other
+ * event types will never be delivered toe this listener instance.
+ * @return the listeners found, never null.
+ */
+ Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType);
+
+ /**
+ * Publishes an event to all interested listeners, hereby executing all registered listeners sequentually and
+ * synchronously.,
+ *
+ * @param event the event, not null.
+ */
+ void fireEvent(ConfigEvent<?> event);
+
+ /**
+ * Publishes an event to all interested listeners, hereby publishing the change events asynchrously and in
+ * parallel (multithreaded).
+ *
+ * @param event the event, not null.
+ */
+ void fireEventAsynch(ConfigEvent<?> event);
+
+ /**
+ * Get the current check period to check for configuration changes.
+ *
+ * @return the check period in ms.
+ */
+ long getChangeMonitoringPeriod();
+
+ void setChangeMonitoringPeriod(long millis);
+
+ /**
+ * Check if the observer is running currently.
+ *
+ * @return true, if the change monitoring service is currently running.
+ */
+ boolean isChangeMonitorActive();
+
+ /**
+ * Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly
+ * and trigger ConfigurationChange events if something is changed. This is quite handy for publishing
+ * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
+ * can be on this machine, or also remotedly. For handling corresponding {@link ConfigEventListener} have
+ * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
+ *
+ * @param enable whether to enable or disable the change monitoring.
+ */
+ void enableChangeMonitor(boolean enable);
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/java/org/apache/tamaya/events/spi/package-info.java
----------------------------------------------------------------------
diff --git a/events/src/main/java/org/apache/tamaya/events/spi/package-info.java b/events/src/main/java/org/apache/tamaya/events/spi/package-info.java
new file mode 100644
index 0000000..63d2b3b
--- /dev/null
+++ b/events/src/main/java/org/apache/tamaya/events/spi/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * This package contains the SPI to implement the
+ * {@link org.apache.tamaya.events.ConfigEventManager} singleton.
+ */
+package org.apache.tamaya.events.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
new file mode 100644
index 0000000..f9942c1
--- /dev/null
+++ b/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
@@ -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.events.internal.DefaultConfigurationContextChangeListener
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
----------------------------------------------------------------------
diff --git a/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi b/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
new file mode 100644
index 0000000..d45dc43
--- /dev/null
+++ b/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
@@ -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.events.internal.DefaultConfigEventManagerSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
new file mode 100644
index 0000000..0384064
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
@@ -0,0 +1,62 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * PropertySource implementation that accesses properties that are statically stored.
+ */
+public class ChangeableGlobalPropertySource extends BasePropertySource{
+
+ private static final Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>();
+
+ @Override
+ public String getName() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return null;
+ }
+
+ /**
+ * Put a value (globally) into this property source.
+ * @param key the key, not null
+ * @param value the value, not null
+ * @return the entry replaced, or null.
+ */
+ public static String put(String key, String value){
+ return STORED_ENTRIES.put(key,value);
+ }
+
+ /**
+ * Put all the properties, overriding any existing ones with the same key.
+ * @param properties the properties, not null.
+ */
+ public static void putAll(Map<String,String> properties){
+ STORED_ENTRIES.putAll(properties);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
new file mode 100644
index 0000000..cc6c812
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
@@ -0,0 +1,57 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * PropertySource implementation that accesses properties that are stored on ThreadLocal level, e.g. good to use for
+ * testing..
+ */
+public class ChangeableThreadLocalPropertySource extends BasePropertySource{
+
+ private static final ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){
+ protected Map<String,String> initialValue(){
+ return new HashMap<>();
+ }
+ };
+
+ @Override
+ public String getName() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return null;
+ }
+
+ public static String put(String key, String value){
+ return STORED_ENTRIES.get().put(key,value);
+ }
+
+ public static void putAll(Map<String,String> properties){
+ STORED_ENTRIES.get().putAll(properties);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java b/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
new file mode 100644
index 0000000..b56407c
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.events;
+
+import org.junit.Test;
+
+import java.util.UUID;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link ConfigEventManager}.
+ */
+public class ConfigEventManagerTest {
+
+ private Object testAddListenerValue;
+
+ @Test
+ public void testAddRemoveListener() throws Exception {
+ ConfigEventListener testListener = new ConfigEventListener() {
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ testAddListenerValue = event.getResource();
+ }
+ };
+ ConfigEventManager.addListener(testListener);
+ ConfigEventManager.fireEvent(new SimpleEvent("Event1"));
+ assertEquals(testAddListenerValue, "Event1");
+ ConfigEventManager.removeListener(testListener);
+ ConfigEventManager.fireEvent(new SimpleEvent("Event2"));
+ assertEquals(testAddListenerValue, "Event1");
+ }
+
+ @Test
+ public void testFireEvent() throws Exception {
+ ConfigEventListener testListener = new ConfigEventListener() {
+ @Override
+ public void onConfigEvent(ConfigEvent<?> event) {
+ testAddListenerValue = event.getResource();
+ }
+ };
+ ConfigEventManager.addListener(testListener);
+ ConfigEventManager.fireEvent(new SimpleEvent("Event1"));
+ assertEquals(testAddListenerValue, "Event1");
+ ConfigEventManager.removeListener(testListener);
+ ConfigEventManager.fireEvent(new SimpleEvent("Event2"));
+ assertEquals(testAddListenerValue, "Event1");
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java b/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
new file mode 100644
index 0000000..1431228
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link org.apache.tamaya.events.FrozenPropertySource}.
+ */
+public class FrozenPropertySourceTest {
+
+ private static final PropertySource myPS = new SystemPropertySource();
+
+ @Test
+ public void testOf() throws Exception {
+ PropertySource ps = FrozenPropertySource.of(myPS);
+ assertNotNull(ps);
+ }
+
+ @Test
+ public void testGetName() throws Exception {
+ PropertySource ps = FrozenPropertySource.of(myPS);
+ String name = ps.getName();
+ assertNotNull(name);
+ assertEquals(name, ps.getName());
+ }
+
+ @Test
+ public void testGetOrdinal() throws Exception {
+ PropertySource ps = FrozenPropertySource.of(myPS);
+ assertEquals(myPS.getOrdinal(), ps.getOrdinal());
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ PropertySource ps = FrozenPropertySource.of(myPS);
+ assertNotNull(ps);
+ for (Map.Entry<String, String> e : myPS.getProperties().entrySet()) {
+ assertEquals(ps.get(e.getKey()).getValue(), e.getValue());
+ }
+ }
+
+ @Test
+ public void testGetProperties() throws Exception {
+ PropertySource ps = FrozenPropertySource.of(myPS);
+ assertNotNull(ps);
+ assertNotNull(ps.getProperties());
+ assertFalse(ps.getProperties().isEmpty());
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ PropertySource ps1 = FrozenPropertySource.of(myPS);
+ PropertySource ps2 = FrozenPropertySource.of(myPS);
+ assertEquals(ps1.getName(), ps2.getName());
+ assertEquals(ps1.getProperties().size(), ps2.getProperties().size());
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ boolean alwaysDifferent = true;
+ for(int i=0;i<10;i++){
+ PropertySource ps1 = FrozenPropertySource.of(myPS);
+ PropertySource ps2 = FrozenPropertySource.of(myPS);
+ // sometimes not same, because frozenAt in ms maybe different
+ if(ps1.hashCode()==ps2.hashCode()){
+ alwaysDifferent=false;
+ break;
+ }
+ }
+ if(alwaysDifferent){
+ fail("HashCode should be same if frozenAt is in the same ms...");
+ }
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ PropertySource ps = FrozenPropertySource.of(myPS);
+ String toString = ps.toString();
+ assertNotNull(toString);
+ assertTrue(toString.contains("FrozenPropertySource"));
+ assertTrue(toString.contains(myPS.getName()));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java b/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
new file mode 100644
index 0000000..0cd9e2b
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.events;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test (currently manual) to test configuration changes.
+ */
+public class ObservedConfigTest {
+
+ @Test
+ @Ignore // reactivate later...
+ public void testChangingConfig() throws IOException {
+ Configuration config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
+
+ Map<String, String> props = config.getProperties();
+ assertEquals(props.get("test"), "test2");
+ assertEquals(props.get("testValue1"), "value");
+ assertNull(props.get("testValue2"));
+
+ //insert a new properties file into the tempdirectory
+ FileUtils.writeStringToFile(
+ new File(TestObservingProvider.propertyLocation.toFile(), "test2.properties"),
+ "testValue2=anotherValue");
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
+
+ props = config.getProperties();
+
+ assertEquals(props.get("test"), "test2");
+ assertEquals(props.get("testValue1"), "value");
+ assertEquals(props.get("testValue2"), "anotherValue");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java b/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
new file mode 100644
index 0000000..dead0d9
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
@@ -0,0 +1,66 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PropertySource that provides a randome entry, different on each access!
+ */
+public class RandomPropertySource implements PropertySource{
+
+ private Map<String, String> data = new HashMap<>();
+
+ @Override
+ public int getOrdinal() {
+ return 0;
+ }
+
+ @Override
+ public String getName() {
+ return "random";
+ }
+
+ @Override
+ public PropertyValue get(String key) {
+ if(key.equals("random.new")){
+ return PropertyValue.of(key, String.valueOf(Math.random()),getName());
+ }
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ synchronized(data) {
+ data.put("random.new", String.valueOf(Math.random()));
+ data.put("_random.new.source", getName());
+ data.put("_random.new.timestamp", String.valueOf(System.currentTimeMillis()));
+ return new HashMap<>(data);
+ }
+ }
+
+ @Override
+ public boolean isScannable() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java b/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java
new file mode 100644
index 0000000..5017aa1
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java
@@ -0,0 +1,32 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.events.spi.BaseConfigEvent;
+
+/**
+ * Simple test event for testing only.
+ */
+public class SimpleEvent extends BaseConfigEvent<String> {
+
+ public SimpleEvent(String paylod) {
+ super(paylod, String.class);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/TestConfigView.java b/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
new file mode 100644
index 0000000..8e5b397
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
@@ -0,0 +1,156 @@
+/*
+ * 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.events;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.ConfigOperator;
+import org.apache.tamaya.ConfigQuery;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Created by Anatole on 24.03.2015.
+ */
+public class TestConfigView implements ConfigOperator{
+
+ private static final TestConfigView INSTANCE = new TestConfigView();
+
+ private TestConfigView(){}
+
+ public static ConfigOperator of(){
+ return INSTANCE;
+ }
+
+ @Override
+ public Configuration operate(final Configuration config) {
+ return new Configuration() {
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> result = new HashMap<>();
+ for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
+ if (en.getKey().startsWith("test")) {
+ result.put(en.getKey(), en.getValue());
+ }
+ }
+ return result;
+// return config.getProperties().entrySet().stream().filter(e -> e.getKey().startsWith("test")).collect(
+// Collectors.toMap(en -> en.getKey(), en -> en.getValue()));
+ }
+
+ @Override
+ public Configuration with(ConfigOperator operator) {
+ return null;
+ }
+
+ @Override
+ public <T> T query(ConfigQuery<T> query) {
+ return null;
+ }
+
+ @Override
+ public ConfigurationContext getContext() {
+ return config.getContext();
+ }
+
+ @Override
+ public String get(String key) {
+ return getProperties().get(key);
+ }
+
+ @Override
+ public String getOrDefault(String key, String defaultValue) {
+ String val = get(key);
+ if(val==null){
+ return defaultValue;
+ }
+ return val;
+ }
+
+ @Override
+ public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
+ T val = get(key, type);
+ if(val==null){
+ return defaultValue;
+ }
+ return val;
+ }
+
+ @Override
+ public <T> T get(String key, Class<T> type) {
+ return (T) get(key, TypeLiteral.of(type));
+ }
+
+ /**
+ * Accesses the current String value for the given key and tries to convert it
+ * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
+ * {@link org.apache.tamaya.spi.ConfigurationContext}.
+ *
+ * @param key the property's absolute, or relative path, e.g. @code
+ * a/b/c/d.myProperty}.
+ * @param type The target type required, not null.
+ * @param <T> the value type
+ * @return the converted value, never null.
+ */
+ @Override
+ public <T> T get(String key, TypeLiteral<T> type) {
+ String value = get(key);
+ if (value != null) {
+ List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
+ .getPropertyConverters(type);
+ ConversionContext context = new ConversionContext.Builder(
+ key,type).build();
+ for (PropertyConverter<T> converter : converters) {
+ try {
+ T t = converter.convert(value, context);
+ if (t != null) {
+ return t;
+ }
+ } catch (Exception e) {
+ Logger.getLogger(getClass().getName())
+ .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: "
+ + value, e);
+ }
+ }
+ throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": "
+ + key + ", supportedFormats: " + context.getSupportedFormats());
+ }
+ return null;
+ }
+
+ @Override
+ public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
+ T val = get(key, type);
+ if(val==null){
+ return defaultValue;
+ }
+ return val;
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
----------------------------------------------------------------------
diff --git a/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java b/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
new file mode 100644
index 0000000..2685d3e
--- /dev/null
+++ b/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
@@ -0,0 +1,92 @@
+/*
+ * 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.events;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Test configuration property source provider that observes a directory and updated the config if necessary.
+ */
+public class TestObservingProvider extends ObservingPropertySourceProvider{
+
+ public static Path propertyLocation;
+
+ static{
+ try {
+ // create some temporary config
+ Path tempDir = Files.createTempDirectory("observedFolder");
+
+ TestObservingProvider.propertyLocation = tempDir;
+
+ FileUtils.copyInputStreamToFile(
+ TestObservingProvider.class.getResourceAsStream("/test.properties"),
+ new File(tempDir.toFile(), "test.properties"));
+
+ Runtime.getRuntime().addShutdownHook(new Thread(){
+ @Override
+ public void run(){
+ try{
+ // cleanup directory
+ Files.deleteIfExists(getTargetFile("test1.properties"));
+ Files.deleteIfExists(getTargetFile("test2.properties"));
+ Files.deleteIfExists(getTargetFile("test3.properties"));
+ }
+ catch(Exception e){
+ Logger.getLogger("TestObservingProvider").log(Level.WARNING,
+ "Failed to cleanup config test dir", e);
+ }
+ }
+ });
+ }
+ catch(Exception e){
+ Logger.getLogger("TestObservingProvider").log(Level.WARNING, "Failed to init config test dir", e);
+ }
+ }
+
+ private static Path getTargetFile(String name) {
+ File testFile = new File(TestObservingProvider.getTestDirectory(), name);
+ return Paths.get(testFile.toURI());
+ }
+
+ public TestObservingProvider(){
+ super(propertyLocation);
+ Logger.getLogger(getClass().getName()).info("Using test directory: " + getTestPath());
+ }
+
+ public static File getTestDirectory(){
+ String tempDir = System.getProperty("java.io.tmpdir");
+ File dir = new File(tempDir, "tamaya-events-testdir");
+ if(!dir.exists()){
+ dir.mkdirs();
+ }
+ return dir;
+ }
+
+ private static String getTestPath(){
+ return getTestDirectory().getAbsolutePath();
+ }
+}