Rewrite/adaptation based on JSR API. Signed-off-by: Anatole Tresch <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/f7037fbd Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/f7037fbd Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/f7037fbd Branch: refs/heads/configjsr Commit: f7037fbdc68878401b9f85b48c0b31bd7a1ebb24 Parents: 31bdbd2 Author: Anatole Tresch <[email protected]> Authored: Wed Jan 3 09:37:16 2018 +0100 Committer: Anatole Tresch <[email protected]> Committed: Wed Jan 3 09:37:16 2018 +0100 ---------------------------------------------------------------------- apache-commons/pom.xml | 5 - camel/pom.xml | 5 - collections/pom.xml | 5 - configured-sysprops/pom.xml | 5 - consul/pom.xml | 5 - .../tamaya/consul/ConsulConfigSource.java | 241 ++++++++++++++++ .../tamaya/consul/ConsulPropertySource.java | 247 ---------------- .../org.apache.tamaya.spi.PropertySource | 2 +- .../tamaya/consul/ConsulPropertySourceTest.java | 16 +- .../apache/tamaya/consul/ConsulWriteTest.java | 13 +- etcd/pom.xml | 5 - .../apache/tamaya/etcd/EtcdConfigSource.java | 245 ++++++++++++++++ .../apache/tamaya/etcd/EtcdPropertySource.java | 281 ------------------- .../services/javax.config.spi.ConfigSource | 19 ++ .../org.apache.tamaya.spi.PropertySource | 19 -- .../tamaya/etcd/EtcdPropertySourceTest.java | 15 +- hazelcast/pom.xml | 5 - .../tamaya/hazelcast/HazelcastConfigSource.java | 233 +++++++++++++++ .../hazelcast/HazelcastPropertySource.java | 238 ---------------- jodatime/pom.xml | 6 - management/pom.xml | 5 - metamodel/pom.xml | 5 - .../ResourcePropertySourceProviderFactory.java | 4 +- .../factories/URLPropertySourceFactory.java | 4 +- propertysources/pom.xml | 5 - .../ConfigDirConfigSourceProvider.java | 82 ++++++ .../ConfigDirPropertySourceProvider.java | 82 ------ .../MetainfConfigConfigSourceProvider.java | 63 +++++ .../MetainfConfigPropertySourceProvider.java | 63 ----- ...MetainfConfigPropertySourceProviderTest.java | 2 +- remote/pom.xml | 5 - uom/pom.xml | 6 - usagetracker/pom.xml | 5 - validation/pom.xml | 5 - vertx/pom.xml | 5 - 35 files changed, 905 insertions(+), 1046 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/apache-commons/pom.xml ---------------------------------------------------------------------- diff --git a/apache-commons/pom.xml b/apache-commons/pom.xml index 0ed033d..3870562 100644 --- a/apache-commons/pom.xml +++ b/apache-commons/pom.xml @@ -32,11 +32,6 @@ under the License. <dependencies> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-formats</artifactId> <version>${project.parent.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/camel/pom.xml ---------------------------------------------------------------------- diff --git a/camel/pom.xml b/camel/pom.xml index f4324bb..fac9414 100644 --- a/camel/pom.xml +++ b/camel/pom.xml @@ -69,11 +69,6 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-functions</artifactId> <version>${project.parent.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/collections/pom.xml ---------------------------------------------------------------------- diff --git a/collections/pom.xml b/collections/pom.xml index cb9fa83..f729e6b 100644 --- a/collections/pom.xml +++ b/collections/pom.xml @@ -37,11 +37,6 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/configured-sysprops/pom.xml ---------------------------------------------------------------------- diff --git a/configured-sysprops/pom.xml b/configured-sysprops/pom.xml index 28ce175..044a9f4 100644 --- a/configured-sysprops/pom.xml +++ b/configured-sysprops/pom.xml @@ -33,11 +33,6 @@ under the License. <dependencies> <dependency> <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-core</artifactId> <version>${project.parent.version}</version> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/consul/pom.xml ---------------------------------------------------------------------- diff --git a/consul/pom.xml b/consul/pom.xml index c48c7ae..f628e60 100644 --- a/consul/pom.xml +++ b/consul/pom.xml @@ -47,11 +47,6 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-functions</artifactId> <version>${project.parent.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/consul/src/main/java/org/apache/tamaya/consul/ConsulConfigSource.java ---------------------------------------------------------------------- diff --git a/consul/src/main/java/org/apache/tamaya/consul/ConsulConfigSource.java b/consul/src/main/java/org/apache/tamaya/consul/ConsulConfigSource.java new file mode 100644 index 0000000..3555f7a --- /dev/null +++ b/consul/src/main/java/org/apache/tamaya/consul/ConsulConfigSource.java @@ -0,0 +1,241 @@ +/* + * 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.consul; + +import com.google.common.base.Optional; +import com.google.common.net.HostAndPort; +import com.orbitz.consul.Consul; +import com.orbitz.consul.KeyValueClient; +import com.orbitz.consul.model.kv.Value; +import org.apache.tamaya.base.configsource.BaseConfigSource; +import org.apache.tamaya.mutableconfig.ConfigChangeRequest; +import org.apache.tamaya.mutableconfig.spi.MutableConfigSource; + +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Propertysource that is reading configuration from a configured consul endpoint. Setting + * {@code consul.prefix} as system property maps the consul based configuration + * to this prefix namespace. Consul servers are configured as {@code consul.urls} system or environment property. + */ +public class ConsulConfigSource extends BaseConfigSource +implements MutableConfigSource { + private static final Logger LOG = Logger.getLogger(ConsulConfigSource.class.getName()); + + private String prefix = ""; + + private List<HostAndPort> consulBackends; + + + public ConsulConfigSource(String prefix, Collection<String> backends){ + this.prefix = prefix==null?"":prefix; + consulBackends = new ArrayList<>(); + for(String s:backends){ + consulBackends.add(HostAndPort.fromString(s)); + } + } + + public ConsulConfigSource(Collection<String> backends){ + consulBackends = new ArrayList<>(); + for(String s:backends){ + consulBackends.add(HostAndPort.fromString(s)); + } + } + + public ConsulConfigSource(){ + prefix = System.getProperty("tamaya.consul.prefix", ""); + } + + public ConsulConfigSource(String... backends){ + consulBackends = new ArrayList<>(); + for (String s : backends) { + consulBackends.add(HostAndPort.fromString(s)); + } + } + + public String getPrefix() { + return prefix; + } + + public ConsulConfigSource setPrefix(String prefix) { + this.prefix = prefix; + return this; + } + + public int getOrdinal() { + String configuredOrdinal = getValue(CONFIG_ORDINAL); + if(configuredOrdinal!=null){ + try{ + return Integer.parseInt(configuredOrdinal); + } catch(Exception e){ + Logger.getLogger(getClass().getName()).log(Level.WARNING, + "Configured Ordinal is not an int number: " + configuredOrdinal, e); + } + } + return getDefaultOrdinal(); + } + + /** + * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value. + * @return the default ordinal used, by default 1000. + */ + public int getDefaultOrdinal(){ + return 1000; + } + + @Override + public String getName() { + return "consul"; + } + + @Override + public String getValue(String key) { + // check prefix, if key does not start with it, it is not part of our name space + // if so, the prefix part must be removedProperties, so etcd can resolve without it + if(!key.startsWith(prefix)){ + return null; + } else{ + key = key.substring(prefix.length()); + } + String reqKey = key; + if(key.startsWith("_")){ + reqKey = key.substring(1); + if(reqKey.endsWith(".createdIndex")){ + reqKey = reqKey.substring(0,reqKey.length()-".createdIndex".length()); + } else if(reqKey.endsWith(".modifiedIndex")){ + reqKey = reqKey.substring(0,reqKey.length()-".modifiedIndex".length()); + } else if(reqKey.endsWith(".ttl")){ + reqKey = reqKey.substring(0,reqKey.length()-".ttl".length()); + } else if(reqKey.endsWith(".expiration")){ + reqKey = reqKey.substring(0,reqKey.length()-".expiration".length()); + } else if(reqKey.endsWith(".source")){ + reqKey = reqKey.substring(0,reqKey.length()-".source".length()); + } + } + for(HostAndPort hostAndPort: getConsulBackends()){ + try{ + Consul consul = Consul.builder().withHostAndPort(hostAndPort).build(); + KeyValueClient kvClient = consul.keyValueClient(); + Optional<Value> valueOpt = kvClient.getValue(reqKey); + if(!valueOpt.isPresent()) { + LOG.log(Level.FINE, "key not found in consul: " + reqKey); + }else{ + // No prefix mapping necessary here, since we only access/return the value... + Value value = valueOpt.get(); + Map<String,String> props = new HashMap<>(); + props.put(reqKey+".createIndex", String.valueOf(value.getCreateIndex())); + props.put(reqKey+".modifyIndex", String.valueOf(value.getModifyIndex())); + props.put(reqKey+".lockIndex", String.valueOf(value.getLockIndex())); + props.put(reqKey+".flags", String.valueOf(value.getFlags())); + return value.getValue().get(); + } + } catch(Exception e){ + LOG.log(Level.FINE, "etcd access failed on " + hostAndPort + ", trying next...", e); + } + } + return null; + } + + @Override + public Map<String, String> getProperties() { +// for(HostAndPort hostAndPort: getConsulBackends()){ +// try{ +// Consul consul = Consul.builder().withHostAndPort(hostAndPort).build(); +// KeyValueClient kvClient = consul.keyValueClient(); +// Optional<Value> valueOpt = kvClient.getProperty(reqKey); +// try{ +// Map<String, String> props = kvClient.getProperties(""); +// if(!props.containsKey("_ERROR")) { +// return mapPrefix(props); +// } else{ +// LOG.log(Level.FINE, "consul error on " + hostAndPort + ": " + props.get("_ERROR")); +// } +// } catch(Exception e){ +// LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e); +// } +// } catch(Exception e){ +// LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e); +// } +// } + return Collections.emptyMap(); + } + + private Map<String, String> mapPrefix(Map<String, String> props) { + if(prefix.isEmpty()){ + return props; + } + Map<String,String> map = new HashMap<>(); + for(Map.Entry<String,String> entry:props.entrySet()){ + if(entry.getKey().startsWith("_")){ + map.put("_" + prefix + entry.getKey().substring(1), entry.getValue()); + } else{ + map.put(prefix+ entry.getKey(), entry.getValue()); + } + } + return map; + } + + @Override + public void applyChange(ConfigChangeRequest configChange) { + for(HostAndPort hostAndPort: ConsulBackendConfig.getConsulBackends()){ + try{ + Consul consul = Consul.builder().withHostAndPort(hostAndPort).build(); + KeyValueClient kvClient = consul.keyValueClient(); + + for(String k: configChange.getRemovedProperties()){ + try{ + kvClient.deleteKey(k); + } catch(Exception e){ + LOG.info("Failed to remove key from consul: " + k); + } + } + for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){ + String key = en.getKey(); + try{ + kvClient.putValue(key,en.getValue()); + }catch(Exception e) { + LOG.info("Failed to add key to consul: " + en.getKey() + "=" + en.getValue()); + } + } + // success: stop here + break; + } catch(Exception e){ + LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e); + } + } + } + + private List<HostAndPort> getConsulBackends(){ + if(consulBackends==null){ + consulBackends = ConsulBackendConfig.getConsulBackends(); + LOG.info("Using consul backends: " + consulBackends); + } + return consulBackends; + } + + @Override + protected String toStringValues() { + return super.toStringValues() + + " prefix=" + prefix + '\n' + + " backends=" + this.consulBackends + '\n'; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java ---------------------------------------------------------------------- diff --git a/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java b/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java deleted file mode 100644 index 647cc5c..0000000 --- a/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java +++ /dev/null @@ -1,247 +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.consul; - -import com.google.common.base.Optional; -import com.google.common.net.HostAndPort; -import com.orbitz.consul.Consul; -import com.orbitz.consul.KeyValueClient; -import com.orbitz.consul.model.kv.Value; -import org.apache.tamaya.mutableconfig.ConfigChangeRequest; -import org.apache.tamaya.mutableconfig.spi.MutablePropertySource; -import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.propertysource.BasePropertySource; - -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Propertysource that is reading configuration from a configured consul endpoint. Setting - * {@code consul.prefix} as system property maps the consul based configuration - * to this prefix namespace. Consul servers are configured as {@code consul.urls} system or environment property. - */ -public class ConsulPropertySource extends BasePropertySource -implements MutablePropertySource{ - private static final Logger LOG = Logger.getLogger(ConsulPropertySource.class.getName()); - - private String prefix = ""; - - private List<HostAndPort> consulBackends; - - - public ConsulPropertySource(String prefix, Collection<String> backends){ - this.prefix = prefix==null?"":prefix; - consulBackends = new ArrayList<>(); - for(String s:backends){ - consulBackends.add(HostAndPort.fromString(s)); - } - } - - public ConsulPropertySource(Collection<String> backends){ - consulBackends = new ArrayList<>(); - for(String s:backends){ - consulBackends.add(HostAndPort.fromString(s)); - } - } - - public ConsulPropertySource(){ - prefix = System.getProperty("tamaya.consul.prefix", ""); - } - - public ConsulPropertySource(String... backends){ - consulBackends = new ArrayList<>(); - for (String s : backends) { - consulBackends.add(HostAndPort.fromString(s)); - } - } - - public String getPrefix() { - return prefix; - } - - public ConsulPropertySource setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - public int getOrdinal() { - PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); - if(configuredOrdinal!=null){ - try{ - return Integer.parseInt(configuredOrdinal.getValue()); - } catch(Exception e){ - Logger.getLogger(getClass().getName()).log(Level.WARNING, - "Configured Ordinal is not an int number: " + configuredOrdinal, e); - } - } - return getDefaultOrdinal(); - } - - /** - * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value. - * @return the default ordinal used, by default 1000. - */ - public int getDefaultOrdinal(){ - return 1000; - } - - @Override - public String getName() { - return "consul"; - } - - @Override - public PropertyValue get(String key) { - // check prefix, if key does not start with it, it is not part of our name space - // if so, the prefix part must be removedProperties, so etcd can resolve without it - if(!key.startsWith(prefix)){ - return null; - } else{ - key = key.substring(prefix.length()); - } - String reqKey = key; - if(key.startsWith("_")){ - reqKey = key.substring(1); - if(reqKey.endsWith(".createdIndex")){ - reqKey = reqKey.substring(0,reqKey.length()-".createdIndex".length()); - } else if(reqKey.endsWith(".modifiedIndex")){ - reqKey = reqKey.substring(0,reqKey.length()-".modifiedIndex".length()); - } else if(reqKey.endsWith(".ttl")){ - reqKey = reqKey.substring(0,reqKey.length()-".ttl".length()); - } else if(reqKey.endsWith(".expiration")){ - reqKey = reqKey.substring(0,reqKey.length()-".expiration".length()); - } else if(reqKey.endsWith(".source")){ - reqKey = reqKey.substring(0,reqKey.length()-".source".length()); - } - } - for(HostAndPort hostAndPort: getConsulBackends()){ - try{ - Consul consul = Consul.builder().withHostAndPort(hostAndPort).build(); - KeyValueClient kvClient = consul.keyValueClient(); - Optional<Value> valueOpt = kvClient.getValue(reqKey); - if(!valueOpt.isPresent()) { - LOG.log(Level.FINE, "key not found in consul: " + reqKey); - }else{ - // No prefix mapping necessary here, since we only access/return the value... - Value value = valueOpt.get(); - Map<String,String> props = new HashMap<>(); - props.put(reqKey+".createIndex", String.valueOf(value.getCreateIndex())); - props.put(reqKey+".modifyIndex", String.valueOf(value.getModifyIndex())); - props.put(reqKey+".lockIndex", String.valueOf(value.getLockIndex())); - props.put(reqKey+".flags", String.valueOf(value.getFlags())); - return PropertyValue.builder(key, value.getValue().get(), getName()).setMetaEntries(props).build(); - } - } catch(Exception e){ - LOG.log(Level.FINE, "etcd access failed on " + hostAndPort + ", trying next...", e); - } - } - return null; - } - - @Override - public Map<String, PropertyValue> getProperties() { -// for(HostAndPort hostAndPort: getConsulBackends()){ -// try{ -// Consul consul = Consul.builder().withHostAndPort(hostAndPort).build(); -// KeyValueClient kvClient = consul.keyValueClient(); -// Optional<Value> valueOpt = kvClient.getProperty(reqKey); -// try{ -// Map<String, String> props = kvClient.getProperties(""); -// if(!props.containsKey("_ERROR")) { -// return mapPrefix(props); -// } else{ -// LOG.log(Level.FINE, "consul error on " + hostAndPort + ": " + props.get("_ERROR")); -// } -// } catch(Exception e){ -// LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e); -// } -// } catch(Exception e){ -// LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e); -// } -// } - return Collections.emptyMap(); - } - - private Map<String, String> mapPrefix(Map<String, String> props) { - if(prefix.isEmpty()){ - return props; - } - Map<String,String> map = new HashMap<>(); - for(Map.Entry<String,String> entry:props.entrySet()){ - if(entry.getKey().startsWith("_")){ - map.put("_" + prefix + entry.getKey().substring(1), entry.getValue()); - } else{ - map.put(prefix+ entry.getKey(), entry.getValue()); - } - } - return map; - } - - @Override - public boolean isScannable() { - return false; - } - - @Override - public void applyChange(ConfigChangeRequest configChange) { - for(HostAndPort hostAndPort: ConsulBackendConfig.getConsulBackends()){ - try{ - Consul consul = Consul.builder().withHostAndPort(hostAndPort).build(); - KeyValueClient kvClient = consul.keyValueClient(); - - for(String k: configChange.getRemovedProperties()){ - try{ - kvClient.deleteKey(k); - } catch(Exception e){ - LOG.info("Failed to remove key from consul: " + k); - } - } - for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){ - String key = en.getKey(); - try{ - kvClient.putValue(key,en.getValue()); - }catch(Exception e) { - LOG.info("Failed to add key to consul: " + en.getKey() + "=" + en.getValue()); - } - } - // success: stop here - break; - } catch(Exception e){ - LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e); - } - } - } - - private List<HostAndPort> getConsulBackends(){ - if(consulBackends==null){ - consulBackends = ConsulBackendConfig.getConsulBackends(); - LOG.info("Using consul backends: " + consulBackends); - } - return consulBackends; - } - - @Override - protected String toStringValues() { - return super.toStringValues() + - " prefix=" + prefix + '\n' + - " backends=" + this.consulBackends + '\n'; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource ---------------------------------------------------------------------- diff --git a/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource index 4996059..361ac84 100644 --- a/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource +++ b/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource @@ -16,4 +16,4 @@ # specific language governing permissions and limitations # under the License. # -org.apache.tamaya.consul.ConsulPropertySource \ No newline at end of file +org.apache.tamaya.consul.ConsulConfigSource \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/consul/src/test/java/org/apache/tamaya/consul/ConsulPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/consul/src/test/java/org/apache/tamaya/consul/ConsulPropertySourceTest.java b/consul/src/test/java/org/apache/tamaya/consul/ConsulPropertySourceTest.java index 0366b2b..c9ff19f 100644 --- a/consul/src/test/java/org/apache/tamaya/consul/ConsulPropertySourceTest.java +++ b/consul/src/test/java/org/apache/tamaya/consul/ConsulPropertySourceTest.java @@ -18,8 +18,6 @@ */ package org.apache.tamaya.consul; -import org.apache.tamaya.consul.ConsulPropertySource; -import org.apache.tamaya.spi.PropertyValue; import org.junit.BeforeClass; import org.junit.Test; @@ -33,7 +31,7 @@ import static org.junit.Assert.assertEquals; */ public class ConsulPropertySourceTest { - private final ConsulPropertySource propertySource = new ConsulPropertySource(); + private final ConsulConfigSource propertySource = new ConsulConfigSource(); @BeforeClass public static void setup(){ @@ -57,20 +55,16 @@ public class ConsulPropertySourceTest { @Test public void testGet() throws Exception { - Map<String,PropertyValue> props = propertySource.getProperties(); - for(Map.Entry<String,PropertyValue> en:props.entrySet()){ - assertNotNull("Key not found: " + en.getKey(), propertySource.get(en.getKey())); + Map<String,String> props = propertySource.getProperties(); + for(Map.Entry<String,String> en:props.entrySet()){ + assertNotNull("Key not found: " + en.getKey(), propertySource.getValue(en.getKey())); } } @Test public void testGetProperties() throws Exception { - Map<String,PropertyValue> props = propertySource.getProperties(); + Map<String,String> props = propertySource.getProperties(); assertNotNull(props); } - @Test - public void testIsScannable() throws Exception { - assertFalse(propertySource.isScannable()); - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java ---------------------------------------------------------------------- diff --git a/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java b/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java index 1746030..cf8a33b 100644 --- a/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java +++ b/consul/src/test/java/org/apache/tamaya/consul/ConsulWriteTest.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.UUID; import org.apache.tamaya.mutableconfig.ConfigChangeRequest; -import org.apache.tamaya.spi.PropertyValue; import org.junit.BeforeClass; import org.junit.Test; @@ -42,12 +41,12 @@ public class ConsulWriteTest { * Needs to be enabled manually in case you want to do integration tests. */ static boolean execute = false; - private static ConsulPropertySource propertySource; + private static ConsulConfigSource propertySource; @BeforeClass public static void setup() throws MalformedURLException, URISyntaxException { System.setProperty("consul.urls", "http://127.0.0.1:8300"); - propertySource = new ConsulPropertySource(); + propertySource = new ConsulConfigSource(); System.out.println("At the moment no write-tests can be executed to verify the Consul integration. You can manually edit this test class."); } @@ -69,18 +68,18 @@ public class ConsulWriteTest { ConfigChangeRequest request = new ConfigChangeRequest("testDelete"); request.put(taID, "testDelete"); propertySource.applyChange(request); - assertEquals(taID.toString(), propertySource.get("testDelete").getValue()); - assertNotNull(propertySource.get("_testDelete.createdIndex")); + assertEquals(taID.toString(), propertySource.getValue("testDelete")); + assertNotNull(propertySource.getValue("_testDelete.createdIndex")); request = new ConfigChangeRequest("testDelete2"); request.remove("testDelete"); propertySource.applyChange(request); - assertNull(propertySource.get("testDelete")); + assertNull(propertySource.getValue("testDelete")); } @Test public void testGetProperties() throws Exception { if(!execute)return; - Map<String,PropertyValue> result = propertySource.getProperties(); + Map<String,String> result = propertySource.getProperties(); assertTrue(result.isEmpty()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/etcd/pom.xml ---------------------------------------------------------------------- diff --git a/etcd/pom.xml b/etcd/pom.xml index ef818a1..1713737 100644 --- a/etcd/pom.xml +++ b/etcd/pom.xml @@ -46,11 +46,6 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-functions</artifactId> <version>${project.parent.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/etcd/src/main/java/org/apache/tamaya/etcd/EtcdConfigSource.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/apache/tamaya/etcd/EtcdConfigSource.java b/etcd/src/main/java/org/apache/tamaya/etcd/EtcdConfigSource.java new file mode 100644 index 0000000..05c3a53 --- /dev/null +++ b/etcd/src/main/java/org/apache/tamaya/etcd/EtcdConfigSource.java @@ -0,0 +1,245 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.etcd; + +import org.apache.tamaya.base.configsource.BaseConfigSource; +import org.apache.tamaya.mutableconfig.ConfigChangeRequest; +import org.apache.tamaya.mutableconfig.spi.MutableConfigSource; + +import java.util.ArrayList; +import java.util.Collection; +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; + +/** + * Propertysource that is reading configuration from a configured etcd endpoint. Setting + * {@code etcd.prefix} as system property maps the etcd based configuration + * to this prefix namespace. Etcd servers are configured as {@code etcd.server.urls} system or environment property. + * Etcd can be disabled by setting {@code tamaya.etcdprops.disable} either as environment or system property. + */ +public class EtcdConfigSource extends BaseConfigSource + implements MutableConfigSource { + private static final Logger LOG = Logger.getLogger(EtcdConfigSource.class.getName()); + + private String prefix = System.getProperty("tamaya.etcd.prefix", ""); + + private List<EtcdAccessor> etcdBackends; + + private Map<String,String> metaData = new HashMap<>(); + + public EtcdConfigSource(String prefix, Collection<String> backends){ + this(backends); + String metadataPrefix = "[meta]datasource."+getName()+"."; + if(prefix!=null && !prefix.isEmpty()){ + this.prefix = prefix; + metaData.put(metadataPrefix+"prefix", prefix); + } + } + + public EtcdConfigSource(Collection<String> backends){ + etcdBackends = new ArrayList<>(); + for(String s:backends){ + etcdBackends.add(new EtcdAccessor(s)); + } + setDefaultOrdinal(1000); + setName("etcd"); + String metadataPrefix = "[meta]datasource."+getName()+"."; + metaData.put(metadataPrefix+"backend", "etcd"); + metaData.put(metadataPrefix+"backends", getBackendConfigString()); + } + + public EtcdConfigSource(){ + prefix = System.getProperty("tamaya.etcd.prefix", ""); + setDefaultOrdinal(1000); + setName("etcd"); + String metadataPrefix = "[meta]datasource."+getName()+"."; + if(prefix!=null && !prefix.isEmpty()){ + metaData.put(metadataPrefix+"prefix", prefix); + } + metaData.put(metadataPrefix+"backend", "etcd"); + metaData.put(metadataPrefix+"backends", getBackendConfigString()); + } + + public EtcdConfigSource(String... backends){ + etcdBackends = new ArrayList<>(); + for (String s : backends) { + etcdBackends.add(new EtcdAccessor(s)); + } + setDefaultOrdinal(1000); + setName("etcd"); + String metadataPrefix = "[meta]datasource."+getName()+"."; + if(prefix!=null && !prefix.isEmpty()){ + metaData.put(metadataPrefix+"prefix", prefix); + } + metaData.put(metadataPrefix+"backend", "etcd"); + metaData.put(metadataPrefix+"backends", getBackendConfigString()); + } + + public String getPrefix() { + return prefix; + } + + public EtcdConfigSource setPrefix(String prefix) { + this.prefix = prefix==null?"":prefix; + String metadataPrefix = "[meta]datasource."+getName()+"."; + if(!prefix.isEmpty()){ + metaData.put(metadataPrefix+"prefix", prefix); + }else{ + metaData.remove(metadataPrefix+"prefix"); + } + return this; + } + + @Override + public int getOrdinal() { + String configuredOrdinal = getValue(CONFIG_ORDINAL); + if(configuredOrdinal!=null){ + try{ + return Integer.parseInt(configuredOrdinal); + } catch(Exception e){ + Logger.getLogger(getClass().getName()).log(Level.WARNING, + "Configured ordinal is not an int number: " + configuredOrdinal, e); + } + } + return getDefaultOrdinal(); + } + + @Override + public String getValue(String key) { + // check prefix, if key does not start with it, it is not part of our name space + // if so, the prefix part must be removedProperties, so etcd can resolve without it + if(!key.startsWith(prefix)){ + return null; + } else{ + key = key.substring(prefix.length()); + } + Map<String,String> props; + for(EtcdAccessor accessor: EtcdBackendConfig.getEtcdBackends()){ + try{ + props = accessor.get(key); + if(!props.containsKey("_ERROR")) { + return props.get(key); + } else{ + LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR")); + } + } catch(Exception e){ + LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e); + } + } + return null; + } + + @Override + public Map<String, String> getProperties() { + for(EtcdAccessor accessor: getEtcdBackends()){ + try{ + Map<String, String> props = accessor.getProperties(""); + if(!props.containsKey("_ERROR")) { + return mapMetadata(props); + } else{ + LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR")); + } + } catch(Exception e){ + LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e); + } + } + return Collections.emptyMap(); + } + + private Map<String, String> mapMetadata(Map<String, String> props) { + Map<String, String> values = new HashMap<>(); + values.putAll(metaData); + // Evaluate keys + for(Map.Entry<String,String> entry:props.entrySet()) { + if (!entry.getKey().startsWith("_")) { + values.put(prefix + "etcd:" + entry.getKey(), entry.getValue()); + } + } + return values; + } + + @Override + public void applyChange(ConfigChangeRequest configChange) { + for(EtcdAccessor accessor: EtcdBackendConfig.getEtcdBackends()){ + try{ + for(String k: configChange.getRemovedProperties()){ + Map<String,String> res = accessor.delete(k); + if(res.get("_ERROR")!=null){ + LOG.info("Failed to remove key from etcd: " + k); + } + } + for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){ + String key = en.getKey(); + Integer ttl = null; + int index = en.getKey().indexOf('?'); + if(index>0){ + key = en.getKey().substring(0, index); + String rawQuery = en.getKey().substring(index+1); + String[] queries = rawQuery.split("&"); + for(String query:queries){ + if(query.contains("ttl")){ + int qIdx = query.indexOf('='); + ttl = qIdx>0?Integer.parseInt(query.substring(qIdx+1).trim()):null; + } + } + } + Map<String,String> res = accessor.set(key, en.getValue(), ttl); + if(res.get("_ERROR")!=null){ + LOG.info("Failed to add key to etcd: " + en.getKey() + "=" + en.getValue()); + } + } + // success, stop here + break; + } catch(Exception e){ + LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e); + } + } + } + + private List<EtcdAccessor> getEtcdBackends(){ + if(etcdBackends==null){ + etcdBackends = EtcdBackendConfig.getEtcdBackends(); + LOG.info("Using etcd backends: " + etcdBackends); + } + return etcdBackends; + } + + @Override + protected String toStringValues() { + return super.toStringValues() + + " prefix=" + prefix + '\n' + + " backends=" + this.etcdBackends + '\n'; + } + + private String getBackendConfigString() { + String backendProp = ""; + for(EtcdAccessor acc:getEtcdBackends()){ + if(backendProp.isEmpty()){ + backendProp += acc.getUrl(); + }else{ + backendProp += ", " + acc.getUrl(); + } + } + return backendProp; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java b/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java deleted file mode 100644 index 1e7f17c..0000000 --- a/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java +++ /dev/null @@ -1,281 +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.etcd; - -import org.apache.tamaya.mutableconfig.ConfigChangeRequest; -import org.apache.tamaya.mutableconfig.spi.MutablePropertySource; -import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spi.PropertyValueBuilder; -import org.apache.tamaya.spisupport.propertysource.BasePropertySource; - -import java.util.ArrayList; -import java.util.Collection; -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; - -/** - * Propertysource that is reading configuration from a configured etcd endpoint. Setting - * {@code etcd.prefix} as system property maps the etcd based configuration - * to this prefix namespace. Etcd servers are configured as {@code etcd.server.urls} system or environment property. - * Etcd can be disabled by setting {@code tamaya.etcdprops.disable} either as environment or system property. - */ -public class EtcdPropertySource extends BasePropertySource - implements MutablePropertySource{ - private static final Logger LOG = Logger.getLogger(EtcdPropertySource.class.getName()); - - private String prefix = System.getProperty("tamaya.etcd.prefix", ""); - - private List<EtcdAccessor> etcdBackends; - - private Map<String,String> metaData = new HashMap<>(); - - public EtcdPropertySource(String prefix, Collection<String> backends){ - this.prefix = prefix==null?"":prefix; - etcdBackends = new ArrayList<>(); - for(String s:backends){ - etcdBackends.add(new EtcdAccessor(s)); - } - setDefaultOrdinal(1000); - setName("etcd"); - if(!prefix.isEmpty()){ - metaData.put("prefix", prefix); - } - metaData.put("backend", "etcd"); - metaData.put("backends", backends.toString()); - } - - public EtcdPropertySource(Collection<String> backends){ - etcdBackends = new ArrayList<>(); - for(String s:backends){ - etcdBackends.add(new EtcdAccessor(s)); - } - setDefaultOrdinal(1000); - setName("etcd"); - metaData.put("backend", "etcd"); - metaData.put("backends", backends.toString()); - } - - public EtcdPropertySource(){ - prefix = System.getProperty("tamaya.etcd.prefix", ""); - setDefaultOrdinal(1000); - setName("etcd"); - if(!prefix.isEmpty()){ - metaData.put("prefix", prefix); - } - metaData.put("backend", "etcd"); - String backendProp = ""; - for(EtcdAccessor acc:getEtcdBackends()){ - if(backendProp.isEmpty()){ - backendProp += acc.getUrl(); - }else{ - backendProp += ", " + acc.getUrl(); - } - } - metaData.put("backends", backendProp); - } - - public EtcdPropertySource(String... backends){ - etcdBackends = new ArrayList<>(); - for (String s : backends) { - etcdBackends.add(new EtcdAccessor(s)); - } - setDefaultOrdinal(1000); - setName("etcd"); - if(!prefix.isEmpty()){ - metaData.put("prefix", prefix); - } - metaData.put("backend", "etcd"); - metaData.put("backends", backends.toString()); - } - - public String getPrefix() { - return prefix; - } - - public EtcdPropertySource setPrefix(String prefix) { - this.prefix = prefix==null?"":prefix; - if(!prefix.isEmpty()){ - metaData.put("prefix", prefix); - }else{ - metaData.remove("prefix"); - } - return this; - } - - @Override - public int getOrdinal() { - PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); - if(configuredOrdinal!=null){ - try{ - return Integer.parseInt(configuredOrdinal.getValue()); - } catch(Exception e){ - Logger.getLogger(getClass().getName()).log(Level.WARNING, - "Configured ordinal is not an int number: " + configuredOrdinal, e); - } - } - return getDefaultOrdinal(); - } - - @Override - public PropertyValue get(String key) { - // check prefix, if key does not start with it, it is not part of our name space - // if so, the prefix part must be removedProperties, so etcd can resolve without it - if(!key.startsWith(prefix)){ - return null; - } else{ - key = key.substring(prefix.length()); - } - Map<String,String> props; - for(EtcdAccessor accessor: EtcdBackendConfig.getEtcdBackends()){ - try{ - props = accessor.get(key); - if(!props.containsKey("_ERROR")) { - // No prefix mapping necessary here, since we only access/return the value... - return PropertyValue.builder(key, props.get(key), getName()).setMetaEntries(metaData) - .addMetaEntries(props).removeMetaEntry(key).build(); - } else{ - LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR")); - } - } catch(Exception e){ - LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e); - } - } - return null; - } - - @Override - public Map<String, PropertyValue> getProperties() { - for(EtcdAccessor accessor: getEtcdBackends()){ - try{ - Map<String, String> props = accessor.getProperties(""); - if(!props.containsKey("_ERROR")) { - return mapPrefix(props); - } else{ - LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR")); - } - } catch(Exception e){ - LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e); - } - } - return Collections.emptyMap(); - } - - private Map<String, PropertyValue> mapPrefix(Map<String, String> props) { - - Map<String, PropertyValueBuilder> builders = new HashMap<>(); - // Evaluate keys - for(Map.Entry<String,String> entry:props.entrySet()) { - if (!entry.getKey().startsWith("_")) { - PropertyValueBuilder builder = builders.get(entry.getKey()); - if (builder == null) { - builder = PropertyValue.builder(entry.getKey(), "", getName()).setMetaEntries(metaData); - builders.put(entry.getKey(), builder); - } - } - } - // add meta entries - for(Map.Entry<String,String> entry:props.entrySet()) { - if (entry.getKey().startsWith("_")) { - String key = entry.getKey().substring(1); - for(String field:new String[]{".createdIndex", ".modifiedIndex", ".ttl", - ".expiration", ".source"}) { - if (key.endsWith(field)) { - key = key.substring(0, key.length() - field.length()); - PropertyValueBuilder builder = builders.get(key); - if (builder != null) { - builder.addMetaEntry(field, entry.getValue()); - } - } - } - } - } - // Map to value map. - Map<String, PropertyValue> values = new HashMap<>(); - for(Map.Entry<String,PropertyValueBuilder> en:builders.entrySet()) { - if(prefix.isEmpty()){ - values.put(en.getKey(), en.getValue().build()); - }else{ - values.put(prefix + en.getKey(), en.getValue().setKey(prefix + en.getKey()).build()); - } - } - return values; - } - - @Override - public boolean isScannable() { - return true; - } - - @Override - public void applyChange(ConfigChangeRequest configChange) { - for(EtcdAccessor accessor: EtcdBackendConfig.getEtcdBackends()){ - try{ - for(String k: configChange.getRemovedProperties()){ - Map<String,String> res = accessor.delete(k); - if(res.get("_ERROR")!=null){ - LOG.info("Failed to remove key from etcd: " + k); - } - } - for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){ - String key = en.getKey(); - Integer ttl = null; - int index = en.getKey().indexOf('?'); - if(index>0){ - key = en.getKey().substring(0, index); - String rawQuery = en.getKey().substring(index+1); - String[] queries = rawQuery.split("&"); - for(String query:queries){ - if(query.contains("ttl")){ - int qIdx = query.indexOf('='); - ttl = qIdx>0?Integer.parseInt(query.substring(qIdx+1).trim()):null; - } - } - } - Map<String,String> res = accessor.set(key, en.getValue(), ttl); - if(res.get("_ERROR")!=null){ - LOG.info("Failed to add key to etcd: " + en.getKey() + "=" + en.getValue()); - } - } - // success, stop here - break; - } catch(Exception e){ - LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e); - } - } - } - - private List<EtcdAccessor> getEtcdBackends(){ - if(etcdBackends==null){ - etcdBackends = EtcdBackendConfig.getEtcdBackends(); - LOG.info("Using etcd backends: " + etcdBackends); - } - return etcdBackends; - } - - @Override - protected String toStringValues() { - return super.toStringValues() + - " prefix=" + prefix + '\n' + - " backends=" + this.etcdBackends + '\n'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/etcd/src/main/resources/META-INF/services/javax.config.spi.ConfigSource ---------------------------------------------------------------------- diff --git a/etcd/src/main/resources/META-INF/services/javax.config.spi.ConfigSource b/etcd/src/main/resources/META-INF/services/javax.config.spi.ConfigSource new file mode 100644 index 0000000..813e825 --- /dev/null +++ b/etcd/src/main/resources/META-INF/services/javax.config.spi.ConfigSource @@ -0,0 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy current the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +org.apache.tamaya.etcd.EtcdConfigSource \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource ---------------------------------------------------------------------- diff --git a/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource deleted file mode 100644 index eb7958e..0000000 --- a/etcd/src/main/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.etcd.EtcdPropertySource \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java b/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java index 8b6569f..c7caf77 100644 --- a/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java +++ b/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java @@ -18,7 +18,6 @@ */ package org.apache.tamaya.etcd; -import org.apache.tamaya.spi.PropertyValue; import org.junit.BeforeClass; import org.junit.Test; @@ -32,7 +31,7 @@ import static org.junit.Assert.assertEquals; */ public class EtcdPropertySourceTest { - private final EtcdPropertySource propertySource = new EtcdPropertySource(); + private final EtcdConfigSource propertySource = new EtcdConfigSource(); @BeforeClass public static void setup(){ @@ -56,20 +55,16 @@ public class EtcdPropertySourceTest { @Test public void testGet() throws Exception { - Map<String,PropertyValue> props = propertySource.getProperties(); - for(Map.Entry<String,PropertyValue> en:props.entrySet()){ - assertNotNull("Key not found: " + en.getKey(), propertySource.get(en.getKey())); + Map<String,String> props = propertySource.getProperties(); + for(Map.Entry<String,String> en:props.entrySet()){ + assertNotNull("Key not found: " + en.getKey(), propertySource.getValue(en.getKey())); } } @Test public void testGetProperties() throws Exception { - Map<String,PropertyValue> props = propertySource.getProperties(); + Map<String,String> props = propertySource.getProperties(); assertNotNull(props); } - @Test - public void testIsScannable() throws Exception { - assertTrue(propertySource.isScannable()); - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/hazelcast/pom.xml ---------------------------------------------------------------------- diff --git a/hazelcast/pom.xml b/hazelcast/pom.xml index 834a808..db03c09 100644 --- a/hazelcast/pom.xml +++ b/hazelcast/pom.xml @@ -46,11 +46,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-functions</artifactId> <version>${project.parent.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastConfigSource.java ---------------------------------------------------------------------- diff --git a/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastConfigSource.java b/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastConfigSource.java new file mode 100644 index 0000000..5808ac9 --- /dev/null +++ b/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastConfigSource.java @@ -0,0 +1,233 @@ +/* + * 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.hazelcast; + +import com.hazelcast.config.Config; +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.core.IList; +import com.hazelcast.core.IMap; +import org.apache.tamaya.base.configsource.BaseConfigSource; +import org.apache.tamaya.mutableconfig.ConfigChangeRequest; +import org.apache.tamaya.mutableconfig.spi.MutableConfigSource; +import org.apache.tamaya.spi.PropertyValue; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Distributed Propertysource using a in-memory hazelcast cluster. + * Created by atsticks on 03.11.16. + * + * Basically all kind of property entris can be stored. Additionally this property source allows + * to pass additional meta-entries to control the TTL of the data in milliseconds. For illustration + * the following map will store {@code my.entry} with a TLL of 20000 milliseconds (20 seconds) and + * store {@code my.otherEntry} with infinite lifetime (as long as the cluster is alive): + * + * {@code + * my.entry=myvalue + * _my.entry.ttl=20000 + * my.otherEntry=1234 + * } + * + * By default a new hazelcast instance is created, but it is also possible to reuse an existing + * instance of pass a Hazelcast configuration instance. + */ +public class HazelcastConfigSource extends BaseConfigSource +implements MutableConfigSource { + /** The logger. */ + private static final Logger LOG = Logger.getLogger(HazelcastConfigSource.class.getName()); + /** The Hazelcast config map used. */ + private Map<String, String> configMap = new HashMap<>(); + /** The hazelcast API instance. */ + private HazelcastInstance hazelcastInstance; + /** The hazelcast map reference ID used, by default {@code tamaya.configuration}. */ + private String mapReference = "tamaya.configuration"; + /** Flag if this property source is read-only. */ + private boolean readOnly = false; + + /** + * Creates a new instance, hereby using {@code "Hazelcast"} as property source name and + * a default hazelcast backend created by calling {@link Hazelcast#newHazelcastInstance()}. + */ + public HazelcastConfigSource(){ + super("Hazelcast"); + this.hazelcastInstance = Hazelcast.newHazelcastInstance(); + } + + /** + * Creates a new instance, hereby using {@code "Hazelcast"} as property source name and the + * given hazelcast instance. + * @param hazelcastInstance the hazelcast instance, not null. + */ + public HazelcastConfigSource(HazelcastInstance hazelcastInstance){ + this("Hazelcast", hazelcastInstance); + } + + /** + * Creates a new instance, hereby using the given property source name and + * a default hazelcast backend created by calling {@link Hazelcast#newHazelcastInstance()}. + * @param name the property source name, not null. + */ + public HazelcastConfigSource(String name){ + super(name); + this.hazelcastInstance = Hazelcast.newHazelcastInstance(); + } + + /** + * Creates a new instance, hereby using the given property source name and + * a creating a new hazelcast backend using the given Hazelcast {@link Config}. + * @param config the hazelcast config, not null. + * @param name the property source name, not null. + */ + public HazelcastConfigSource(String name, Config config){ + super(name); + this.hazelcastInstance = Hazelcast.newHazelcastInstance(config); + } + + /** + * Creates a new instance, hereby using the given property source name and the + * hazelcast instance. + * @param name + * @param hazelcastInstance + */ + public HazelcastConfigSource(String name, HazelcastInstance hazelcastInstance){ + super(name); + this.hazelcastInstance = Objects.requireNonNull(hazelcastInstance); + } + + /** + * Setting the read-only flag for this instance. + * @param readOnly if true, the property source will not write back any changes to the + * hazelcast backend. + */ + public void setReadOnly(boolean readOnly){ + this.readOnly = readOnly; + } + + /** + * Flag to check if the property source is read-only. + * @return true, if the instance is read-only. + */ + public boolean isReadOnly(){ + return readOnly; + } + + /** + * Set the Hazelcast reference name for the Tamaya configuration Map. + * @param mapReference the map reference to be used, not null. + */ + public void setMapReference(String mapReference){ + this.mapReference = Objects.requireNonNull(mapReference); + } + + /** + * Get the Hazelcast reference name for the Tamaya configuration Map. + * @return the Hazelcast reference name for the Tamaya configuration Map, never null. + */ + public String getMapReference(){ + return mapReference; + } + + /** + * Get access to the hazelcast instance used. + * @return the hazelcast instance, not null. + */ + public HazelcastInstance getHazelcastInstance() { + return hazelcastInstance; + } + + @Override + public String getValue(String key) { + Config hcConfig = hazelcastInstance.getConfig(); + String value = hcConfig.getProperty(key); + if(value==null){ + return null; + } + return value; + } + + @Override + public Map<String, String> getProperties() { + Map<String,String> meta = new HashMap<>(); + String prefix = "[meta]datasource."+getName()+"."; + meta.put(prefix+"backend", "Hazelcast"); + meta.put(prefix+"instance", hazelcastInstance.getConfig().getInstanceName()); + meta.put(prefix+"_mapReference", mapReference); + this.configMap.putAll(meta); + return Collections.unmodifiableMap(this.configMap); + } + + /** + * Reloads the configuration map from Hazelcast completely. + */ + public void refresh() { + IMap<String,String> config = hazelcastInstance.getMap(mapReference); + Map<String, String> configMap = new HashMap<>(config); + this.configMap = configMap; + } + + @Override + public void applyChange(ConfigChangeRequest configChange) { + if(readOnly){ + return; + } + IMap<String,String> config = hazelcastInstance.getMap(mapReference); + for(Map.Entry<String, String> en: configChange.getAddedProperties().entrySet()){ + String metaVal = configChange.getAddedProperties().get("_" + en.getKey()+".ttl"); + if(metaVal!=null){ + try { + long ms = Long.parseLong(metaVal); + config.put(en.getKey(), en.getValue(), ms, TimeUnit.MILLISECONDS); + }catch(Exception e){ + LOG.log(Level.WARNING, "Failed to parse TTL in millis: " + metaVal + + " for '"+ en.getKey()+"'", e); + config.put(en.getKey(), en.getValue()); + } + }else { + config.put(en.getKey(), en.getValue()); + } + } + for(String key: configChange.getRemovedProperties()){ + config.remove(key); + } + IList<String> taList = hazelcastInstance.getList("_tamaya.transactions"); + taList.add(configChange.getTransactionID()); + config.put("_tamaya.transaction.lastId", configChange.getTransactionID(), 1, TimeUnit.DAYS); + config.put("_tamaya.transaction.startedAt", String.valueOf(configChange.getStartedAt()), 1, TimeUnit.DAYS); + config.flush(); + refresh(); + } + + @Override + protected String toStringValues() { + return super.toStringValues() + + "\n hazelcastInstance=" + hazelcastInstance + + "\n name='" + getName() + '\'' + + "\n mapReference='" + mapReference + '\'' + + "\n readOnly=" + readOnly + '\''; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java ---------------------------------------------------------------------- diff --git a/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java b/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java deleted file mode 100644 index 9f63a0e..0000000 --- a/hazelcast/src/main/java/org/apache/tamaya/hazelcast/HazelcastPropertySource.java +++ /dev/null @@ -1,238 +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.hazelcast; - -import com.hazelcast.config.Config; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IList; -import com.hazelcast.core.IMap; -import org.apache.tamaya.mutableconfig.ConfigChangeRequest; -import org.apache.tamaya.mutableconfig.spi.MutablePropertySource; -import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.propertysource.BasePropertySource; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Distributed Propertysource using a in-memory hazelcast cluster. - * Created by atsticks on 03.11.16. - * - * Basically all kind of property entris can be stored. Additionally this property source allows - * to pass additional meta-entries to control the TTL of the data in milliseconds. For illustration - * the following map will store {@code my.entry} with a TLL of 20000 milliseconds (20 seconds) and - * store {@code my.otherEntry} with infinite lifetime (as long as the cluster is alive): - * - * {@code - * my.entry=myvalue - * _my.entry.ttl=20000 - * my.otherEntry=1234 - * } - * - * By default a new hazelcast instance is created, but it is also possible to reuse an existing - * instance of pass a Hazelcast configuration instance. - */ -public class HazelcastPropertySource extends BasePropertySource -implements MutablePropertySource{ - /** The logger. */ - private static final Logger LOG = Logger.getLogger(HazelcastPropertySource.class.getName()); - /** The Hazelcast config map used. */ - private Map<String, String> configMap = new HashMap<>(); - /** The hazelcast API instance. */ - private HazelcastInstance hazelcastInstance; - /** The hazelcast map reference ID used, by default {@code tamaya.configuration}. */ - private String mapReference = "tamaya.configuration"; - /** Flag if this property source is read-only. */ - private boolean readOnly = false; - - /** - * Creates a new instance, hereby using {@code "Hazelcast"} as property source name and - * a default hazelcast backend created by calling {@link Hazelcast#newHazelcastInstance()}. - */ - public HazelcastPropertySource(){ - super("Hazelcast"); - this.hazelcastInstance = Hazelcast.newHazelcastInstance(); - } - - /** - * Creates a new instance, hereby using {@code "Hazelcast"} as property source name and the - * given hazelcast instance. - * @param hazelcastInstance the hazelcast instance, not null. - */ - public HazelcastPropertySource(HazelcastInstance hazelcastInstance){ - this("Hazelcast", hazelcastInstance); - } - - /** - * Creates a new instance, hereby using the given property source name and - * a default hazelcast backend created by calling {@link Hazelcast#newHazelcastInstance()}. - * @param name the property source name, not null. - */ - public HazelcastPropertySource(String name){ - super(name); - this.hazelcastInstance = Hazelcast.newHazelcastInstance(); - } - - /** - * Creates a new instance, hereby using the given property source name and - * a creating a new hazelcast backend using the given Hazelcast {@link Config}. - * @param config the hazelcast config, not null. - * @param name the property source name, not null. - */ - public HazelcastPropertySource(String name, Config config){ - super(name); - this.hazelcastInstance = Hazelcast.newHazelcastInstance(config); - } - - /** - * Creates a new instance, hereby using the given property source name and the - * hazelcast instance. - * @param name - * @param hazelcastInstance - */ - public HazelcastPropertySource(String name, HazelcastInstance hazelcastInstance){ - super(name); - this.hazelcastInstance = Objects.requireNonNull(hazelcastInstance); - } - - /** - * Setting the read-only flag for this instance. - * @param readOnly if true, the property source will not write back any changes to the - * hazelcast backend. - */ - public void setReadOnly(boolean readOnly){ - this.readOnly = readOnly; - } - - /** - * Flag to check if the property source is read-only. - * @return true, if the instance is read-only. - */ - public boolean isReadOnly(){ - return readOnly; - } - - /** - * Set the Hazelcast reference name for the Tamaya configuration Map. - * @param mapReference the map reference to be used, not null. - */ - public void setMapReference(String mapReference){ - this.mapReference = Objects.requireNonNull(mapReference); - } - - /** - * Get the Hazelcast reference name for the Tamaya configuration Map. - * @return the Hazelcast reference name for the Tamaya configuration Map, never null. - */ - public String getMapReference(){ - return mapReference; - } - - /** - * Get access to the hazelcast instance used. - * @return the hazelcast instance, not null. - */ - public HazelcastInstance getHazelcastInstance() { - return hazelcastInstance; - } - - @Override - public PropertyValue get(String key) { - Config hcConfig = hazelcastInstance.getConfig(); - String value = hcConfig.getProperty(key); - if(value==null){ - return null; - } - return PropertyValue.builder(key, value, getName()) - .addMetaEntry("backend", "Hazelcast") - .addMetaEntry("instance", hcConfig.getInstanceName()) - .addMetaEntry("mapReference", mapReference) - .build(); - } - - @Override - public Map<String, PropertyValue> getProperties() { - Map<String,String> meta = new HashMap<>(); - meta.put("backend", "Hazelcast"); - meta.put("instance", hazelcastInstance.getConfig().getInstanceName()); - meta.put("mapReference", mapReference); - return PropertyValue.map(this.configMap, getName(), meta); - } - - @Override - public boolean isScannable() { - return true; - } - - /** - * Reloads the configuration map from Hazelcast completely. - */ - public void refresh() { - IMap<String,String> config = hazelcastInstance.getMap(mapReference); - Map<String, String> configMap = new HashMap<>(config); - this.configMap = configMap; - } - - @Override - public void applyChange(ConfigChangeRequest configChange) { - if(readOnly){ - return; - } - IMap<String,String> config = hazelcastInstance.getMap(mapReference); - for(Map.Entry<String, String> en: configChange.getAddedProperties().entrySet()){ - String metaVal = configChange.getAddedProperties().get("_" + en.getKey()+".ttl"); - if(metaVal!=null){ - try { - long ms = Long.parseLong(metaVal); - config.put(en.getKey(), en.getValue(), ms, TimeUnit.MILLISECONDS); - }catch(Exception e){ - LOG.log(Level.WARNING, "Failed to parse TTL in millis: " + metaVal + - " for '"+ en.getKey()+"'", e); - config.put(en.getKey(), en.getValue()); - } - }else { - config.put(en.getKey(), en.getValue()); - } - } - for(String key: configChange.getRemovedProperties()){ - config.remove(key); - } - IList<String> taList = hazelcastInstance.getList("_tamaya.transactions"); - taList.add(configChange.getTransactionID()); - config.put("_tamaya.transaction.lastId", configChange.getTransactionID(), 1, TimeUnit.DAYS); - config.put("_tamaya.transaction.startedAt", String.valueOf(configChange.getStartedAt()), 1, TimeUnit.DAYS); - config.flush(); - refresh(); - } - - @Override - protected String toStringValues() { - return super.toStringValues() + - "\n hazelcastInstance=" + hazelcastInstance + - "\n name='" + getName() + '\'' + - "\n mapReference='" + mapReference + '\'' + - "\n readOnly=" + readOnly + '\''; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/jodatime/pom.xml ---------------------------------------------------------------------- diff --git a/jodatime/pom.xml b/jodatime/pom.xml index 7ffbf23..c88f11c 100644 --- a/jodatime/pom.xml +++ b/jodatime/pom.xml @@ -47,12 +47,6 @@ under the License. <dependencies> <dependency> <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-core</artifactId> <version>${project.parent.version}</version> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/management/pom.xml ---------------------------------------------------------------------- diff --git a/management/pom.xml b/management/pom.xml index 81f64c9..e32b3c5 100644 --- a/management/pom.xml +++ b/management/pom.xml @@ -32,11 +32,6 @@ under the License. <dependencies> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>org.apache.tamaya.ext</groupId> <artifactId>tamaya-functions</artifactId> <version>${project.parent.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/metamodel/pom.xml ---------------------------------------------------------------------- diff --git a/metamodel/pom.xml b/metamodel/pom.xml index 860b383..9d75493 100644 --- a/metamodel/pom.xml +++ b/metamodel/pom.xml @@ -36,11 +36,6 @@ <dependencies> <dependency> <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-core</artifactId> <version>${project.parent.version}</version> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactory.java ---------------------------------------------------------------------- diff --git a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactory.java b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactory.java index 7b34ea4..6dc97ac 100644 --- a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactory.java +++ b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactory.java @@ -21,7 +21,7 @@ package org.apache.tamaya.metamodel.internal.factories; import org.apache.tamaya.format.ConfigurationData; import org.apache.tamaya.format.ConfigurationFormats; -import org.apache.tamaya.format.MappedConfigurationDataPropertySource; +import org.apache.tamaya.format.MappedConfigurationDataConfigSource; import org.apache.tamaya.metamodel.spi.ItemFactory; import org.apache.tamaya.resource.ConfigResources; import org.apache.tamaya.spi.PropertySource; @@ -66,7 +66,7 @@ public class ResourcePropertySourceProviderFactory implements ItemFactory<Proper data = ConfigurationFormats.readConfigurationData(resource, ConfigurationFormats.getFormats(formats)); } - propertySources.add(new MappedConfigurationDataPropertySource(data)); + propertySources.add(new MappedConfigurationDataConfigSource(data)); } catch (Exception e) { LOG.log(Level.SEVERE, "Failed to read property source from resource: " + location, e); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactory.java ---------------------------------------------------------------------- diff --git a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactory.java b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactory.java index 227b6ef..d09ae88 100644 --- a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactory.java +++ b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactory.java @@ -21,7 +21,7 @@ package org.apache.tamaya.metamodel.internal.factories; import org.apache.tamaya.format.ConfigurationData; import org.apache.tamaya.format.ConfigurationFormats; -import org.apache.tamaya.format.MappedConfigurationDataPropertySource; +import org.apache.tamaya.format.MappedConfigurationDataConfigSource; import org.apache.tamaya.functions.Supplier; import org.apache.tamaya.metamodel.internal.ComponentConfigurator; import org.apache.tamaya.metamodel.spi.ItemFactory; @@ -127,7 +127,7 @@ public class URLPropertySourceFactory implements ItemFactory<PropertySource>{ } } - private static final class RefreshablePropertySource extends MappedConfigurationDataPropertySource + private static final class RefreshablePropertySource extends MappedConfigurationDataConfigSource implements Refreshable{ public RefreshablePropertySource(String name, Supplier<ConfigurationData> dataSupplier) { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f7037fbd/propertysources/pom.xml ---------------------------------------------------------------------- diff --git a/propertysources/pom.xml b/propertysources/pom.xml index e9d64ac..ea23f00 100644 --- a/propertysources/pom.xml +++ b/propertysources/pom.xml @@ -39,11 +39,6 @@ under the License. <scope>provided</scope> </dependency> <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency>
