You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2013/01/06 16:35:46 UTC
svn commit: r1429542 - in /openwebbeans/trunk/webbeans-impl/src:
main/java/org/apache/webbeans/annotation/
main/java/org/apache/webbeans/component/creation/
main/java/org/apache/webbeans/container/
main/java/org/apache/webbeans/event/ main/java/org/apa...
Author: struberg
Date: Sun Jan 6 15:35:46 2013
New Revision: 1429542
URL: http://svn.apache.org/viewvc?rev=1429542&view=rev
Log:
OWB-344 implement decorator resolution
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java Sun Jan 6 15:35:46 2013
@@ -168,7 +168,7 @@ public final class AnnotationManager
*/
public Annotation[] getInterceptorBindingMetaAnnotations(Set<Annotation> anns)
{
- return getInterceptorBindingMetaAnnotations(AnnotationUtil.getAnnotationsFromSet(anns));
+ return getInterceptorBindingMetaAnnotations(AnnotationUtil.asSet(anns));
}
/**
@@ -241,7 +241,7 @@ public final class AnnotationManager
{
if(parameter.isAnnotationPresent(clazz))
{
- Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(parameter.getAnnotations());
+ Annotation[] anns = AnnotationUtil.asSet(parameter.getAnnotations());
for(Annotation ann : anns)
{
if(isQualifierAnnotation(ann.annotationType()))
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java Sun Jan 6 15:35:46 2013
@@ -70,7 +70,7 @@ public class AbstractBeanCreator<T>
* Creates a bean instance.
*
* @param bean bean instance
- * @param beanAnnotations annotations
+ * @param annotated
*/
public AbstractBeanCreator(AbstractOwbBean<T> bean, Annotated annotated)
{
@@ -106,7 +106,7 @@ public class AbstractBeanCreator<T>
public void defineName(String name)
{
- Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(getAnnotated().getAnnotations());
+ Annotation[] anns = AnnotationUtil.asSet(getAnnotated().getAnnotations());
Named nameAnnot = null;
boolean isDefault = false;
for (Annotation ann : anns)
@@ -152,7 +152,7 @@ public class AbstractBeanCreator<T>
*/
public void defineQualifiers()
{
- Annotation[] annotations = AnnotationUtil.getAnnotationsFromSet(annotated.getAnnotations());
+ Annotation[] annotations = AnnotationUtil.asSet(annotated.getAnnotations());
final AnnotationManager annotationManager = getBean().getWebBeansContext().getAnnotationManager();
for (Annotation annotation : annotations)
@@ -246,7 +246,7 @@ public class AbstractBeanCreator<T>
*/
public void defineScopeType(String errorMessage, boolean allowLazyInit)
{
- Annotation[] annotations = AnnotationUtil.getAnnotationsFromSet(annotated.getAnnotations());
+ Annotation[] annotations = AnnotationUtil.asSet(annotated.getAnnotations());
boolean found = false;
List<ExternalScope> additionalScopes = getBean().getWebBeansContext().getBeanManagerImpl().getAdditionalScopes();
@@ -458,7 +458,7 @@ public class AbstractBeanCreator<T>
*/
public void defineStereoTypes()
{
- Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(annotated.getAnnotations());
+ Annotation[] anns = AnnotationUtil.asSet(annotated.getAnnotations());
final AnnotationManager annotationManager = getBean().getWebBeansContext().getAnnotationManager();
if (annotationManager.hasStereoTypeMetaAnnotation(anns))
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java Sun Jan 6 15:35:46 2013
@@ -63,7 +63,7 @@ import org.apache.webbeans.util.ClassUti
import org.apache.webbeans.util.WebBeansUtil;
/**
- * Abstract implementation of {@link InjectionTargetBeanCreator}.
+ * Abstract implementation of {@link AbstractBeanCreator}.
*
* @version $Rev$ $Date$
*
@@ -230,7 +230,7 @@ public abstract class AbstractInjecionTa
}
Field field = annotatedField.getJavaMember();
- Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(annotatedField.getAnnotations());
+ Annotation[] anns = AnnotationUtil.asSet(annotatedField.getAnnotations());
if(Modifier.isPublic(field.getModifiers()))
{
if(!getBean().getScope().equals(Dependent.class))
@@ -323,7 +323,7 @@ public abstract class AbstractInjecionTa
for (AnnotatedParameter<T> annotatedParameter : annotatedParameters)
{
annotationManager.checkForNewQualifierForDeployment(annotatedParameter.getBaseType(), annotatedMethod.getDeclaringType().getJavaClass(),
- method.getName(), AnnotationUtil.getAnnotationsFromSet(annotatedParameter.getAnnotations()));
+ method.getName(), AnnotationUtil.asSet(annotatedParameter.getAnnotations()));
if(annotatedParameter.isAnnotationPresent(Disposes.class) ||
annotatedParameter.isAnnotationPresent(Observes.class))
@@ -443,7 +443,7 @@ public abstract class AbstractInjecionTa
}
}
- Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(annotatedField.getAnnotations());
+ Annotation[] anns = AnnotationUtil.asSet(annotatedField.getAnnotations());
Field field = annotatedField.getJavaMember();
//Producer field for resource
@@ -557,7 +557,7 @@ public abstract class AbstractInjecionTa
producerMethodBeanCreator.defineStereoTypes();
webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(getBean(),
producerMethodBean,
- AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
+ AnnotationUtil.asSet(annotatedMethod.getAnnotations()));
if (producerMethodBean.getReturnType().isArray())
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Sun Jan 6 15:35:46 2013
@@ -927,7 +927,7 @@ public class BeanManagerImpl implements
// check for InjectionPoint injection
if (rawType.equals(InjectionPoint.class))
{
- if (AnnotationUtil.hasAnnotation(AnnotationUtil.getAnnotationsFromSet(injectionPoint.getQualifiers()), Default.class))
+ if (AnnotationUtil.hasAnnotation(AnnotationUtil.asSet(injectionPoint.getQualifiers()), Default.class))
{
if (!bean.getScope().equals(Dependent.class))
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java Sun Jan 6 15:35:46 2013
@@ -455,7 +455,7 @@ public class ObserverMethodImpl<T> imple
//Get parameter annotations
Annotation[] bindingTypes =
annotationManager.getQualifierAnnotations(AnnotationUtil.
- getAnnotationsFromSet(parameter.getAnnotations()));
+ asSet(parameter.getAnnotations()));
InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, parameter.getBaseType(),
parameter.getDeclaringCallable().getJavaMember(), parameter, bindingTypes);
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java Sun Jan 6 15:35:46 2013
@@ -74,7 +74,7 @@ public class InjectionPointFactory
Asserts.assertNotNull(annotField, "annotField parameter can not be null");
Field member = annotField.getJavaMember();
- Annotation[] annots = AnnotationUtil.getAnnotationsFromSet(annotField.getAnnotations());
+ Annotation[] annots = AnnotationUtil.asSet(annotField.getAnnotations());
return getGenericInjectionPoint(owner, annots, annotField.getBaseType(), member, annotField);
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolution.java Sun Jan 6 15:35:46 2013
@@ -22,12 +22,15 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -78,7 +81,7 @@ public class InterceptorResolution
}
- public BeanInterceptorInfo calculateInterceptorInfo(AnnotatedType annotatedType)
+ public <T> BeanInterceptorInfo calculateInterceptorInfo(Bean<T> bean, AnnotatedType<T> annotatedType)
{
List<AnnotatedMethod> interceptableAnnotatedMethods = getInterceptableBusinessMethods(annotatedType);
@@ -88,48 +91,140 @@ public class InterceptorResolution
List<Interceptor> classLevelEjbInterceptors = new ArrayList<Interceptor>();
// pick up CDI interceptors from a class level
- //X TODO should work but can surely be improved!
- Set<Annotation> classInterceptorBindings
- = annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations());
+ Set<Annotation> classInterceptorBindings = annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations());
+
+ //X TODO pick up EJB-style interceptors from a class level
- //X TODO pick up EJB interceptors from a class level
//X TODO pick up the decorators
+ List<Decorator<?>> decorators = beanManager.resolveDecorators(bean.getTypes(), AnnotationUtil.asSet(bean.getQualifiers()));
Set<Interceptor<?>> allUsedCdiInterceptors = new HashSet<Interceptor<?>>();
Map<Method, MethodInterceptorInfo> businessMethodInterceptorInfos = new HashMap<Method, MethodInterceptorInfo>();
- // iterate over all methods and build up the CDI interceptor stack
- for (AnnotatedMethod interceptableAnnotatedMethod : interceptableAnnotatedMethods)
+ // iterate over all methods and build up the interceptor/decorator stack
+ for (AnnotatedMethod annotatedMethod : interceptableAnnotatedMethods)
{
- Set<Annotation> cummulatedInterceptorBindings = new HashSet<Annotation>();
- cummulatedInterceptorBindings.addAll(
- annotationManager.getInterceptorAnnotations(interceptableAnnotatedMethod.getAnnotations()));
+ InterceptionType interceptionType = calculateInterceptionType(annotatedMethod);
+ MethodInterceptorInfo methodInterceptorInfo = new MethodInterceptorInfo(interceptionType);
- cummulatedInterceptorBindings.addAll(classInterceptorBindings);
+ calculateCdiMethodInterceptors(methodInterceptorInfo, allUsedCdiInterceptors, annotatedMethod, classInterceptorBindings);
- if (cummulatedInterceptorBindings.size() == 0)
+ calculateCdiMethodDecorators(methodInterceptorInfo, decorators, annotatedMethod);
+
+ if (methodInterceptorInfo.isEmpty())
{
continue;
}
- InterceptionType interceptionType = calculateInterceptionType(interceptableAnnotatedMethod);
- MethodInterceptorInfo methodInterceptorInfo = new MethodInterceptorInfo(interceptionType);
+ if (InterceptionType.AROUND_INVOKE.equals(interceptionType))
+ {
+ businessMethodInterceptorInfos.put(annotatedMethod.getJavaMember(), methodInterceptorInfo);
+ }
+ }
+
+ return new BeanInterceptorInfo(null, allUsedCdiInterceptors, businessMethodInterceptorInfos);
+ }
- List<Interceptor<?>> methodInterceptors
- = beanManager.resolveInterceptors(interceptionType, AnnotationUtil.getAnnotationsFromSet(cummulatedInterceptorBindings));
- methodInterceptorInfo.setCdiInterceptors(methodInterceptors);
+ private void calculateCdiMethodDecorators(MethodInterceptorInfo methodInterceptorInfo, List<Decorator<?>> decorators, AnnotatedMethod annotatedMethod)
+ {
+ if (decorators == null || decorators.isEmpty())
+ {
+ return;
+ }
- allUsedCdiInterceptors.addAll(methodInterceptors);
+ Set<Decorator<?>> appliedDecorators = new HashSet<Decorator<?>>();
- if (interceptionType.equals(InterceptionType.AROUND_INVOKE))
+ for (Decorator decorator : decorators)
+ {
+ isDecoratorInterceptsMethod(decorator, annotatedMethod, appliedDecorators);
+ }
+
+ if (appliedDecorators.size() > 0)
+ {
+ methodInterceptorInfo.setMethodDecorators(new ArrayList<Decorator<?>>(appliedDecorators));
+ }
+ }
+
+ private boolean isDecoratorInterceptsMethod(Decorator decorator, AnnotatedMethod annotatedMethod, Set<Decorator<?>> appliedDecorators)
+ {
+ String annotatedMethodName = annotatedMethod.getJavaMember().getName();
+
+ Set<Type> decoratedTypes = decorator.getDecoratedTypes();
+ for (Type decoratedType : decoratedTypes)
+ {
+ if (decoratedType instanceof Class)
{
- businessMethodInterceptorInfos.put(interceptableAnnotatedMethod.getJavaMember(), methodInterceptorInfo);
+ Class decoratedClass = (Class) decoratedType;
+ Method[] decoratorMethods = decoratedClass.getDeclaredMethods();
+ for (Method decoratorMethod : decoratorMethods)
+ {
+ int modifiers = decoratorMethod.getModifiers();
+ if (Modifier.isFinal(modifiers) ||
+ Modifier.isPrivate(modifiers) ||
+ Modifier.isStatic(modifiers))
+ {
+ continue;
+ }
+
+ if (decoratorMethod.getName().equals(annotatedMethodName))
+ {
+ Class<?>[] decoratorMethodParams = decoratorMethod.getParameterTypes();
+ Class<?>[] annotatedMethodParams = annotatedMethod.getJavaMember().getParameterTypes();
+ if (decoratorMethodParams.length == annotatedMethodParams.length)
+ {
+ boolean paramsMatch = true;
+ for (int i = 0; i < decoratorMethodParams.length; i++)
+ {
+ if (!decoratorMethodParams[i].equals(annotatedMethodParams[i]))
+ {
+ paramsMatch = false;
+ break;
+ }
+ }
+
+ if (paramsMatch)
+ {
+ // yikes our method is decorated by this very decorator type.
+ appliedDecorators.add(decorator);
+ return true;
+ }
+ }
+ }
+ }
}
}
- return new BeanInterceptorInfo(null, allUsedCdiInterceptors, businessMethodInterceptorInfos);
+ return false;
+
+ }
+
+ private void calculateCdiMethodInterceptors(MethodInterceptorInfo methodInterceptorInfo,
+ Set<Interceptor<?>> allUsedCdiInterceptors,
+ AnnotatedMethod annotatedMethod,
+ Set<Annotation> classInterceptorBindings)
+ {
+ AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
+
+ Set<Annotation> cummulatedInterceptorBindings = new HashSet<Annotation>();
+ cummulatedInterceptorBindings.addAll(
+ annotationManager.getInterceptorAnnotations(annotatedMethod.getAnnotations()));
+
+ cummulatedInterceptorBindings.addAll(classInterceptorBindings);
+
+ if (cummulatedInterceptorBindings.size() == 0)
+ {
+ return;
+ }
+
+ List<Interceptor<?>> methodInterceptors
+ = webBeansContext.getBeanManagerImpl().resolveInterceptors(methodInterceptorInfo.getInterceptionType(),
+ AnnotationUtil.asSet(cummulatedInterceptorBindings));
+
+ methodInterceptorInfo.setCdiInterceptors(methodInterceptors);
+
+ allUsedCdiInterceptors.addAll(methodInterceptors);
}
@@ -335,5 +430,13 @@ public class InterceptorResolution
}
}
+
+ /**
+ * Determine if any interceptor information has been set at all.
+ */
+ public boolean isEmpty()
+ {
+ return cdiInterceptors == null && ejbInterceptors == null && methodDecorators == null;
+ }
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java Sun Jan 6 15:35:46 2013
@@ -305,7 +305,7 @@ public final class WebBeansInterceptorCo
Method method = methodB.getJavaMember();
Set<Annotation> interceptorAnns = new HashSet<Annotation>();
- Annotation[] methodAnns = AnnotationUtil.getAnnotationsFromSet(methodB.getAnnotations());
+ Annotation[] methodAnns = AnnotationUtil.asSet(methodB.getAnnotations());
if (annotationManager.hasInterceptorBindingMetaAnnotation(methodAnns))
{
Annotation[] anns =
@@ -313,7 +313,7 @@ public final class WebBeansInterceptorCo
methodAnns);
Annotation[] annsClazz =
annotationManager.getInterceptorBindingMetaAnnotations(
- AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()));
+ AnnotationUtil.asSet(annotatedType.getAnnotations()));
for (Annotation ann : anns)
{
@@ -328,7 +328,7 @@ public final class WebBeansInterceptorCo
Annotation[] stereoTypes =
annotationManager.getStereotypeMetaAnnotations(
- AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()));
+ AnnotationUtil.asSet(annotatedType.getAnnotations()));
for (Annotation stero : stereoTypes)
{
if (annotationManager.hasInterceptorBindingMetaAnnotation(
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java Sun Jan 6 15:35:46 2013
@@ -655,7 +655,7 @@ public final class AnnotationUtil
return null;
}
- public static Annotation[] getAnnotationsFromSet(Set<Annotation> set)
+ public static Annotation[] asSet(Set<Annotation> set)
{
if(set != null)
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sun Jan 6 15:35:46 2013
@@ -1943,7 +1943,7 @@ public final class WebBeansUtil
if (component instanceof EnterpriseBeanMarker)
{
beans = new HashSet<Bean<?>>();
- Set<Bean<?>> allBeans = ((BeanManagerImpl)(manager)).getBeans(Object.class, AnnotationUtil.getAnnotationsFromSet(component.getQualifiers()));
+ Set<Bean<?>> allBeans = ((BeanManagerImpl)(manager)).getBeans(Object.class, AnnotationUtil.asSet(component.getQualifiers()));
for(Bean<?> candidateBean : allBeans)
{
@@ -1964,7 +1964,7 @@ public final class WebBeansUtil
else
{
beans = manager.getBeans(component.getBeanClass(),
- AnnotationUtil.getAnnotationsFromSet(component.getQualifiers()));
+ AnnotationUtil.asSet(component.getQualifiers()));
}
for(Bean<?> bean : beans)
@@ -2080,7 +2080,7 @@ public final class WebBeansUtil
{
ProducerMethodBean<?> bean = beanEntry.getKey();
AnnotatedMethod<?> annotatedMethod = beanEntry.getValue();
- Annotation[] annotationsFromSet = AnnotationUtil.getAnnotationsFromSet(bean.getQualifiers());
+ Annotation[] annotationsFromSet = AnnotationUtil.asSet(bean.getQualifiers());
Method disposal = annotationManager.getDisposalWithGivenAnnotatedMethod(annotatedType, bean.getReturnType(), annotationsFromSet);
AnnotatedMethod<?> disposalAnnotated = null;
@@ -2705,7 +2705,7 @@ public final class WebBeansUtil
private <X> void checkManagedWebBeansInterceptorConditions(AnnotatedType<X> type)
{
- Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(type.getAnnotations());
+ Annotation[] anns = AnnotationUtil.asSet(type.getAnnotations());
Class<?> clazz = type.getJavaClass();
boolean hasClassInterceptors = false;
@@ -2746,7 +2746,7 @@ public final class WebBeansUtil
}
if (annotationManager.hasInterceptorBindingMetaAnnotation(
- AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
+ AnnotationUtil.asSet(methodA.getAnnotations())))
{
throw new WebBeansConfigurationException("Method : " + method.getName() + "in managed bean class : " + clazz.getName()
+ " can not be defined as non-static, non-private and final . Because it is annotated with at least one @InterceptorBinding");
Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java?rev=1429542&r1=1429541&r2=1429542&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorResolutionTest.java Sun Jan 6 15:35:46 2013
@@ -19,6 +19,7 @@
package org.apache.webbeans.newtests.interceptors.resolution;
import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
@@ -63,8 +64,9 @@ public class InterceptorResolutionTest
InterceptorResolution ir = new InterceptorResolution(getWebBeansContext());
AnnotatedType<ClassInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(ClassInterceptedClass.class);
+ Bean<ClassInterceptedClass> bean = (Bean<ClassInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(ClassInterceptedClass.class));
- InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(annotatedType);
+ InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
Assert.assertNotNull(interceptorInfo);
Assert.assertNotNull(interceptorInfo.getInterceptors());
@@ -103,8 +105,9 @@ public class InterceptorResolutionTest
InterceptorResolution ir = new InterceptorResolution(getWebBeansContext());
AnnotatedType<ClassMultiInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(ClassMultiInterceptedClass.class);
+ Bean<ClassMultiInterceptedClass> bean = (Bean<ClassMultiInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(ClassMultiInterceptedClass.class));
- InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(annotatedType);
+ InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
Assert.assertNotNull(interceptorInfo);
Assert.assertNotNull(interceptorInfo.getInterceptors());
@@ -141,8 +144,9 @@ public class InterceptorResolutionTest
InterceptorResolution ir = new InterceptorResolution(getWebBeansContext());
AnnotatedType<MethodInterceptedClass> annotatedType = getBeanManager().createAnnotatedType(MethodInterceptedClass.class);
+ Bean<MethodInterceptedClass> bean = (Bean<MethodInterceptedClass>) getBeanManager().resolve(getBeanManager().getBeans(MethodInterceptedClass.class));
- InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(annotatedType);
+ InterceptorResolution.BeanInterceptorInfo interceptorInfo = ir.calculateInterceptorInfo(bean, annotatedType);
Assert.assertNotNull(interceptorInfo);
Assert.assertNotNull(interceptorInfo.getInterceptors());