tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject incubator-tamaya git commit: TAMAYA-19: Fixed compile issues.
Date Tue, 16 Dec 2014 23:50:46 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 84bf6f827 -> 11a48e8c5


TAMAYA-19: Fixed compile issues.


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

Branch: refs/heads/master
Commit: 11a48e8c5d649fff329eabb02391c84705e3975a
Parents: 84bf6f8
Author: anatole <anatole@apache.org>
Authored: Wed Dec 17 00:50:37 2014 +0100
Committer: anatole <anatole@apache.org>
Committed: Wed Dec 17 00:50:37 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/tamaya/PropertyAdapter.java | 50 ++++++++++++++++++++
 .../org/apache/tamaya/PropertyAdapters.java     |  2 +-
 .../java/org/apache/tamaya/spi/Orderable.java   | 27 ++++++++++-
 .../org/apache/tamaya/spi/OrdinalProvider.java  | 18 +++++++
 .../core/internal/inject/ConfiguredField.java   |  3 +-
 .../core/internal/inject/ConfiguredMethod.java  |  3 +-
 6 files changed, 97 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11a48e8c/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapter.java b/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
index e9d1ce3..5ee0eb7 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
@@ -19,6 +19,10 @@
 package org.apache.tamaya;
 
 
+import org.apache.tamaya.annotation.WithPropertyAdapter;
+import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
+import org.apache.tamaya.spi.ServiceContext;
+
 /**
  * Interface for an adapter that converts a configured String into something else.
  * This is typically used for implementing type conversion fromMap String to a certain target
@@ -34,4 +38,50 @@ public interface PropertyAdapter<T>{
      */
     T adapt(String value);
 
+    /**
+     * Registers a new PropertyAdapter for the given target type, hereby replacing any existing
adapter for
+     * this type.
+     * @param targetType The target class, not null.
+     * @param adapter The adapter, not null.
+     * @param <T> The target type
+     * @return any adapter replaced with the new adapter, or null.
+     */
+    public static <T> PropertyAdapter<T> register(Class<T> targetType,
PropertyAdapter<T> adapter){
+        return PropertyAdapters.register(targetType, adapter);
+    }
+
+    /**
+     * Get an adapter converting to the given target type.
+     * @param targetType the target type class
+     * @return true, if the given target type is supported.
+     */
+    public static boolean isTargetTypeSupported(Class<?> targetType){
+        return PropertyAdapters.isTargetTypeSupported(targetType);
+    }
+
+    /**
+     * Get an adapter converting to the given target type.
+     * @param targetType the target type class
+     * @param <T> the target type
+     * @return the corresponding adapter, never null.
+     * @throws ConfigException if the target type is not supported.
+     */
+    public static  <T> PropertyAdapter<T> getAdapter(Class<T> targetType){
+        return PropertyAdapters.getAdapter(targetType);
+    }
+
+    /**
+     * Get an adapter converting to the given target type.
+     * @param targetType the target type class
+     * @param annotation the {@link org.apache.tamaya.annotation.WithPropertyAdapter} annotation,
or null. If the annotation is not null and
+     *                   defines an overriding adapter, this instance is created and returned.
+     * @param <T> the target type
+     * @return the corresponding adapter, never null.
+     * @throws ConfigException if the target type is not supported, or the overriding adapter
cannot be
+     * instantiated.
+     */
+    public static  <T> PropertyAdapter<T> getAdapter(Class<T> targetType,
WithPropertyAdapter annotation){
+        return PropertyAdapters.getAdapter(targetType, annotation);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11a48e8c/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
index cde5934..90b29d7 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
@@ -26,7 +26,7 @@ import org.apache.tamaya.spi.PropertyAdaptersSingletonSpi;
  * Singleton manager that provides {@link PropertyAdapter} instance, usable for converting
String
  * based configuration entries into any other target types.
  */
-public final class PropertyAdapters{
+final class PropertyAdapters{
 
     /**
      * Orivate singleton constructor.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11a48e8c/api/src/main/java/org/apache/tamaya/spi/Orderable.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/Orderable.java b/api/src/main/java/org/apache/tamaya/spi/Orderable.java
index 401d181..4a314f6 100644
--- a/api/src/main/java/org/apache/tamaya/spi/Orderable.java
+++ b/api/src/main/java/org/apache/tamaya/spi/Orderable.java
@@ -1,9 +1,34 @@
+/*
+ * 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.spi;
 
 /**
- * Created by Anatole on 14.12.2014.
+ * Interface that can be optionally implemented by SPI components to be loaded into
+ * the Tamaya's ServiceContext. The ordinal provided will be used to determine
+ * priority and precedence, when multiple components implement the same
+ * service interface.
  */
 @FunctionalInterface
 public interface Orderable {
+    /**
+     * Get the ordinal value for the component, by default 0.
+     * @return the ordinal value
+     */
     int order();
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11a48e8c/api/src/main/java/org/apache/tamaya/spi/OrdinalProvider.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/OrdinalProvider.java b/api/src/main/java/org/apache/tamaya/spi/OrdinalProvider.java
index 7d0c205..aad8618 100644
--- a/api/src/main/java/org/apache/tamaya/spi/OrdinalProvider.java
+++ b/api/src/main/java/org/apache/tamaya/spi/OrdinalProvider.java
@@ -1,3 +1,21 @@
+/*
+ * 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.spi;
 
 import java.util.OptionalInt;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11a48e8c/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
index 37c8d2c..ee5aeda 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
@@ -21,7 +21,6 @@ package org.apache.tamaya.core.internal.inject;
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.PropertyAdapters;
 import org.apache.tamaya.annotation.*;
 import org.apache.tamaya.core.internal.Utils;
 
@@ -140,7 +139,7 @@ public class ConfiguredField {
                 if (String.class.equals(baseType) || baseType.isAssignableFrom(configValue.getClass()))
{
                     annotatedField.set(target, configValue);
                 } else {
-                    PropertyAdapter<?> adapter = PropertyAdapters.getAdapter(baseType);
+                    PropertyAdapter<?> adapter = PropertyAdapter.getAdapter(baseType);
                     annotatedField.set(target, adapter.adapt(configValue));
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/11a48e8c/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
index de7eaf9..3bc4472 100644
--- a/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
+++ b/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredMethod.java
@@ -21,7 +21,6 @@ package org.apache.tamaya.core.internal.inject;
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.PropertyAdapters;
 import org.apache.tamaya.annotation.*;
 import org.apache.tamaya.core.internal.Utils;
 
@@ -182,7 +181,7 @@ public class ConfiguredMethod {
                 if (String.class.equals(baseType) || baseType.isAssignableFrom(configValue.getClass()))
{
                     return configValue;
                 } else {
-                    PropertyAdapter<?> adapter = PropertyAdapters.getAdapter(baseType);
+                    PropertyAdapter<?> adapter = PropertyAdapter.getAdapter(baseType);
                     return adapter.adapt(configValue);
                 }
             }


Mime
View raw message