From 68ef3c68b03846da6953eab5f6b24dbaec35a2eb Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Sat, 5 Jan 2013 19:31:42 +0100 Subject: [PATCH] DATACMNS-263 - Fixed incompatibility with OpenWebbeans < 1.1.8. Prefer using non-anonymous inner classes to represent @Default and @Any qualifiers. Upgraded to OpenWebbeans 1.1.7 along the way. --- spring-data-commons-core/pom.xml | 2 +- .../cdi/CdiRepositoryExtensionSupport.java | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/spring-data-commons-core/pom.xml b/spring-data-commons-core/pom.xml index 48043299d..f3e046b07 100644 --- a/spring-data-commons-core/pom.xml +++ b/spring-data-commons-core/pom.xml @@ -19,7 +19,7 @@ 1.8.5 2.8.0 1.7.1 - 1.1.3 + 1.1.7 diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryExtensionSupport.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryExtensionSupport.java index 6f964ec03..5fd10c2bb 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryExtensionSupport.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryExtensionSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 the original author or authors. + * Copyright 2011-2013 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. @@ -94,7 +94,6 @@ public abstract class CdiRepositoryExtensionSupport implements Extension { /** * Determines the qualifiers of the given type. */ - @SuppressWarnings("serial") private Set getQualifiers(final Class type) { Set qualifiers = new HashSet(); @@ -105,14 +104,14 @@ public abstract class CdiRepositoryExtensionSupport implements Extension { qualifiers.add(annotation); } } + // Add @Default qualifier if no qualifier is specified. if (qualifiers.isEmpty()) { - qualifiers.add(new AnnotationLiteral() { - }); + qualifiers.add(DefaultAnnotationLiteral.INSTANCE); } + // Add @Any qualifier. - qualifiers.add(new AnnotationLiteral() { - }); + qualifiers.add(AnyAnnotationLiteral.INSTANCE); return qualifiers; } @@ -124,4 +123,16 @@ public abstract class CdiRepositoryExtensionSupport implements Extension { protected Iterable, Set>> getRepositoryTypes() { return repositoryTypes.entrySet(); } + + private static class DefaultAnnotationLiteral extends AnnotationLiteral implements Default { + + private static final long serialVersionUID = 511359421048623933L; + private static final DefaultAnnotationLiteral INSTANCE = new DefaultAnnotationLiteral(); + } + + private static class AnyAnnotationLiteral extends AnnotationLiteral implements Any { + + private static final long serialVersionUID = 7261821376671361463L; + private static final AnyAnnotationLiteral INSTANCE = new AnyAnnotationLiteral(); + } }