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/03/18 00:49:15 UTC

[3/6] incubator-tamaya git commit: Added Resolver singleton.

Added Resolver singleton.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/bc03d8c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/bc03d8c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/bc03d8c4

Branch: refs/heads/master
Commit: bc03d8c42c2e5a2b55c0f8cbf2308f04dffcdf22
Parents: 3bd3fe7
Author: anatole <an...@apache.org>
Authored: Mon Mar 16 01:39:13 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Mar 16 01:39:13 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/resolver/Resolver.java    | 54 ++++++++++++++++++++
 1 file changed, 54 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/bc03d8c4/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
new file mode 100644
index 0000000..39844f9
--- /dev/null
+++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.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.resolver;
+
+import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
+import org.apache.tamaya.spi.ServiceContextManager;
+
+/**
+ * Resolver singleton.
+ */
+public final class Resolver {
+
+    /**
+     * Singleton constructor.
+     */
+    private Resolver(){}
+
+    /**
+     * Evaluates the current expression.
+     * @param key the key, not null.
+     * @param value the value to be filtered/evaluated.
+     * @return the filtered/evaluated value, including null.
+     */
+    public static String evaluateExpression(String key, String value){
+        return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class).get()
+                .evaluateExpression(key, value);
+    }
+
+    /**
+     * Evaluates the current expression.
+     * @param value the value to be filtered/evaluated.
+     * @return the filtered/evaluated value, including null.
+     */
+    public static String evaluateExpression(String value){
+        return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class).get()
+                .evaluateExpression(null, value);
+    }
+}