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/01/04 21:59:57 UTC
[1/2] incubator-tamaya git commit: TAMAYA-47: Added initial revision
of a functional value resolver module (implemented as PropertyFilter).
Repository: incubator-tamaya
Updated Branches:
refs/heads/master dbf8af82e -> 99997f39e
TAMAYA-47: Added initial revision of a functional value resolver module (implemented as PropertyFilter).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/11708a62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/11708a62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/11708a62
Branch: refs/heads/master
Commit: 11708a627ce0ba1199225d333c0e1f3be7362db2
Parents: 69be0de
Author: anatole <an...@apache.org>
Authored: Sun Jan 4 21:58:48 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 4 21:58:48 2015 +0100
----------------------------------------------------------------------
modules/resolver/pom.xml | 10 ++
.../tamaya/resolver/ExpressionEvaluator.java | 38 ------
.../internal/DefaultExpressionEvaluator.java | 127 +++++++++++++------
.../internal/EnvironmentPropertyResolver.java | 15 +--
.../internal/SystemPropertyResolver.java | 16 +--
.../tamaya/resolver/spi/ExpressionResolver.java | 40 +++---
...pache.tamaya.resolver.spi.ExpressionResolver | 20 +++
.../org.apache.tamaya.spi.PropertyFilter | 19 +++
.../tamaya/resolver/MyResolutionTest.java | 15 +++
.../tamaya/resolver/MyTestPropertySource.java | 45 +++++++
.../org.apache.tamaya.spi.PropertySource | 19 +++
11 files changed, 251 insertions(+), 113 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/pom.xml
----------------------------------------------------------------------
diff --git a/modules/resolver/pom.xml b/modules/resolver/pom.xml
index fb33e38..301ba9a 100644
--- a/modules/resolver/pom.xml
+++ b/modules/resolver/pom.xml
@@ -36,5 +36,15 @@ under the License.
<artifactId>tamaya-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/java/org/apache/tamaya/resolver/ExpressionEvaluator.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/ExpressionEvaluator.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/ExpressionEvaluator.java
deleted file mode 100644
index 5baa956..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/ExpressionEvaluator.java
+++ /dev/null
@@ -1,38 +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 org.apache.tamaya.Configuration;
-
-/**
- * This interfaces provides a model for expression evaluation. This enables transparently plugin expression languages
- * as needed. In a Java EE context full fledged EL may be used, whereas in ME only simple replacement mechanisms
- * are better suited to the runtime requirements.
- */
-@FunctionalInterface
-public interface ExpressionEvaluator {
- /**
- * Evaluates the given expression.
- * @param expression the expression to be evaluated, not null.
- * @param configurations the configurations to be used for evaluating the values for injection into {@code instance}.
- * If no items are passed, the default configuration is used.
- * @return the evaluated expression.
- */
- String evaluate(String expression, Configuration... configurations);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
index 457aa6c..8590761 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
@@ -16,41 +16,80 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.core.internal.el;
+package org.apache.tamaya.resolver.internal;
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
+import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.ServiceContext;
-import org.apache.tamaya.core.spi.ExpressionEvaluator;
-import org.apache.tamaya.core.spi.ExpressionResolver;
+import org.apache.tamaya.resolver.spi.ExpressionResolver;
+import javax.annotation.Priority;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
- * Default expression evaluator that manages several instances of {@link org.apache.tamaya.core.spi.ExpressionResolver}.
+ * Default expression evaluator that manages several instances of {@link org.apache.tamaya.resolver.spi.ExpressionResolver}.
* Each resolver is identified by a resolver id. Each expression passed has the form resolverId:resolverExpression, which
* has the advantage that different resolvers can be active in parallel.
*/
-public final class DefaultExpressionEvaluator implements ExpressionEvaluator{
+@Priority(10000)
+public class DefaultExpressionEvaluator implements PropertyFilter {
- private Map<String, ExpressionResolver> resolvers = new ConcurrentHashMap<>();
+ private static final Logger LOG = Logger.getLogger(DefaultExpressionEvaluator.class.getName());
- private ExpressionResolver defaultResolver;
+ private List<ExpressionResolver> resolvers = new ArrayList<>();
public DefaultExpressionEvaluator() {
for(ExpressionResolver resolver: ServiceContext.getInstance().getServices(ExpressionResolver.class)){
- resolvers.put(resolver.getResolverId(), resolver);
+ resolvers.add(resolver);
}
- defaultResolver = ServiceContext.getInstance().getSingleton(ExpressionResolver.class);
+ Collections.sort(resolvers, this::compareExpressionResolver);
}
/**
- * Resolves an expression in the form current <code>${resolverId:expression}</code>. The expression can be
- * part current any type current literal text. Also multiple expression, with different resolver ids are supported.
- * All control characters (${}\) can be escaped.<br>
+ * Order ExpressionResolver reversely, the most important come first.
+ *
+ * @param res1 the first ExpressionResolver
+ * @param res2 the second ExpressionResolver
+ * @return the comparison result.
+ */
+ private int compareExpressionResolver(ExpressionResolver res1, ExpressionResolver res2) {
+ Priority prio1 = res1.getClass().getAnnotation(Priority.class);
+ Priority prio2 = res2.getClass().getAnnotation(Priority.class);
+ int ord1 = prio1 != null ? prio1.value() : 0;
+ int ord2 = prio2 != null ? prio2.value() : 0;
+ if (ord1 < ord2) {
+ return -1;
+ } else if (ord1 > ord2) {
+ return 1;
+ } else {
+ return res1.getClass().getName().compareTo(res2.getClass().getName());
+ }
+ }
+
+ /**
+ * Resolves an expression in the form current <code>${resolverId:expression}</code> or
+ * <code>${<prefix>expression}</code>. The expression can be
+ * part current any type current literal text. Also multiple expressions with mixed matching resolvers are
+ * supported.
+ * All control characters (${}\) can be escaped using '\'.<br>
* So all the following are valid expressions:
* <ul>
+ * <li><code>${expression}</code></li>
+ * <li><code>bla bla ${expression}</code></li>
+ * <li><code>${expression} bla bla</code></li>
+ * <li><code>bla bla ${expression} bla bla</code></li>
+ * <li><code>${expression}${resolverId2:expression2}</code></li>
+ * <li><code>foo ${expression}${resolverId2:expression2}</code></li>
+ * <li><code>foo ${expression} bar ${resolverId2:expression2}</code></li>
+ * <li><code>${expression}foo${resolverId2:expression2}bar</code></li>
+ * <li><code>foor${expression}bar${resolverId2:expression2}more</code></li>
+ * <li><code>\${expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
+ * </ul>
+ * Given {@code resolverId:} is a valid prefix targeting a {@link java.beans.Expression} explicitly, also the
+ * following expressions are valid:
+ * <ul>
* <li><code>${resolverId:expression}</code></li>
* <li><code>bla bla ${resolverId:expression}</code></li>
* <li><code>${resolverId:expression} bla bla</code></li>
@@ -63,16 +102,13 @@ public final class DefaultExpressionEvaluator implements ExpressionEvaluator{
* <li><code>\${resolverId:expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
* </ul>
*
- * @param expression the expression to be evaluated, not null
- * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}.
- * If no such config is passed, the default configurations provided by the current
- * registered providers are used.
- * @return the evaluated expression.
- * @throws org.apache.tamaya.ConfigException if resolution fails.
+ * @param key the key to be filtered
+ * @param valueToBeFiltered value to be analyzed for expressions
+ * @return the resolved value, or the input in case where no expression was detected.
*/
@Override
- public String evaluate(String expression, Configuration... configurations) {
- StringTokenizer tokenizer = new StringTokenizer(expression, "${}\\", true);
+ public String filterProperty(String key, String valueToBeFiltered, Function<String,String> propertyValueProvider){
+ StringTokenizer tokenizer = new StringTokenizer(valueToBeFiltered, "${}\\", true);
boolean escaped = false;
StringBuilder resolvedValue = new StringBuilder();
StringBuilder current = new StringBuilder();
@@ -106,14 +142,16 @@ public final class DefaultExpressionEvaluator implements ExpressionEvaluator{
current.setLength(0);
}
if (!"{".equals(tokenizer.nextToken())) {
- throw new ConfigException("Invalid expression encountered: " + expression);
+ LOG.warning("Invalid expression syntax in: " + valueToBeFiltered);
+ return valueToBeFiltered;
}
String subExpression = tokenizer.nextToken();
if (!"}".equals(tokenizer.nextToken())) {
- throw new ConfigException("Invalid expression encountered: " + expression);
+ LOG.warning("Invalid expression syntax in: " + valueToBeFiltered);
+ return valueToBeFiltered;
}
// evaluate sub-expression
- current.append(evaluteInternal(subExpression));
+ current.append(evaluteInternal(subExpression, propertyValueProvider));
break;
default:
current.append(token);
@@ -125,19 +163,32 @@ public final class DefaultExpressionEvaluator implements ExpressionEvaluator{
return resolvedValue.toString();
}
- private String evaluteInternal(String subExpression) {
- int sepPos = subExpression.indexOf(':');
- if (sepPos > 0) {
- String refID = subExpression.substring(0, sepPos);
- String expression = subExpression.substring(sepPos + 1);
- return Optional.ofNullable(this.resolvers.get(refID)).orElseThrow(
- () -> new ConfigException("Resolver not found: " + refID + " in " + subExpression)
- ).resolve(expression);
- } else {
- return Optional.ofNullable(this.defaultResolver).orElseThrow(
- () -> new ConfigException("No default Resolver set, but required by " + subExpression)
- ).resolve(subExpression);
+ private String evaluteInternal(String subExpression, Function<String,String> propertyValueProvider) {
+ String value = null;
+ // 1 check for explicit prefix
+ for(ExpressionResolver resolver:resolvers){
+ if(subExpression.startsWith(resolver.getResolverPrefix())){
+ value = resolver.evaluate(subExpression.substring(resolver.getResolverPrefix().length()), propertyValueProvider);
+ break;
+ }
+ }
+ if(value==null){
+ for(ExpressionResolver resolver:resolvers){
+ try{
+ value = resolver.evaluate(subExpression, propertyValueProvider);
+ if(value!=null){
+ return value;
+ }
+ }catch(Exception e){
+ LOG.log(Level.WARNING, "Error during expression resolution from " + resolver, e);
+ }
+ }
+ }
+ if(value==null){
+ LOG.log(Level.WARNING, "Unresolvable expression encountered " + subExpression);
+ value = '[' + subExpression + ']';
}
+ return value;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
index 68d37a4..f0c46a9 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
@@ -16,13 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.core.internal.el;
+package org.apache.tamaya.resolver.internal;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.spi.ExpressionResolver;
+import org.apache.tamaya.resolver.spi.ExpressionResolver;
import java.util.Optional;
+import java.util.function.Function;
/**
* Property resolver implementation that interprets the resolver expressions as environment properties.
@@ -30,15 +31,13 @@ import java.util.Optional;
public final class EnvironmentPropertyResolver implements ExpressionResolver{
@Override
- public String getResolverId() {
- return "env";
+ public String getResolverPrefix() {
+ return "env:";
}
@Override
- public String resolve(String expression, Configuration... configurations){
- return Optional.ofNullable(System.getenv(expression)).orElseThrow(
- () -> new ConfigException("No such environment property: " + expression)
- );
+ public String evaluate(String expression, Function<String, String> propertyResolver){
+ return Optional.ofNullable(System.getenv(expression)).orElse(null);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
index c6eb298..7617023 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
@@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.core.internal.el;
+package org.apache.tamaya.resolver.internal;
import java.util.Optional;
+import java.util.function.Function;
import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.spi.ExpressionResolver;
+import org.apache.tamaya.resolver.spi.ExpressionResolver;
/**
* Property resolver implementation that interprets the resolver expression as system property name.
@@ -30,15 +30,13 @@ import org.apache.tamaya.core.spi.ExpressionResolver;
public final class SystemPropertyResolver implements ExpressionResolver{
@Override
- public String getResolverId() {
- return "sys";
+ public String getResolverPrefix() {
+ return "sys:";
}
@Override
- public String resolve(String expression, Configuration... configurations){
- return Optional.ofNullable(System.getProperty(expression)).orElseThrow(
- () -> new ConfigException("No such system property: " + expression)
- );
+ public String evaluate(String expression, Function<String, String> propertyResolver){
+ return Optional.ofNullable(System.getProperty(expression)).orElse(null);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java
index 5ec7b52..d9bcb78 100644
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java
@@ -16,38 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.core.spi;
+package org.apache.tamaya.resolver.spi;
import org.apache.tamaya.Configuration;
+import java.util.function.Function;
+
/**
- * This interface defines a small plugin for resolving current expressions within configuration.
- * Resolver expression always have the form current <code>${resolverId:expression}</code>. The
- * {@code resolverId} hereby references the resolver to be used to replace the according
- * {@code expression}. Also it is well possible to mix different resolvers, e.g. using
- * an expression like <code>${ref1:expression1} bla bla ${ref2:expression2}</code>.
- * Finally when no resolver id is passed, the default resolver should be used.
+ * This interfaces provides a model for expression evaluation. This enables transparently plugin expression languages
+ * as needed. In a Java EE context full fledged EL may be used, whereas in ME only simple replacement mechanisms
+ * are better suited to the runtime requirements.
*/
public interface ExpressionResolver {
/**
- * Get a (unique) resolver id used as a prefix for qualifying the resolver to be used for
- * resolving an expression.
+ * Get the unique resolver prefix. This allows to address a resolver explicitly, in case of conflicts. By
+ * default all registered resolvers are called in order as defined by the {@link javax.annotation.Priority}
+ * annotation.
*
- * @return the (unique) resolver id, never null, not empty.
+ * @return the prefix that identifies this resolver instance, e.g. 'config:'.
*/
- String getResolverId();
+ public String getResolverPrefix();
/**
- * Resolve the expression. The expression should be stripped fromMap any surrounding parts.
- * E.g. <code>${myresolver:blabla to be interpreted AND executed.}</code> should be passed
- * as {@code blabla to be interpreted AND executed.} only.
+ * Evaluates the given expression.
*
- * @param expression the stripped expression.
- * @param configuration the configuration for which the value must be resolved.
- * @return the resolved expression.
- * @throws org.apache.tamaya.ConfigException when the expression passed is not resolvable, e.g. due to syntax issues
- * or data not present or valid.
+ * @param expression the expression to be evaluated, not null. If a resolver was addressed explicitly,
+ * the prefix is removed prior to calling this method.
+ * @param propertyResolver a functional instance to resolve additional properties as needed, e.g. reading
+ * additional system, environment properties, or meta-properties. This abstraction
+ * gives the evaluator access to the contextual configuration instance which
+ * contains expressions.
+ * @return the evaluated expression, or null, if the evaluator is not able to resolve the expression.
*/
- String resolve(String expression, Configuration configuration);
+ String evaluate(String expression, Function<String, String> propertyResolver);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver
new file mode 100644
index 0000000..5c26b65
--- /dev/null
+++ b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver
@@ -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.resolver.internal.SystemPropertyResolver
+org.apache.tamaya.resolver.internal.EnvironmentPropertyResolver
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
new file mode 100644
index 0000000..aa766b6
--- /dev/null
+++ b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
@@ -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.resolver.internal.DefaultExpressionEvaluator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyResolutionTest.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyResolutionTest.java b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyResolutionTest.java
new file mode 100644
index 0000000..b69d762
--- /dev/null
+++ b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyResolutionTest.java
@@ -0,0 +1,15 @@
+package org.apache.tamaya.resolver;
+
+import org.apache.tamaya.Configuration;
+import org.junit.Test;
+
+/**
+ * Created by Anatole on 04.01.2015.
+ */
+public class MyResolutionTest {
+
+ @Test
+ public void testConfig(){
+ System.out.println(Configuration.current().getProperties());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
new file mode 100644
index 0000000..f765a64
--- /dev/null
+++ b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
@@ -0,0 +1,45 @@
+package org.apache.tamaya.resolver;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Created by Anatole on 04.01.2015.
+ */
+public class MyTestPropertySource implements PropertySource{
+
+ private Map<String,String> properties = new HashMap<>();
+
+ public MyTestPropertySource(){
+ properties.put("Expression Only", "${java.version}");
+ properties.put("Expression Only (prefixed)", "${sys:java.version}");
+ properties.put("Before Text", "My Java version is ${java.version}");
+ properties.put("Before Text (prefixed)", "My Java version is ${sys:java.version}");
+ properties.put("Before and After Text", "My Java version is ${java.version}.");
+ properties.put("Before and After Text (prefixed)", "My Java version is ${sys:java.version}.");
+ properties.put("Multi-expression", "Java version ${sys:java.version} and line.separator ${line.separator}.");
+ }
+
+ @Override
+ public int getOrdinal() {
+ return 0;
+ }
+
+ @Override
+ public String getName() {
+ return "test";
+ }
+
+ @Override
+ public Optional<String> get(String key) {
+ return Optional.ofNullable(properties.get(key));
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11708a62/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
new file mode 100644
index 0000000..088aca9
--- /dev/null
+++ b/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.resolver.MyTestPropertySource
\ No newline at end of file
[2/2] incubator-tamaya git commit: Merge remote-tracking branch
'origin/master'
Posted by an...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/99997f39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/99997f39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/99997f39
Branch: refs/heads/master
Commit: 99997f39e7d1f748d73d614e665d684d9a383a9c
Parents: 11708a6 dbf8af8
Author: anatole <an...@apache.org>
Authored: Sun Jan 4 21:59:49 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Sun Jan 4 21:59:49 2015 +0100
----------------------------------------------------------------------
pom.xml | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------