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 2017/11/14 09:25:51 UTC
[10/12] incubator-tamaya git commit: TAMAYA-318 Fixed issue
registering default converters with invalid target type.
TAMAYA-318 Fixed issue registering default converters with invalid target type.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/aa6dbe62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/aa6dbe62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/aa6dbe62
Branch: refs/heads/master
Commit: aa6dbe62dfad0490506e5c9eacb87e962939ff14
Parents: 878b236
Author: Anatole Tresch <an...@apache.org>
Authored: Tue Nov 14 08:47:57 2017 +0100
Committer: Anatole Tresch <an...@apache.org>
Committed: Tue Nov 14 08:47:57 2017 +0100
----------------------------------------------------------------------
.../DefaultConfigurationContextBuilder.java | 21 ++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/aa6dbe62/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
index 4cad87d..8268f64 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
@@ -35,6 +35,8 @@ import org.apache.tamaya.spisupport.propertysource.JavaConfigurationPropertySour
import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
import java.io.File;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
@@ -397,13 +399,20 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
Map<TypeLiteral, Collection<PropertyConverter>> result = new HashMap<>();
for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(
PropertyConverter.class)) {
- TypeLiteral target = TypeLiteral.of(TypeLiteral.of(conv.getClass()).getType());
- Collection<PropertyConverter> convList = result.get(target);
- if (convList == null) {
- convList = new ArrayList<>();
- result.put(target, convList);
+ for(Type type:conv.getClass().getGenericInterfaces()){
+ if(type instanceof ParameterizedType){
+ ParameterizedType pt = (ParameterizedType)type;
+ if(PropertyConverter.class.equals(((ParameterizedType) type).getRawType())){
+ TypeLiteral target = TypeLiteral.of(pt.getActualTypeArguments()[0]);
+ Collection<PropertyConverter> convList = result.get(target);
+ if (convList == null) {
+ convList = new ArrayList<>();
+ result.put(target, convList);
+ }
+ convList.add(conv);
+ }
+ }
}
- convList.add(conv);
}
return result;
}