You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2016/03/09 14:16:54 UTC
camel git commit: Do not override alternative priority if already
defined in Camel CDI tests
Repository: camel
Updated Branches:
refs/heads/master 8c415c8f3 -> 1c0c5a9e2
Do not override alternative priority if already defined in Camel CDI tests
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1c0c5a9e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1c0c5a9e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1c0c5a9e
Branch: refs/heads/master
Commit: 1c0c5a9e2c29262a7f495720cd8cb0f06d4d0c0b
Parents: 8c415c8
Author: Antonin Stefanutti <an...@stefanutti.fr>
Authored: Wed Mar 9 14:15:57 2016 +0100
Committer: Antonin Stefanutti <an...@stefanutti.fr>
Committed: Wed Mar 9 14:16:22 2016 +0100
----------------------------------------------------------------------
.../camel/test/cdi/CamelCdiTestExtension.java | 24 +++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1c0c5a9e/components/camel-test-cdi/src/main/java/org/apache/camel/test/cdi/CamelCdiTestExtension.java
----------------------------------------------------------------------
diff --git a/components/camel-test-cdi/src/main/java/org/apache/camel/test/cdi/CamelCdiTestExtension.java b/components/camel-test-cdi/src/main/java/org/apache/camel/test/cdi/CamelCdiTestExtension.java
index 7b7e151..cf1d3a2 100644
--- a/components/camel-test-cdi/src/main/java/org/apache/camel/test/cdi/CamelCdiTestExtension.java
+++ b/components/camel-test-cdi/src/main/java/org/apache/camel/test/cdi/CamelCdiTestExtension.java
@@ -19,13 +19,16 @@ package org.apache.camel.test.cdi;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import javax.annotation.Priority;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.enterprise.inject.spi.WithAnnotations;
-import javax.interceptor.Interceptor.Priority;
+
+import static javax.interceptor.Interceptor.Priority.APPLICATION;
final class CamelCdiTestExtension implements Extension {
@@ -47,25 +50,24 @@ final class CamelCdiTestExtension implements Extension {
* @see Beans
*/
private <T> void alternatives(@Observes @WithAnnotations(Alternative.class) ProcessAnnotatedType<T> pat) {
- if (!Arrays.asList(beans.alternatives()).contains(pat.getAnnotatedType().getJavaClass())) {
+ AnnotatedType<T> type = pat.getAnnotatedType();
+
+ if (!Arrays.asList(beans.alternatives()).contains(type.getJavaClass())) {
// Only select globally the alternatives that are declared with @Beans
return;
}
Set<AnnotatedMethod<? super T>> methods = new HashSet<>();
- for (AnnotatedMethod<? super T> am : pat.getAnnotatedType().getMethods()) {
- if (am.isAnnotationPresent(Alternative.class)) {
- methods.add(new AnnotatedMethodDecorator<>(am, PriorityLiteral.of(Priority.APPLICATION)));
+ for (AnnotatedMethod<? super T> method : type.getMethods()) {
+ if (method.isAnnotationPresent(Alternative.class) && !method.isAnnotationPresent(Priority.class)) {
+ methods.add(new AnnotatedMethodDecorator<>(method, PriorityLiteral.of(APPLICATION)));
}
}
- if (pat.getAnnotatedType().isAnnotationPresent(Alternative.class)) {
- pat.setAnnotatedType(new AnnotatedTypeDecorator<>(pat.getAnnotatedType(),
- PriorityLiteral.of(Priority.APPLICATION),
- methods));
+ if (type.isAnnotationPresent(Alternative.class) && !type.isAnnotationPresent(Priority.class)) {
+ pat.setAnnotatedType(new AnnotatedTypeDecorator<>(type, PriorityLiteral.of(APPLICATION), methods));
} else if (!methods.isEmpty()) {
- pat.setAnnotatedType(new AnnotatedTypeDecorator<>(pat.getAnnotatedType(),
- methods));
+ pat.setAnnotatedType(new AnnotatedTypeDecorator<>(type, methods));
}
}
}