You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/05/21 09:40:24 UTC
[06/15] incubator-tamaya git commit: Moved PropertySourceBuilder from
resource module to builder module. Minor Javadoc change.
Moved PropertySourceBuilder from resource module to builder module.
Minor Javadoc change.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/391671af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/391671af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/391671af
Branch: refs/heads/master
Commit: 391671af5bb5d64ce179726d64671b83a18f0b51
Parents: 3013dbd
Author: anatole <an...@apache.org>
Authored: Thu May 21 06:28:44 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Thu May 21 06:28:44 2015 +0200
----------------------------------------------------------------------
.../tamaya/builder/ConfigurationBuilder.java | 2 +-
.../tamaya/builder/PropertySourceBuilder.java | 118 +++++++++++++
.../tamaya/builder/SimplePropertySource.java | 55 +++++++
modules/events/pom.xml | 5 +
.../tamaya/events/ObservedConfigTest.java | 164 -------------------
.../tamaya/events/TestObservingProvider.java | 40 +++++
.../events/delta/PropertySourceChangeTest.java | 26 +--
.../tamaya/resource/PropertySourceBuilder.java | 81 ---------
sandbox/remote/pom.xml | 5 +
9 files changed, 237 insertions(+), 259 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
index 799b114..82eb3eb 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
@@ -71,7 +71,7 @@ import static java.lang.String.format;
*
* <p><strong>Support for configuration formats</strong></p>
*
- * The configuration builder allows you to add property resources
+ * The configuration builder allows you to put property resources
* via a URL, as shown in the code example above, without implementing
* a {@link org.apache.tamaya.spi.PropertySource PropertySource} or providing an
* instance of a {@link org.apache.tamaya.spi.PropertySource PropertySource}.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java
new file mode 100644
index 0000000..e298939
--- /dev/null
+++ b/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java
@@ -0,0 +1,118 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Simple builder for building a {@link org.apache.tamaya.spi.PropertySource}.
+ */
+public final class PropertySourceBuilder {
+ /** The ordinal to be used. */
+ private int ordinal;
+ /** The name to be used. */
+ private String name;
+ /** The properties. */
+ private Map<String,String> properties = new HashMap<>();
+
+ /** private constructor. */
+ private PropertySourceBuilder(String name){
+ this.name = Objects.requireNonNull(name);
+ }
+
+ /**
+ * Gets a new instance of a builder.
+ * @param name The name of the property source, not null.
+ * @return a new instance.
+ */
+ public static PropertySourceBuilder of(String name){
+ return new PropertySourceBuilder(name);
+ }
+
+ /**
+ * Gets a new instance of a builder.
+ * @param name The name of the property source, not null.
+ * @return a new instance.
+ */
+ public static PropertySourceBuilder from(String name){
+ return new PropertySourceBuilder(name);
+ }
+
+ /**
+ * Sets a new property key/value.
+ * @param key the property key, not null.
+ * @param value the property value, not null.
+ * @return the bulder for chaining.
+ */
+ public PropertySourceBuilder put(String key, String value){
+ this.properties.put(key, value);
+ return this;
+ }
+
+ /**
+ * Put all the given key, values.
+ * @param values the new key/values, not null.
+ * @return the bulder for chaining.
+ */
+ public PropertySourceBuilder putAll(Map<String, String> values){
+ this.properties.putAll(values);
+ return this;
+ }
+
+ /**
+ * Sets the ordinal to be used explicitly (instead evaluating it using {@code tamaya.ordinal}.
+ * @param ordinal the explicit ordinal to be used.
+ * @return the bulder for chaining.
+ */
+ public PropertySourceBuilder withOrdinal(int ordinal){
+ this.ordinal = ordinal;
+ return this;
+ }
+
+ /**
+ * Puts all values from the given property source.
+ * @param propertySource the property source, not null.
+ * @return the bulder for chaining.
+ */
+ public PropertySourceBuilder putAll(PropertySource propertySource){
+ this.properties.putAll(propertySource.getProperties());
+ return this;
+ }
+
+ /**
+ * Creates a new immutable {@link org.apache.tamaya.spi.PropertySource} instance.
+ * @return a new immutable {@link org.apache.tamaya.spi.PropertySource} instance, never null.
+ */
+ public PropertySource build(){
+ return new SimplePropertySource(name, properties);
+ }
+
+ @Override
+ public String toString() {
+ return "PropertySourceBuilder{" +
+ "ordinal=" + ordinal +
+ ", name='" + name + '\'' +
+ ", properties=" + properties +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.java b/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.java
new file mode 100644
index 0000000..f343973
--- /dev/null
+++ b/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.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.builder;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+* Simple property source implementation using a map.
+*/
+public class SimplePropertySource implements PropertySource {
+ /** The properties. */
+ private Map<String, String> properties;
+ /** The source's name. */
+ private String name;
+
+ public SimplePropertySource(String name, Map<String, String> properties){
+ this.properties = new HashMap<>(properties);
+ this.name = Objects.requireNonNull(name);
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return this.properties;
+ }
+
+ @Override
+ public String toString(){
+ return "SimplePropertySource(name="+name+", numProps="+properties.size()+")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/events/pom.xml
----------------------------------------------------------------------
diff --git a/modules/events/pom.xml b/modules/events/pom.xml
index e23dd1d..0da9ec9 100644
--- a/modules/events/pom.xml
+++ b/modules/events/pom.xml
@@ -43,6 +43,11 @@ under the License.
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-builder</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.tamaya</groupId>
<artifactId>tamaya-core</artifactId>
<version>${project.version}</version>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java b/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
index bc3d087..d954ce0 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
@@ -21,19 +21,12 @@ package org.apache.tamaya.events;
import org.apache.commons.io.FileUtils;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.ConfigurationProvider;
-import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Map;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
@@ -42,68 +35,6 @@ import static org.junit.Assert.assertEquals;
*/
public class ObservedConfigTest {
- private static Path getSourceFile(String name) throws Exception {
- URL url = ObservedConfigTest.class.getResource("/data");
- File testFile = new File(new File(url.toURI()), name);
- return Paths.get(testFile.toURI());
- }
-
- private static Path getTargetFile(String name) {
- File testFile = new File(TestObservingProvider.getTestDirectory(), name);
- return Paths.get(testFile.toURI());
- }
-
- /**
- * Test method that periodically prints out what is happening.
- */
- public static void main() {
- while (true) {
- System.out.println("1: " + ConfigurationProvider.getConfiguration().get("1"));
- System.out.println("2: " + ConfigurationProvider.getConfiguration().get("2"));
- System.out.println("3: " + ConfigurationProvider.getConfiguration().get("3"));
- System.out.println("4: " + ConfigurationProvider.getConfiguration().get("4"));
- System.out.println("5: " + ConfigurationProvider.getConfiguration().get("5"));
- System.out.println("6: " + ConfigurationProvider.getConfiguration().get("6"));
- System.out.println("=======================================================================");
- try {
- Thread.sleep(2000L);
- } catch (Exception e) {
- // stop here...
- }
- }
- }
-
- @AfterClass
- public static void cleanup() throws Exception {
- // cleanup directory
- Files.deleteIfExists(getTargetFile("test1.properties"));
- Files.deleteIfExists(getTargetFile("test2.properties"));
- Files.deleteIfExists(getTargetFile("test3.properties"));
- }
-
- @Before
- public void setup() throws IOException {
- // create some temporary config
- Path tempDir = Files.createTempDirectory("observedFolder");
-
- TestObservingProvider.propertyLocation = tempDir;
-
- FileUtils.copyInputStreamToFile(
- getClass().getResourceAsStream("/test.properties"),
- new File(tempDir.toFile(), "test.properties"));
- }
-
- public void testInitialConfig() 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("a"));
-
- }
-
@Test
public void testChangingConfig() throws IOException {
Configuration config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
@@ -133,99 +64,4 @@ public class ObservedConfigTest {
assertEquals(props.get("testValue2"), "anotherValue");
}
- @Test
- //Y TODO Check tests later
- public void testConfigChanges() throws Exception {
-// // test empty directory
-// testEmpty();
-// // add a file, test for changes
-// Files.copy(getSourceFile("test1.properties"), getTargetFile("test1.properties"));
-// try {
-// Thread.sleep(2000L);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// testProperties1();
-// Files.copy(getSourceFile("test2.properties"), getTargetFile("test2.properties"));
-// Files.copy(getSourceFile("test3.properties"), getTargetFile("test3.properties"));
-// try {
-// Thread.sleep(2000L);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// testAllFiles();
-// // change a file, test for changes
-// Files.copy(getSourceFile("test1b.properties"), getTargetFile("test1.properties"));
-// try {
-// Thread.sleep(2000L);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// testProperties2();
-// // remove a file, test for changes
-// Files.delete(getTargetFile("test2.properties"));
-// try {
-// Thread.sleep(2000L);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// testProperties3();
-// // cleanup directory
-// Files.deleteIfExists(getTargetFile("test1.properties"));
-// Files.deleteIfExists(getTargetFile("test2.properties"));
-// Files.deleteIfExists(getTargetFile("test3.properties"));
-// try {
-// Thread.sleep(2000L);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// testEmpty();
- }
-
- private void testEmpty() {
- assertNull(ConfigurationProvider.getConfiguration().get("1"));
- assertNull(ConfigurationProvider.getConfiguration().get("2"));
- assertNull(ConfigurationProvider.getConfiguration().get("3"));
- assertNull(ConfigurationProvider.getConfiguration().get("4"));
- assertNull(ConfigurationProvider.getConfiguration().get("5"));
- assertNull(ConfigurationProvider.getConfiguration().get("6"));
- }
-
- private void testAllFiles() {
- assertNotNull(ConfigurationProvider.getConfiguration().get("1"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("2"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("3"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("4"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("5"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("6"));
- }
-
- private void testProperties1() {
- assertNotNull(ConfigurationProvider.getConfiguration().get("1"));
- assertNull(ConfigurationProvider.getConfiguration().get("2"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("3"));
- assertNull(ConfigurationProvider.getConfiguration().get("4"));
- assertNull(ConfigurationProvider.getConfiguration().get("5"));
- assertNull(ConfigurationProvider.getConfiguration().get("6"));
- }
-
- private void testProperties2() {
- assertNotNull(ConfigurationProvider.getConfiguration().get("1"));
- assertNull(ConfigurationProvider.getConfiguration().get("2"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("3"));
- assertNull(ConfigurationProvider.getConfiguration().get("4"));
- assertNull(ConfigurationProvider.getConfiguration().get("5"));
- assertNull(ConfigurationProvider.getConfiguration().get("6"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("7"));
- }
-
- private void testProperties3() {
- assertNotNull(ConfigurationProvider.getConfiguration().get("1"));
- assertNull(ConfigurationProvider.getConfiguration().get("2"));
- assertNotNull(ConfigurationProvider.getConfiguration().get("3"));
- assertNull(ConfigurationProvider.getConfiguration().get("4"));
- assertNull(ConfigurationProvider.getConfiguration().get("5"));
- assertNull(ConfigurationProvider.getConfiguration().get("6"));
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java b/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
index 775de58..160c117 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.events;
+import org.apache.commons.io.FileUtils;
import org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider;
import org.apache.tamaya.format.formats.PropertiesFormat;
@@ -26,6 +27,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.file.FileSystem;
+import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -33,6 +35,7 @@ import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.util.Iterator;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -42,6 +45,43 @@ 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,
new PropertiesFormat());
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java b/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
index b3b6145..770bd5d 100644
--- a/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
+++ b/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.tamaya.events.delta;
+import org.apache.tamaya.builder.PropertySourceBuilder;
import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.resource.PropertySourceBuilder;
import org.apache.tamaya.spi.PropertySource;
import org.junit.Test;
@@ -99,10 +99,10 @@ public class PropertySourceChangeTest {
@Test
public void testIsRemoved() throws Exception {
- PropertySource ps1 = PropertySourceBuilder.of("test").add("key1", "value1")
- .add("key2", "value2").build();
- PropertySource ps2 = PropertySourceBuilder.of("test").add("key1", "value2")
- .add("key3", "value3").build();
+ PropertySource ps1 = PropertySourceBuilder.of("test").put("key1", "value1")
+ .put("key2", "value2").build();
+ PropertySource ps2 = PropertySourceBuilder.of("test").put("key1", "value2")
+ .put("key3", "value3").build();
PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
.addChanges(
ps2
@@ -114,10 +114,10 @@ public class PropertySourceChangeTest {
@Test
public void testIsAdded() throws Exception {
- PropertySource ps1 = PropertySourceBuilder.of("test").add("key1", "value1")
- .add("key2", "value2").build();
- PropertySource ps2 = PropertySourceBuilder.of("test").add("key1", "value2")
- .add("key3", "value3").build();
+ PropertySource ps1 = PropertySourceBuilder.of("test").put("key1", "value1")
+ .put("key2", "value2").build();
+ PropertySource ps2 = PropertySourceBuilder.of("test").put("key1", "value2")
+ .put("key3", "value3").build();
PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
.addChanges(
ps2
@@ -129,10 +129,10 @@ public class PropertySourceChangeTest {
@Test
public void testIsUpdated() throws Exception {
- PropertySource ps1 = PropertySourceBuilder.of("test").add("key1", "value1")
- .add("key2", "value2").build();
- PropertySource ps2 = PropertySourceBuilder.of("test").add("key1", "value2")
- .add("key3", "value3").build();
+ PropertySource ps1 = PropertySourceBuilder.of("test").put("key1", "value1")
+ .put("key2", "value2").build();
+ PropertySource ps2 = PropertySourceBuilder.of("test").put("key1", "value2")
+ .put("key3", "value3").build();
PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
.addChanges(
ps2
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/modules/resources/src/main/java/org/apache/tamaya/resource/PropertySourceBuilder.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/PropertySourceBuilder.java b/modules/resources/src/main/java/org/apache/tamaya/resource/PropertySourceBuilder.java
deleted file mode 100644
index 5a387ee..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/PropertySourceBuilder.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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.resource;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Simple builder for building a {@link org.apache.tamaya.spi.PropertySource}.
- */
-public final class PropertySourceBuilder {
- private int ordinal;
- private String name;
- private Map<String,String> properties = new HashMap<>();
-
- /** private constructor. */
- private PropertySourceBuilder(String name){
- this.name = Objects.requireNonNull(name);
- }
-
- /**
- * Gets a new instance of a builder.
- * @param name The name of the property source, not null.
- * @return a new instance.
- */
- public static PropertySourceBuilder of(String name){
- return new PropertySourceBuilder(name);
- }
-
- /**
- * Gets a new instance of a builder.
- * @param name The name of the property source, not null.
- * @return a new instance.
- */
- public static PropertySourceBuilder from(String name){
- return new PropertySourceBuilder(name);
- }
-
- public PropertySourceBuilder add(String key, String value){
- this.properties.put(key, value);
- return this;
- }
-
- public PropertySourceBuilder addAll(Map<String,String> values){
- this.properties.putAll(values);
- return this;
- }
-
- public PropertySourceBuilder withOrdinal(int ordinal){
- this.ordinal = ordinal;
- return this;
- }
-
- public PropertySourceBuilder addValues(PropertySource propertySource){
- this.properties.putAll(propertySource.getProperties());
- return this;
- }
-
- public PropertySource build(){
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/391671af/sandbox/remote/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/remote/pom.xml b/sandbox/remote/pom.xml
index f4b7100..26c1bbd 100644
--- a/sandbox/remote/pom.xml
+++ b/sandbox/remote/pom.xml
@@ -51,5 +51,10 @@ under the License.
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <!-- dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency -->
</dependencies>
</project>