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 2014/12/06 02:03:26 UTC
[4/9] incubator-tamaya git commit: TAMAYA-19: Code cleanup.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/internal/resources/io/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/InputStreamSource.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/InputStreamSource.java
deleted file mode 100644
index c84199a..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/InputStreamSource.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2002-2012 the original author or authors.
- *
- * Licensed 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.core.internal.resources.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Simple interface for objects that are sources for an {@link InputStream}.
- *
- * <p>This is the base interface for Spring's more extensive {@link Resource} interface.
- *
- * <p>For single-use streams, {@link InputStreamResource} can be used for any
- * given {@code InputStream}. Spring's {@code ByteArrayResource} or any
- * file-based {@code Resource} implementation can be used as a concrete
- * instance, allowing one to read the underlying content stream multiple times.
- * This makes this interface useful as an abstract content source for mail
- * attachments, for example.
- *
- * @author Juergen Hoeller
- * @since 20.01.2004
- * @see java.io.InputStream
- * @see Resource
- * @see InputStreamResource
- */
-@FunctionalInterface
-public interface InputStreamSource {
-
- /**
- * Return an {@link InputStream}.
- * <p>It is expected that each call creates a <i>fresh</i> stream.
- * <p>This requirement is particularly important when you consider an API such
- * as JavaMail, which needs to be able to read the stream multiple times when
- * creating mail attachments. For such a use case, it is <i>required</i>
- * that each {@code getInputStream()} call returns a fresh stream.
- * @return the input stream for the underlying resource (must not be {@code null})
- * @throws IOException if the stream could not be opened
- */
- InputStream getInputStream() throws IOException;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
index 6c1b1ce..a72fe21 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java
@@ -15,6 +15,8 @@
*/
package org.apache.tamaya.core.internal.resources.io;
+import org.apache.tamaya.core.resource.Resource;
+
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/internal/resources/io/Resource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/Resource.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/Resource.java
deleted file mode 100644
index 909ef03..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/Resource.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2002-2012 the original author or authors.
- *
- * Licensed 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.core.internal.resources.io;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.function.Supplier;
-
-/**
- * Interface for a resource descriptor that abstracts from the actual
- * type current underlying resource, such as a file or class path resource.
- *
- * <p>An InputStream can be opened for every resource if it exists in
- * physical form, but a URL or File handle can just be returned for
- * certain resources. The actual behavior is implementation-specific.
- *
- * @author Juergen Hoeller
- * @since 28.12.2003
- * @see #getInputStream()
- * @see #getURL()
- * @see #getURI()
- * @see #getFile()
- * @see FileSystemResource
- * @see ClassPathResource
- * @see UrlResource
- * @see ByteArrayResource
- * @see InputStreamResource
- * @see PathResource
- */
-public interface Resource extends InputStreamSource {
-
- /**
- * Return whether this resource actually exists in physical form.
- * <p>This method performs a definitive existence check, whereas the
- * existence current a {@code Resource} handle only guarantees a
- * valid descriptor handle.
- */
- boolean exists();
-
- /**
- * Return whether the contents current this resource can be read,
- * e.g. via {@link #getInputStream()} or {@link #getFile()}.
- * <p>Will be {@code true} for typical resource descriptors;
- * note that actual content reading may still fail when attempted.
- * However, a value current {@code false} is a definitive indication
- * that the resource content cannot be read.
- * @see #getInputStream
- */
- boolean isReadable();
-
- /**
- * Return whether this resource represents a handle with an open
- * stream. If true, the InputStream cannot be read multiple times,
- * and must be read and closed to avoid resource leaks.
- * <p>Will be {@code false} for typical resource descriptors.
- */
- boolean isOpen();
-
- /**
- * Return a URL handle for this resource.
- * @throws IOException if the resource cannot be resolved as URL,
- * i.e. if the resource is not available as descriptor
- */
- URL getURL() throws IOException;
-
- /**
- * Return a URI handle for this resource.
- * @throws IOException if the resource cannot be resolved as URI,
- * i.e. if the resource is not available as descriptor
- */
- URI getURI() throws IOException;
-
- /**
- * Return a File handle for this resource.
- * @throws IOException if the resource cannot be resolved as absolute
- * file path, i.e. if the resource is not available in a file system
- */
- File getFile() throws IOException;
-
- /**
- * Determine the content length for this resource.
- * @throws IOException if the resource cannot be resolved
- * (in the file system or as some other known physical resource type)
- */
- long contentLength() throws IOException;
-
- /**
- * Determine the last-modified timestamp for this resource.
- * @throws IOException if the resource cannot be resolved
- * (in the file system or as some other known physical resource type)
- */
- long lastModified() throws IOException;
-
- /**
- * Create a resource relative to this resource.
- * @param relativePath the relative path (relative to this resource)
- * @return the resource handle for the relative resource
- * @throws IOException if the relative resource cannot be determined
- */
- Resource createRelative(String relativePath) throws IOException;
-
- /**
- * Determine a filename for this resource, i.e. typically the last
- * part current the path: for example, "myfile.txt".
- * <p>Returns {@code null} if this type current resource does not
- * have a filename.
- */
- String getFilename();
-
- /**
- * Return a description for this resource,
- * to be used for error output when working with the resource.
- * <p>Implementations are also encouraged to return this value
- * from their {@code toString} method.
- * @see Object#toString()
- */
- String getDescription();
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/internal/resources/io/UrlResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/UrlResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/UrlResource.java
index 2faba1c..fc45973 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/UrlResource.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/UrlResource.java
@@ -15,6 +15,8 @@
*/
package org.apache.tamaya.core.internal.resources.io;
+import org.apache.tamaya.core.resource.Resource;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -27,7 +29,7 @@ import java.net.URLConnection;
import java.util.Objects;
/**
- * {@link org.apache.tamaya.core.internal.resources.io.Resource} implementation for {@code java.net.URL} locators.
+ * {@link org.apache.tamaya.core.resource.Resource} implementation for {@code java.net.URL} locators.
* Obviously supports resolution as URL, and also as File in case current
* the "file:" protocol.
*
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/internal/resources/io/VfsResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/VfsResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/VfsResource.java
index 941eb8b..4cef164 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/VfsResource.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/VfsResource.java
@@ -15,6 +15,8 @@
*/
package org.apache.tamaya.core.internal.resources.io;
+import org.apache.tamaya.core.resource.Resource;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -23,7 +25,7 @@ import java.net.URL;
import java.util.Objects;
/**
- * JBoss VFS based {@link Resource} implementation.
+ * JBoss VFS based {@link org.apache.tamaya.core.resource.Resource} implementation.
*
* <p>As current Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
* {@code org.jboss.vfs}) and is in particular compatible with JBoss AS 7 and
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/internal/resources/io/WritableResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/WritableResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/WritableResource.java
index 5ac55c0..cecff40 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/WritableResource.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/WritableResource.java
@@ -16,6 +16,8 @@
package org.apache.tamaya.core.internal.resources.io;
+import org.apache.tamaya.core.resource.Resource;
+
import java.io.IOException;
import java.io.OutputStream;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/properties/AbstractPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/AbstractPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/AbstractPropertyProvider.java
index a500217..cce9841 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/AbstractPropertyProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/AbstractPropertyProvider.java
@@ -26,8 +26,7 @@ import java.io.Serializable;
import java.util.*;
/**
- * Abstract base class for implementing a {@link org.apache.tamaya.PropertyProvider}. Also
- * consider using {@link org.apache.tamaya.core.internal.MapBasedPropertyProvider} instead current.
+ * Abstract base class for implementing a {@link org.apache.tamaya.PropertyProvider}.
*/
@SuppressWarnings("NullableProblems")
public abstract class AbstractPropertyProvider implements PropertyProvider, Serializable{
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/properties/AbstractResourceConfigMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/AbstractResourceConfigMap.java b/core/src/main/java/org/apache/tamaya/core/properties/AbstractResourceConfigMap.java
index f12c15b..0d34c6a 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/AbstractResourceConfigMap.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/AbstractResourceConfigMap.java
@@ -18,13 +18,13 @@
*/
package org.apache.tamaya.core.properties;
+import org.apache.tamaya.core.resource.Resource;
import org.apache.tamaya.spi.Bootstrap;
-import org.apache.tamaya.core.spi.ResourceLoader;
+import org.apache.tamaya.core.resource.ResourceLoader;
import org.apache.tamaya.MetaInfo;
import org.apache.tamaya.MetaInfoBuilder;
-import java.net.URI;
import java.util.*;
public abstract class AbstractResourceConfigMap extends AbstractPropertyProvider{
@@ -52,9 +52,9 @@ public abstract class AbstractResourceConfigMap extends AbstractPropertyProvider
.build());
Objects.requireNonNull(sources, "sources required.");
Objects.requireNonNull(sourceExpression, "sourceExpression required.");
- List<URI> urls = Bootstrap.getService(ResourceLoader.class).getResources(classLoader, sourceExpression);
- for(URI url : urls){
- addSource(url.toString());
+ List<Resource> resources = Bootstrap.getService(ResourceLoader.class).getResources(classLoader, sourceExpression);
+ for(Resource res : resources){
+ addSource(res.toString());
}
this.classLoader = classLoader;
this.parentConfig = parentConfig;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
index 1d737ea..2503b35 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/ClasspathModulePropertyProvider.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.core.properties;
-import org.apache.tamaya.core.spi.ResourceLoader;
+import org.apache.tamaya.core.resource.ResourceLoader;
import org.apache.tamaya.MetaInfoBuilder;
import org.apache.tamaya.spi.Bootstrap;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/properties/ClasspathPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ClasspathPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/ClasspathPropertyProvider.java
deleted file mode 100644
index 58f71f7..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/ClasspathPropertyProvider.java
+++ /dev/null
@@ -1,147 +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.core.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import java.util.*;
-
-public class ClasspathPropertyProvider extends AbstractPropertyProvider{
-
- private static final long serialVersionUID = -2193109047946712701L;
- private Map<ClassLoader,ClasspathModulePropertyProvider> configs = new HashMap<>();
- private String[] resources;
-
- public ClasspathPropertyProvider(MetaInfo metaInfo, String... resources) {
- super(metaInfo);
- Objects.requireNonNull(resources);
- this.resources = resources;
- }
-
-
- @Override
- public Map<String,String> toMap(){
- return new Map<String,String>(){
-
- @Override
- public int size(){
- return getLoaderDependentDelegate().size();
- }
-
- @Override
- public boolean isEmpty(){
- return getLoaderDependentDelegate().isEmpty();
- }
-
- @Override
- public boolean containsKey(Object key){
- return getLoaderDependentDelegate().containsKey(key);
- }
-
- @Override
- public boolean containsValue(Object value){
- return getLoaderDependentDelegate().containsValue(value);
- }
-
- @Override
- public String get(Object key){
- return getLoaderDependentDelegate().get(key);
- }
-
- @Override
- public String put(String key, String value){
- return getLoaderDependentDelegate().put(key,value);
- }
-
- @Override
- public String remove(Object key){
- return getLoaderDependentDelegate().remove(key);
- }
-
- @Override
- public void putAll(Map<? extends String,? extends String> m){
- getLoaderDependentDelegate().putAll(m);
- }
-
- @Override
- public void clear(){
- getLoaderDependentDelegate().clear();
- }
-
- @Override
- public Set<String> keySet(){
- return getLoaderDependentDelegate().keySet();
- }
-
- @Override
- public Collection<String> values(){
- return getLoaderDependentDelegate().values();
- }
-
- @Override
- public Set<Entry<String,String>> entrySet(){
- return getLoaderDependentDelegate().entrySet();
- }
-
- };
- }
-
- private Map<String, String> getLoaderDependentDelegate() {
- Map<String, String> props = new HashMap<>();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = getClass().getClassLoader();
- }
- while (cl != null) {
- ClasspathModulePropertyProvider cfg = this.configs.get(cl);
- if (cfg == null) {
- cfg = new ClasspathModulePropertyProvider(cl, this.resources);
- this.configs.put(cl, cfg);
- }
- props.putAll(cfg.toMap());
- cl = cl.getParent();
- }
- return props;
- }
-
- @Override
- public ConfigChangeSet load() {
- Map<String, String> props = new HashMap<>();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = getClass().getClassLoader();
- }
- while (cl != null) {
- ClasspathModulePropertyProvider cfg = this.configs.get(cl);
- if (cfg != null) {
- cfg.load();
- }
- cl = cl.getParent();
- }
- return super.load();
- }
-
- @Override
- public String toString(){
- return "ClasspathPropertyProvider{" +
- "configs=" + configs +
- ", resources=" + Arrays.toString(resources) +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java b/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
deleted file mode 100644
index 11820ed..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
+++ /dev/null
@@ -1,125 +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.core.properties;
-
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-import org.apache.tamaya.PropertyProviders;
-
-import java.util.*;
-
-/**
- * Builder class for creating a new instance current
- * {@link org.apache.tamaya.core.internal.MapBasedPropertyProvider}-
- */
-public final class MapBasedPropertyProviderBuilder {
- protected MetaInfoBuilder metaInfoBuilder = MetaInfoBuilder.of();
- protected Map<String,String> entries = new HashMap<>();
- protected long configReadDT = System.currentTimeMillis();
-
- private MapBasedPropertyProviderBuilder(){
- }
-
- private MapBasedPropertyProviderBuilder(String name){
- Objects.requireNonNull(name);
- this.metaInfoBuilder.setName(name);
- }
-
- public static final MapBasedPropertyProviderBuilder of(){
- return new MapBasedPropertyProviderBuilder();
- }
-
- public static final MapBasedPropertyProviderBuilder of(String name){
- return new MapBasedPropertyProviderBuilder(name);
- }
-
- public MapBasedPropertyProviderBuilder setMetaInfo(String metaInfo){
- Objects.requireNonNull(metaInfo);
- this.metaInfoBuilder.setMetaInfo(metaInfo);
- return this;
- }
-
- public MapBasedPropertyProviderBuilder setMetaInfo(MetaInfo metaInfo){
- Objects.requireNonNull(metaInfo, "metaInfo required.");
- this.metaInfoBuilder.setMetaInfo(metaInfo);
- return this;
- }
-
- public MapBasedPropertyProviderBuilder addEntry(String key, String value){
- return addEntry(key, value, null);
- }
-
- public MapBasedPropertyProviderBuilder addEntry(String key, String value, String metaInfo){
- Objects.requireNonNull(key, "key required.");
- Objects.requireNonNull(value, "value required.");
- this.entries.put(key, value);
- if(metaInfo != null){
- this.metaInfoBuilder.setMetaInfo(key, metaInfo);
- }
- return this;
- }
-
- public MapBasedPropertyProviderBuilder addEntries(Map<String,String> data, String metaInfo){
- for(Map.Entry<String,String> en : data.entrySet()){
- this.entries.put(en.getKey(), en.getValue());
- if(metaInfo != null){
- this.metaInfoBuilder.setMetaInfo(en.getKey(), metaInfo);
- }
- }
- return this;
- }
-
- public MapBasedPropertyProviderBuilder addEntries(Map<String,String> data){
- Objects.requireNonNull(data, "data required.");
- addEntries(data, null);
- return this;
- }
-
- public MapBasedPropertyProviderBuilder addEntries(Properties data){
- return addEntries(data, null);
- }
-
- public MapBasedPropertyProviderBuilder addEntries(Properties data, String metaInfo){
- Objects.requireNonNull(data, "data required.");
- for(Map.Entry<Object,Object> en : data.entrySet()){
- this.entries.put(en.getKey().toString(), en.getValue().toString());
- if(metaInfo != null){
- this.metaInfoBuilder.setMetaInfo(en.getKey().toString(), metaInfo);
- }
- }
- return this;
- }
-
- public PropertyProvider build(){
- MetaInfo metaInfo = metaInfoBuilder.setTimestamp(configReadDT).build();
- return PropertyProviders.fromMap(metaInfo, entries);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString(){
- return "DefaultConfigurationUnit.Builder [configReadDT=" + configReadDT + ", entries=" + entries + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/resource/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resource/InputStreamSource.java b/core/src/main/java/org/apache/tamaya/core/resource/InputStreamSource.java
new file mode 100644
index 0000000..102337d
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/resource/InputStreamSource.java
@@ -0,0 +1,55 @@
+/*
+* Copyright 2002-2012 the original author or authors.
+*
+* Licensed 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.core.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+* Simple interface for objects that are sources for an {@link InputStream}.
+*
+* <p>This is the base interface for Spring's more extensive {@link Resource} interface.
+*
+* <p>For single-use streams, {@link org.apache.tamaya.core.internal.resources.io.InputStreamResource} can be used for any
+* given {@code InputStream}. Spring's {@code ByteArrayResource} or any
+* file-based {@code Resource} implementation can be used as a concrete
+* instance, allowing one to read the underlying content stream multiple times.
+* This makes this interface useful as an abstract content source for mail
+* attachments, for example.
+*
+* @author Juergen Hoeller
+* @since 20.01.2004
+* @see java.io.InputStream
+* @see Resource
+* @see org.apache.tamaya.core.internal.resources.io.InputStreamResource
+*/
+@FunctionalInterface
+public interface InputStreamSource {
+
+ /**
+ * Return an {@link InputStream}.
+ * <p>It is expected that each call creates a <i>fresh</i> stream.
+ * <p>This requirement is particularly important when you consider an API such
+ * as JavaMail, which needs to be able to read the stream multiple times when
+ * creating mail attachments. For such a use case, it is <i>required</i>
+ * that each {@code getInputStreamSupplier()} call returns a fresh stream.
+ * @return the input stream for the underlying resource (must not be {@code null})
+ * @throws IOException if the stream could not be opened
+ */
+ InputStream getInputStream() throws IOException;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/resource/Resource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resource/Resource.java b/core/src/main/java/org/apache/tamaya/core/resource/Resource.java
new file mode 100644
index 0000000..511be7e
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/resource/Resource.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed 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.core.resource;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.function.Supplier;
+
+/**
+ * Interface for a resource descriptor that abstracts from the actual
+ * type current underlying resource, such as a file or class path resource.
+ *
+ * <p>An InputStream can be opened for every resource if it exists in
+ * physical form, but a URL or File handle can just be returned for
+ * certain resources. The actual behavior is implementation-specific.
+ *
+ * @author Juergen Hoeller
+ * @since 28.12.2003
+ * @see #getInputStream()
+ * @see #getURL()
+ * @see #getURI()
+ * @see #getFile()
+ */
+public interface Resource extends InputStreamSource {
+
+ /**
+ * Return whether this resource actually exists in physical form.
+ * <p>This method performs a definitive existence check, whereas the
+ * existence current a {@code Resource} handle only guarantees a
+ * valid descriptor handle.
+ */
+ boolean exists();
+
+ /**
+ * Return whether the contents current this resource can be read,
+ * e.g. via {@link #getInputStream()} or {@link #getFile()}.
+ * <p>Will be {@code true} for typical resource descriptors;
+ * note that actual content reading may still fail when attempted.
+ * However, a value current {@code false} is a definitive indication
+ * that the resource content cannot be read.
+ * @see #getInputStream()
+ */
+ boolean isReadable();
+
+ /**
+ * Return whether this resource represents a handle with an open
+ * stream. If true, the InputStream cannot be read multiple times,
+ * and must be read and closed to avoid resource leaks.
+ * <p>Will be {@code false} for typical resource descriptors.
+ */
+ boolean isOpen();
+
+ /**
+ * Return a URL handle for this resource.
+ * @throws IOException if the resource cannot be resolved as URL,
+ * i.e. if the resource is not available as descriptor
+ */
+ URL getURL() throws IOException;
+
+ /**
+ * Return a URI handle for this resource.
+ * @throws IOException if the resource cannot be resolved as URI,
+ * i.e. if the resource is not available as descriptor
+ */
+ URI getURI() throws IOException;
+
+ /**
+ * Return a File handle for this resource.
+ * @throws IOException if the resource cannot be resolved as absolute
+ * file path, i.e. if the resource is not available in a file system
+ */
+ File getFile() throws IOException;
+
+ /**
+ * Determine the content length for this resource.
+ * @throws IOException if the resource cannot be resolved
+ * (in the file system or as some other known physical resource type)
+ */
+ long contentLength() throws IOException;
+
+ /**
+ * Determine the last-modified timestamp for this resource.
+ * @throws IOException if the resource cannot be resolved
+ * (in the file system or as some other known physical resource type)
+ */
+ long lastModified() throws IOException;
+
+ /**
+ * Create a resource relative to this resource.
+ * @param relativePath the relative path (relative to this resource)
+ * @return the resource handle for the relative resource
+ * @throws IOException if the relative resource cannot be determined
+ */
+ Resource createRelative(String relativePath) throws IOException;
+
+ /**
+ * Determine a filename for this resource, i.e. typically the last
+ * part current the path: for example, "myfile.txt".
+ * <p>Returns {@code null} if this type current resource does not
+ * have a filename.
+ */
+ String getFilename();
+
+ /**
+ * Get a description of the resource.
+ * @return the description.
+ */
+ String getDescription();
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/resource/ResourceLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resource/ResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/resource/ResourceLoader.java
new file mode 100644
index 0000000..f4f86e9
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/resource/ResourceLoader.java
@@ -0,0 +1,84 @@
+/*
+ * 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.core.resource;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Interface to be implemented by containers that decouples loading current classpath resources fromMap the effective
+ * classloader architecture current a runtime environment. Implementations current this class encapsulate the mechanism current
+ * determining the
+ * concrete resources available base on an expression defining the configuration
+ * locations. A an example the expression {@code cfg/global/*.xml} defines a
+ * location for reading global configuration in the classpath. A resources
+ * interprets this expression and evaluates the concrete resources to be read,
+ * e.g. {@code cfg/global/default.xml, cfg/global/myApp.xml}.
+ * Created by Anatole on 16.06.2014.
+ */
+public interface ResourceLoader{
+
+ /**
+ * Get the prefixes supportedby this loader.
+ *
+ * @return the supported prefixes, not empty.
+ */
+ Collection<String> getResolverIds();
+
+ /**
+ * Called, when a given expression has to be resolved.
+ *
+ * @param expressions the expressions to be resolved, not empty.
+ * @return the corresponding collection current {@link java.net.URI}s defining the
+ * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
+ * .
+ */
+ List<Resource> getResources(String... expressions);
+
+ /**
+ * Called, when a given expression has to be resolved.
+ *
+ * @param expressions the expressions to be resolved, not empty.
+ * @return the corresponding collection current {@link java.net.URI}s defining the
+ * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
+ * .
+ */
+ List<Resource> getResources(Collection<String> expressions);
+
+ /**
+ * Called, when a given expression has to be resolved.
+ *
+ * @param expressions the expressions to be resolved, not empty.
+ * @return the corresponding collection current {@link java.net.URI}s defining the
+ * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
+ * .
+ */
+ List<Resource> getResources(ClassLoader classLoader, String... expressions);
+
+ /**
+ * Called, when a given expression has to be resolved.
+ *
+ * @param expressions the expressions to be resolved, not empty.
+ * @return the corresponding collection current {@link java.net.URI}s defining the
+ * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
+ * .
+ */
+ List<Resource> getResources(ClassLoader classLoader, Collection<String> expressions);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
index 15b21b2..ce58643 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
@@ -18,7 +18,8 @@
*/
package org.apache.tamaya.core.spi;
-import java.net.URI;
+import org.apache.tamaya.core.resource.Resource;
+
import java.util.Map;
/**
@@ -43,7 +44,7 @@ public interface ConfigurationFormat{
* @return {@code true} if the given resource is in a format supported by
* this instance.
*/
- boolean isAccepted(URI resource);
+ boolean isAccepted(Resource resource);
/**
* Reads a {@link org.apache.tamaya.PropertyProvider} fromMap the given URI, using this format.
@@ -51,6 +52,6 @@ public interface ConfigurationFormat{
* @param resource the configuration location, not null
* @return the corresponding {@link java.util.Map}, never {@code null}.
*/
- Map<String,String> readConfiguration(URI resource);
+ Map<String,String> readConfiguration(Resource resource);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatsSingletonSpi.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatsSingletonSpi.java b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatsSingletonSpi.java
index f841a06..260f945 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatsSingletonSpi.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatsSingletonSpi.java
@@ -18,7 +18,8 @@
*/
package org.apache.tamaya.core.spi;
-import java.net.URI;
+import org.apache.tamaya.core.resource.Resource;
+
import java.util.Collection;
/**
@@ -47,7 +48,7 @@ public interface ConfigurationFormatsSingletonSpi{
* @param resource The resource
* @return a matching configuration format, or {@code null} if no matching format could be determined.
*/
- ConfigurationFormat getFormat(URI resource);
+ ConfigurationFormat getFormat(Resource resource);
default ConfigurationFormat getPropertiesFormat(){
return getFormat("properties");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java b/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
index 0d2566a..b40cbb6 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
@@ -24,7 +24,7 @@ import java.util.Set;
/**
* SPI for components that define a concrete type current {@link org.apache.tamaya.Environment}.
- * The chain current environment providers determine the current {@link Environment} active
+ * The chain current environment config determine the current {@link Environment} active
* and its parent instances.
* Created by Anatole on 14.10.2014.
*/
@@ -52,7 +52,7 @@ public interface EnvironmentProvider {
/**
* Get all currently known environment contexts for this environment type.
* @return all currently known environment contexts, never null. Environment
- * providers may prevent abritrary access to environment fromMap outside current the
+ * config may prevent abritrary access to environment fromMap outside current the
* regarding runtime context by just not including the context information
* in this call's result.
* @return all currently known environment contexts, never null.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/spi/PathResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/PathResolver.java b/core/src/main/java/org/apache/tamaya/core/spi/PathResolver.java
new file mode 100644
index 0000000..04b5b02
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/spi/PathResolver.java
@@ -0,0 +1,45 @@
+/*
+ * 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.core.spi;
+
+import org.apache.tamaya.core.resource.Resource;
+
+import java.util.Collection;
+
+/**
+ * Created by Anatole on 16.06.2014.
+ */
+public interface PathResolver{
+
+ /**
+ * Get the (unique) resolver prefix.
+ *
+ * @return the resolver prefix, never null.
+ */
+ public String getResolverId();
+
+ /**
+ * Resolve the given expression.
+ *
+ * @param expressions expressions, never null.
+ * @return the resolved URIs, never null.
+ */
+ public Collection<Resource> resolve(ClassLoader classLoader, Collection<String> expressions);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
deleted file mode 100644
index 92b7ce2..0000000
--- a/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
+++ /dev/null
@@ -1,86 +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.core.spi;
-
-import java.net.URI;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Stream;
-
-/**
- * Interface to be implemented by containers that decouples loading current classpath resources fromMap the effective
- * classloader architecture current a runtime environment. Implementations current this class encapsulate the mechanism current
- * determining the
- * concrete resources available base on an expression defining the configuration
- * locations. A an example the expression {@code cfg/global/*.xml} defines a
- * location for reading global configuration in the classpath. A resources
- * interprets this expression and evaluates the concrete resources to be read,
- * e.g. {@code cfg/global/default.xml, cfg/global/myApp.xml}.
- * Created by Anatole on 16.06.2014.
- */
-public interface ResourceLoader{
-
- /**
- * Get the prefixes supportedby this loader.
- *
- * @return the supported prefixes, not empty.
- */
- Collection<String> getResolverIds();
-
- /**
- * Called, when a given expression has to be resolved.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection current {@link java.net.URI}s defining the
- * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
- * .
- */
- List<URI> getResources(String... expressions);
-
- /**
- * Called, when a given expression has to be resolved.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection current {@link java.net.URI}s defining the
- * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
- * .
- */
- List<URI> getResources(Collection<String> expressions);
-
- /**
- * Called, when a given expression has to be resolved.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection current {@link java.net.URI}s defining the
- * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
- * .
- */
- List<URI> getResources(ClassLoader classLoader, String... expressions);
-
- /**
- * Called, when a given expression has to be resolved.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection current {@link java.net.URI}s defining the
- * concrete resources to be read by a {@link org.apache.tamaya.core.spi.ConfigurationFormat}
- * .
- */
- List<URI> getResources(ClassLoader classLoader, Collection<String> expressions);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/meta-model.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/meta-model.properties b/core/src/main/resources/META-INF/meta-model.properties
index f3b1842..dcfc41f 100644
--- a/core/src/main/resources/META-INF/meta-model.properties
+++ b/core/src/main/resources/META-INF/meta-model.properties
@@ -22,7 +22,7 @@ format.xml-properties.spec=org.apache.tamaya.org.apache.tamaya.internal.format.P
format.properties.spec=org.apache.tamaya.org.apache.tamaya.internal.format.PropertiesFormat
## Define default readers (reading sources)
-reader.classpath.spec=org.apache.tamaya.core.properties.ClasspathPropertyProvider
+reader.classpath.spec=org.apache.tamaya.core.internal.properties.ClasspathPropertyProvider
reader.file.spec=org.apache.tamaya.core.properties.FilePropertyMap
## Define property maps
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.core.internal.resources.PathResolver
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.internal.resources.PathResolver b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.internal.resources.PathResolver
deleted file mode 100644
index 00254da..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.internal.resources.PathResolver
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.core.internal.resources.AntPathClasspathResolver
-org.apache.tamaya.core.internal.resources.AntPathClasspathsResolver
-org.apache.tamaya.core.internal.resources.AntPathFileResolver
-org.apache.tamaya.core.internal.resources.AntPathFilesResolver
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resource.ResourceLoader
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resource.ResourceLoader b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resource.ResourceLoader
new file mode 100644
index 0000000..f9c0de4
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resource.ResourceLoader
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.core.internal.resources.DefaultPathResourceLoader
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
index 07c8e4b..9865949 100644
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ConfigurationProviderSpi
@@ -16,4 +16,5 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.core.internal.DefaultConfigProvider
\ No newline at end of file
+org.apache.tamaya.core.internal.config.SystemPropertiesConfigProvider
+org.apache.tamaya.core.internal.config.EnvPropertiesConfigProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.PathResolver
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.PathResolver b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.PathResolver
new file mode 100644
index 0000000..e13b388
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.PathResolver
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.core.internal.resources.AntPathClasspathResolver
+org.apache.tamaya.core.internal.resources.AntPathFileResolver
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ResourceLoader
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ResourceLoader b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ResourceLoader
deleted file mode 100644
index f9c0de4..0000000
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.spi.ResourceLoader
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.core.internal.resources.DefaultPathResourceLoader
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
index f41b11b..1020ab5 100644
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationManagerSingletonSpi
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.core.internal.DefaultConfigurationManagerSingletonSpi
\ No newline at end of file
+org.apache.tamaya.core.internal.config.DefaultConfigurationManagerSingletonSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdaptersSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdaptersSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdaptersSingletonSpi
index 476c4a4..207176e 100644
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdaptersSingletonSpi
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyAdaptersSingletonSpi
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.core.internal.DefaultPropertyAdaptersSingletonSpi
+org.apache.tamaya.core.internal.properties.DefaultPropertyAdaptersSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProviderBuilderSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProviderBuilderSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProviderBuilderSpi
new file mode 100644
index 0000000..f7f9c4e
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProviderBuilderSpi
@@ -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.core.internal.properties.DefaultPropertyProviderBuilderSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
index 2e0380f..40575b2 100644
--- a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.StagesSingletonSpi
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.core.internal.DefaultStagesSingletonSpi
+org.apache.tamaya.core.internal.env.DefaultStagesSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
index cb0fddb..7f93f21 100644
--- a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
+++ b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
@@ -25,13 +25,13 @@ import static org.junit.Assert.assertTrue;
import org.apache.tamaya.annot.ConfiguredProperty;
import org.apache.tamaya.annot.DefaultValue;
-import org.apache.tamaya.core.internal.DefaultConfigurationManagerSingletonSpi;
+import org.apache.tamaya.core.internal.config.DefaultConfigurationManagerSingletonSpi;
import org.junit.Test;
import java.beans.PropertyChangeListener;
/**
- * Test class for {@link org.apache.tamaya.core.internal.DefaultConfigurationManagerSingletonSpi}.
+ * Test class for {@link org.apache.tamaya.core.internal.config.DefaultConfigurationManagerSingletonSpi}.
*/
public class DefaultConfigurationManagerSingletonSpiSingletonSpiTest {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/JavaOneDemo.java b/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
index 6e294b8..5a64f21 100644
--- a/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
+++ b/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
@@ -18,7 +18,6 @@
*/
package org.apache.tamaya;
-import org.apache.tamaya.core.config.ConfigurationBuilder;
import org.apache.tamaya.core.config.ConfigurationFormats;
import org.apache.tamaya.core.spi.ConfigurationFormat;
import org.junit.Test;
@@ -32,34 +31,32 @@ import static org.junit.Assert.assertNotNull;
/**
* Created by Anatole on 30.09.2014.
*/
-public class JavaOneDemo{
+public class JavaOneDemo {
@Test
- public void testFromSystemProperties(){
- PropertyProvider prov = PropertyProviders.fromSystemProperties();
+ public void testFromSystemProperties() {
+ PropertyProvider prov = PropertyProviderBuilder.create("Sys-conf").addSystemProperties().build();
assertNotNull(prov);
- for(Map.Entry<Object,Object> en:System.getProperties().entrySet()){
+ for (Map.Entry<Object, Object> en : System.getProperties().entrySet()) {
assertEquals(en.getValue(), prov.get(en.getKey().toString()).get());
}
}
@Test
- public void testProgrammatixPropertySet(){
- System.out.println(PropertyProviders.fromPaths("test", "classpath:test.properties"));
+ public void testProgrammatixPropertySet() {
+ System.out.println(PropertyProviderBuilder.create("test").addPaths("test", "classpath:test.properties"));
}
@Test
- public void testProgrammaticConfig(){
+ public void testProgrammaticConfig() {
ConfigurationFormat format = ConfigurationFormats.getPropertiesFormat();
- Map<String,String> cfgMap = new HashMap<>();
+ Map<String, String> cfgMap = new HashMap<>();
cfgMap.put("param1", "value1");
cfgMap.put("a", "Adrian"); // overrides Anatole
- Configuration config = ConfigurationBuilder.of("myTestConfig").addResources(
- "classpath:test.properties").addConfigMaps(AggregationPolicy.OVERRIDE(),
- PropertyProviders
- .fromPaths("classpath:cfg/test.xml"),
- PropertyProviders.fromArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}),
- PropertyProviders.fromMap(cfgMap)).build();
+ Configuration config = PropertyProviderBuilder.create("myTestConfig").addPaths(
+ "classpath:test.properties").addPaths("classpath:cfg/test.xml")
+ .addArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"})
+ .addMap(cfgMap).build().toConfiguration();
System.out.println(config.getAreas());
System.out.println("---");
System.out.println(config.getAreas(s -> s.startsWith("another")));
@@ -72,6 +69,6 @@ public class JavaOneDemo{
System.out.print("--- b=");
System.out.println(config.get("b"));
System.out.println("--- only a,b,c)");
- System.out.println(PropertyProviders.filtered((f) -> f.equals("a") || f.equals("b") || f.equals("c"), config));
+ System.out.println(PropertyProviderBuilder.create(config).filter((f) -> f.equals("a") || f.equals("b") || f.equals("c")).build());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java b/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
index 1dde61c..7f5004a 100644
--- a/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
+++ b/core/src/test/java/org/apache/tamaya/core/env/EnvironmentManagerTest.java
@@ -75,11 +75,12 @@ public class EnvironmentManagerTest {
List<String> envOrder = Environment.getEnvironmentHierarchy();
assertNotNull(envOrder);
assertTrue(envOrder.size()>0);
- assertTrue(envOrder.contains("root"));
- assertTrue(envOrder.contains("system"));
- assertTrue(envOrder.contains("myEar1"));
- assertTrue(envOrder.contains("MyApp1"));
- assertTrue(envOrder.get(0).equals("MyApp1"));
+ assertTrue(envOrder.contains("root(root)"));
+ assertTrue(envOrder.contains("system(system)"));
+ assertTrue(envOrder.get(1).contains("(ear)"));
+ assertTrue(envOrder.get(0).contains("(application)"));
+ assertTrue(envOrder.get(2).equals("system(system)"));
+ assertTrue(envOrder.get(3).equals("root(root)"));
}
@Test
@@ -98,6 +99,6 @@ public class EnvironmentManagerTest {
@Test
public void testEnvironmentOverride(){
assertEquals(Environment.getRootEnvironment().get("user.country").get(),System.getProperty("user.country"));
- assertEquals(Environment.current().get("user.country").get(), "DE_1234");
+ assertEquals(Environment.current().get("user.country").get(), System.getProperty("user.country"));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/core/properties/PropertyProviderBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/properties/PropertyProviderBuilderTest.java b/core/src/test/java/org/apache/tamaya/core/properties/PropertyProviderBuilderTest.java
new file mode 100644
index 0000000..ae92f47
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/core/properties/PropertyProviderBuilderTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.core.properties;
+
+import org.apache.tamaya.PropertyProviderBuilder;
+import org.junit.Test;
+
+import org.apache.tamaya.PropertyProvider;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Created by Anatole on 30.09.2014.
+ */
+public class PropertyProviderBuilderTest {
+
+ @Test
+ public void testFromEnvironmentProperties(){
+ PropertyProvider prov = PropertyProviderBuilder.create("test").addEnvironmentProperties().build();
+ assertNotNull(prov);
+ for(Map.Entry<String,String> en:System.getenv().entrySet()){
+ assertEquals(en.getValue(), prov.get(en.getKey()).get());
+ }
+ }
+
+ @Test
+ public void testFromSystemProperties(){
+ PropertyProvider prov = PropertyProviderBuilder.create("test").addSystemProperties().build();
+ assertNotNull(prov);
+ for(Map.Entry<Object,Object> en:System.getProperties().entrySet()){
+ assertEquals(en.getValue(), prov.get(en.getKey().toString()).get());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java b/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
deleted file mode 100644
index 825f895..0000000
--- a/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
+++ /dev/null
@@ -1,54 +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.core.properties;
-
-import org.apache.tamaya.PropertyProviders;
-import org.junit.Test;
-
-import org.apache.tamaya.PropertyProvider;
-
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Created by Anatole on 30.09.2014.
- */
-public class PropertyProvidersTest{
-
- @Test
- public void testFromEnvironmentProperties(){
- PropertyProvider prov = PropertyProviders.fromEnvironmentProperties();
- assertNotNull(prov);
- for(Map.Entry<String,String> en:System.getenv().entrySet()){
- assertEquals(en.getValue(), prov.get(en.getKey()).get());
- }
- }
-
- @Test
- public void testFromSystemProperties(){
- PropertyProvider prov = PropertyProviders.fromSystemProperties();
- assertNotNull(prov);
- for(Map.Entry<Object,Object> en:System.getProperties().entrySet()){
- assertEquals(en.getValue(), prov.get(en.getKey().toString()).get());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
index c42e926..d035e1d 100644
--- a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
+++ b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
@@ -21,8 +21,7 @@ package org.apache.tamaya.internal;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.MetaInfoBuilder;
import org.apache.tamaya.PropertyProvider;
-import org.apache.tamaya.PropertyProviders;
-import org.apache.tamaya.core.config.Configurations;
+import org.apache.tamaya.PropertyProviderBuilder;
import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
import java.util.Map;
@@ -43,9 +42,8 @@ public class MutableTestConfigProvider implements ConfigurationProviderSpi{
dataMap.put("sons.1", "Robin");
dataMap.put("sons.2", "Luke");
dataMap.put("sons.3", "Benjamin");
- PropertyProvider provider = PropertyProviders.fromMap(MetaInfoBuilder.of().setName(CONFIG_NAME).build(),
- dataMap);
- testConfig = Configurations.getConfiguration(provider);
+ PropertyProvider provider = PropertyProviderBuilder.create(CONFIG_NAME).addMap(dataMap).build();
+ testConfig = provider.toConfiguration();
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/internal/TestConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/internal/TestConfigProvider.java b/core/src/test/java/org/apache/tamaya/internal/TestConfigProvider.java
index c9fdde2..77f80b0 100644
--- a/core/src/test/java/org/apache/tamaya/internal/TestConfigProvider.java
+++ b/core/src/test/java/org/apache/tamaya/internal/TestConfigProvider.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.internal;
-import org.apache.tamaya.core.config.Configurations;
+import org.apache.tamaya.PropertyProviderBuilder;
import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
import org.apache.tamaya.Configuration;
@@ -47,8 +47,8 @@ public class TestConfigProvider implements ConfigurationProviderSpi{
config.put("BD", "123456789123456789123456789123456789.123456789123456789123456789123456789");
config.put("testProperty", "value current testProperty");
config.put("runtimeVersion", "${java.version}");
- testConfig = Configurations.getConfiguration(MetaInfoBuilder.of().setName("test").build(),
- () -> config);
+ testConfig = PropertyProviderBuilder.create("test").addMap(
+ config).build().toConfiguration();
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
index cd99d9c..b23cc12 100644
--- a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
+++ b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
@@ -18,44 +18,42 @@
*/
package org.apache.tamaya.simple;
-import org.apache.tamaya.PropertyProviders;
-import org.apache.tamaya.core.config.ConfigurationBuilder;
+import org.apache.tamaya.PropertyProviderBuilder;
import org.apache.tamaya.core.config.ConfigurationFormats;
import org.apache.tamaya.AggregationPolicy;
import org.apache.tamaya.core.spi.ConfigurationFormat;
import org.junit.Test;
import org.apache.tamaya.Configuration;
+
import java.util.HashMap;
import java.util.Map;
/**
* Created by Anatole on 24.02.14.
*/
-public class SimplePropertiesAndCLISample{
+public class SimplePropertiesAndCLISample {
@Test
- public void testSystemPropertyResolution(){
+ public void testSystemPropertyResolution() {
System.out.println(Configuration.evaluateValue("${sys:java.version}"));
}
@Test
- public void testProgrammatixPropertySet(){
- System.out.println(PropertyProviders.fromPaths("test", "classpath:test.properties"));
+ public void testProgrammatixPropertySet() {
+ System.out.println(PropertyProviderBuilder.create("test").addPaths("test", "classpath:test.properties").build());
}
@Test
- public void testProgrammaticConfig(){
+ public void testProgrammaticConfig() {
ConfigurationFormat format = ConfigurationFormats.getPropertiesFormat();
- Map<String,String> cfgMap = new HashMap<>();
+ Map<String, String> cfgMap = new HashMap<>();
cfgMap.put("param1", "value1");
cfgMap.put("a", "Adrian"); // overrides Anatole
- Configuration config = ConfigurationBuilder.of("myTestConfig").addResources(
- "classpath:test.properties").addConfigMaps(AggregationPolicy.OVERRIDE(),
- PropertyProviders
- .fromPaths("classpath:cfg/test.xml"),
- PropertyProviders.fromArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}),
- PropertyProviders.fromMap(cfgMap)).build();
+ Configuration config = PropertyProviderBuilder.create("myTestConfig").addPaths(
+ "classpath:test.properties").addPaths("classpath:cfg/test.xml")
+ .addArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}).addMap(cfgMap)
+ .build().toConfiguration();
System.out.println(config.getAreas());
System.out.println("---");
System.out.println(config.getAreas(s -> s.startsWith("another")));
@@ -68,7 +66,7 @@ public class SimplePropertiesAndCLISample{
System.out.print("--- b=");
System.out.println(config.get("b"));
System.out.println("--- only a,b,c)");
- System.out.println(PropertyProviders.filtered((f) -> f.equals("a") || f.equals("b") || f.equals("c"), config));
+ System.out.println(PropertyProviderBuilder.create(config).filter((f) -> f.equals("a") || f.equals("b") || f.equals("c")).build());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
index 61beb37..6c2ae19 100644
--- a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
+++ b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
@@ -58,7 +58,8 @@ public class UC1ReadProperties {
@Test
public void example() {
- Configuration config = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").toConfiguration();
+ Configuration config = PropertyProviderBuilder.create("test")
+ .addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build().toConfiguration();
String name = config.get("name").orElse("Anatole");
BigDecimal bigNum = config.get("num.BD", BigDecimal.class).orElseThrow(() -> new IllegalStateException("Sorry"));
double anotherNum = config.getDouble("num.Double").getAsDouble();
@@ -72,13 +73,13 @@ public class UC1ReadProperties {
Map<String, String> areaMap = config.toMap().entrySet().stream()
.filter((e) -> e.getKey().startsWith("num."))
.collect(Collectors.toMap((e) -> e.getKey().substring("num.".length()), (e) -> e.getValue()));
- Configuration areaConfig = PropertyProviders.fromMap(areaMap).toConfiguration();
+ Configuration areaConfig = PropertyProviderBuilder.create("Test").addMap(areaMap).build().toConfiguration();
System.out.println(areaConfig);
}
@Test
public void getConfigurationTest() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:barFoo.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:barFoo.properties").build();
Configuration config = provider.toConfiguration();
assertNotNull(config);
assertTrue(config.isEmpty());
@@ -88,7 +89,7 @@ public class UC1ReadProperties {
@Test
public void readBadPropertiesTest() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:barFoo.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:barFoo.properties").build();
assertNotNull(provider);
assertTrue(provider.isEmpty());
assertTrue(provider.keySet().isEmpty());
@@ -97,7 +98,7 @@ public class UC1ReadProperties {
@Test
public void readPropertiesTest() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
assertNotNull(provider);
assertEquals(provider.get("a").get(), "aValue");
assertEquals(provider.get("b").get(), "bValue");
@@ -121,7 +122,7 @@ public class UC1ReadProperties {
@Test
public void readXmlPropertiesTest() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml").build();
assertNotNull(provider);
assertEquals(provider.get("a-xml").get(), "aFromXml");
assertEquals(provider.get("b-xml").get(), "bFromXml");
@@ -130,7 +131,7 @@ public class UC1ReadProperties {
@Test
public void readIniPropertiesTest() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini").build();
assertNotNull(provider);
assertEquals(provider.get("a.b.c").get(), "abcValue-fromIni");
assertEquals(provider.get("a.b.b").get(), "abbValue-fromIni");
@@ -142,7 +143,8 @@ public class UC1ReadProperties {
@Test
public void readAllPropertiesTest() {
- PropertyProvider provider = PropertyProviders.fromPaths(AggregationPolicy.IGNORE_DUPLICATES(), "classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.*");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").withAggregationPolicy(AggregationPolicy.IGNORE_DUPLICATES)
+ .addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.*").build();
assertNotNull(provider);
// fromMap ini file
assertEquals(provider.get("a.b.c").get(), "abcValue-fromIni");
@@ -157,7 +159,7 @@ public class UC1ReadProperties {
@Test
public void checkForAValue() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
assertFalse(provider.containsKey("blabla"));
assertTrue(provider.containsKey("num.BD"));
assertFalse(provider.get("blabla").isPresent());
@@ -166,7 +168,7 @@ public class UC1ReadProperties {
@Test
public void checkKeys() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
assertEquals(provider.keySet().size(), 16);
assertTrue(provider.keySet().contains("boolean"));
assertFalse(provider.keySet().contains("blabla"));
@@ -174,7 +176,7 @@ public class UC1ReadProperties {
@Test
public void checkToMap() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
Map<String, String> map = provider.toMap();
assertNotNull(map);
assertEquals(map.size(), 16);
@@ -185,34 +187,34 @@ public class UC1ReadProperties {
@Test
public void checkMetaInfo() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
MetaInfo meta = provider.getMetaInfo();
assertNotNull(meta);
}
@Test
public void checkNeverNull() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
assertNotNull(provider.get("blabla"));
assertNotNull(provider.get("a.b.c"));
}
@Test
public void checkUndefined() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
assertFalse(provider.get("blabla").isPresent());
assertTrue(provider.get("a.b.c").isPresent());
}
@Test
public void checkPassDefaultValues() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
assertEquals("myDefaultValue", provider.get("blabla").orElse("myDefaultValue"));
}
@Test(expected = IllegalStateException.class)
public void checkThrowCustomException() {
- PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
provider.get("blabla").orElseThrow(() -> new IllegalStateException("checkThrowCustomException"));
}
}