You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by db...@apache.org on 2011/01/06 10:35:32 UTC

svn commit: r1055805 [2/2] - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/annotation/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/corespi/ main/java/org/apache/...

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=1055805&r1=1055804&r2=1055805&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Thu Jan  6 09:35:31 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.webbeans.util;
 
+import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.annotation.DependentScopeLiteral;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.AbstractOwbBean;
@@ -230,6 +231,7 @@ public final class WebBeansAnnotatedType
     @SuppressWarnings("unchecked")
     public static <X> void defineDisposalMethods(AbstractInjectionTargetBean<X> bean,AnnotatedType<X> annotatedType)
     {
+        final AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
         Set<AnnotatedMethod<? super X>> annotatedMethods = annotatedType.getMethods();    
         ProducerMethodBean<?> previous = null;
         for (AnnotatedMethod<? super X> annotatedMethod : annotatedMethods)
@@ -251,7 +253,7 @@ public final class WebBeansAnnotatedType
             {
                 checkProducerMethodDisposal(annotatedMethod);
                 Type type = AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Disposes.class);
-                Annotation[] annot = AnnotationUtil.getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(annotatedMethod, Disposes.class);
+                Annotation[] annot = annotationManager.getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(annotatedMethod, Disposes.class);
 
                 Set<Bean<?>> set = InjectionResolver.getInstance().implResolveByType(type, annot);
                 if (set.isEmpty())
@@ -337,6 +339,8 @@ public final class WebBeansAnnotatedType
     
     public static <X> void defineInjectedFields(AbstractInjectionTargetBean<X> bean,AnnotatedType<X> annotatedType)
     {
+        AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
+
         Set<AnnotatedField<? super X>> annotatedFields = annotatedType.getFields();   
         for(AnnotatedField<? super X> annotatedField: annotatedFields)
         {
@@ -360,9 +364,9 @@ public final class WebBeansAnnotatedType
                     throw new WebBeansConfigurationException("Error in annotated field : " + annotatedField
                                                     +" while definining injected field. If bean has a public modifier injection point, bean scope must be defined as @Dependent");
                 }
-            }                
-            
-            Annotation[] qualifierAnns = AnnotationUtil.getQualifierAnnotations(anns);
+            }
+
+            Annotation[] qualifierAnns = annotationManager.getQualifierAnnotations(anns);
 
             if (qualifierAnns.length > 0)
             {
@@ -713,16 +717,17 @@ public final class WebBeansAnnotatedType
 
         Class<?> clazz = type.getJavaClass();
         boolean hasClassInterceptors = false;
-        if (AnnotationUtil.getInterceptorBindingMetaAnnotations(anns).length > 0)
+        AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
+        if (annotationManager.getInterceptorBindingMetaAnnotations(anns).length > 0)
         {
             hasClassInterceptors = true;
         }
         else
         {
-            Annotation[] stereoTypes = AnnotationUtil.getStereotypeMetaAnnotations(anns);
+            Annotation[] stereoTypes = annotationManager.getStereotypeMetaAnnotations(anns);
             for (Annotation stero : stereoTypes)
             {
-                if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(stero.annotationType().getDeclaredAnnotations()))
+                if (annotationManager.hasInterceptorBindingMetaAnnotation(stero.annotationType().getDeclaredAnnotations()))
                 {
                     hasClassInterceptors = true;
                     break;
@@ -748,7 +753,8 @@ public final class WebBeansAnnotatedType
                                                     + " can not define non-static, non-private final methods. Because it is annotated with at least one @InterceptorBinding");
                 }
 
-                if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
+                if (annotationManager.hasInterceptorBindingMetaAnnotation(
+                    AnnotationUtil.getAnnotationsFromSet(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");
@@ -964,7 +970,8 @@ public final class WebBeansAnnotatedType
     public static <T> void defineInterceptor(AnnotatedType<T> annotatedType)
     {
         Class<?> clazz = annotatedType.getJavaClass();
-        if (WebBeansContext.getInstance().getInterceptorsManager().isInterceptorEnabled(clazz))
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        if (webBeansContext.getInterceptorsManager().isInterceptorEnabled(clazz))
         {
             ManagedBean<T> delegate = null;
 
@@ -973,8 +980,10 @@ public final class WebBeansAnnotatedType
 
             if (delegate != null)
             {
-                WebBeansInterceptorConfig.configureInterceptorClass(delegate, 
-                        AnnotationUtil.getInterceptorBindingMetaAnnotations(annotatedType.getAnnotations().toArray(new Annotation[0])));
+                Annotation[] anns = annotatedType.getAnnotations().toArray(new Annotation[0]);
+                AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
+                WebBeansInterceptorConfig.configureInterceptorClass(delegate,
+                                                                    annotationManager.getInterceptorBindingMetaAnnotations(anns));
             }
             else
             {
@@ -992,6 +1001,8 @@ public final class WebBeansAnnotatedType
     {
         Set<AnnotatedMethod<? super X>> annotatedMethods = annotatedType.getMethods();  
         
+        final AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
+        
         if(annotatedMethods != null)
         {
             for (AnnotatedMethod<? super X> annotatedMethod : annotatedMethods)
@@ -1013,7 +1024,7 @@ public final class WebBeansAnnotatedType
                     if(found)
                     {
                         Type type = AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Disposes.class);
-                        Annotation[] annots = AnnotationUtil.getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(annotatedMethod, Disposes.class);
+                        Annotation[] annots = annotationManager.getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(annotatedMethod, Disposes.class);
                         
                         if(type.equals(beanType))
                         {

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=1055805&r1=1055804&r2=1055805&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 Thu Jan  6 09:35:31 2011
@@ -99,6 +99,7 @@ import javax.interceptor.InvocationConte
 
 import javassist.util.proxy.ProxyFactory;
 
+import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.ApplicationScopeLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
@@ -587,7 +588,7 @@ public final class WebBeansUtil
         Asserts.nullCheckForClass(clazz);
         Asserts.assertNotNull(annotations, "Annotations argument can not be null");
 
-        Annotation[] as = AnnotationUtil.getQualifierAnnotations(annotations);
+        Annotation[] as = WebBeansContext.getInstance().getAnnotationManager().getQualifierAnnotations(annotations);
         for (Annotation a : annotations)
         {
             if (a.annotationType().equals(New.class))
@@ -1419,7 +1420,7 @@ public final class WebBeansUtil
         Set<Annotation> set = component.getOwbStereotypes();
         Annotation[] anns = new Annotation[set.size()];
         anns = set.toArray(anns);
-        if (AnnotationUtil.hasStereoTypeMetaAnnotation(anns))
+        if (WebBeansContext.getInstance().getAnnotationManager().hasStereoTypeMetaAnnotation(anns))
         {
             return true;
         }
@@ -1441,7 +1442,7 @@ public final class WebBeansUtil
             Annotation[] anns = new Annotation[set.size()];
             anns = set.toArray(anns);
 
-            return AnnotationUtil.getStereotypeMetaAnnotations(anns);
+            return WebBeansContext.getInstance().getAnnotationManager().getStereotypeMetaAnnotations(anns);
         }
 
         return new Annotation[] {};
@@ -1532,6 +1533,7 @@ public final class WebBeansUtil
     {
         Asserts.nullCheckForClass(clazz);
 
+        AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
         boolean scopeTypeFound = false;
         for (Annotation annotation : annotations)
         {
@@ -1558,7 +1560,7 @@ public final class WebBeansUtil
                             "annotation with value");
                 }
             }
-            else if (AnnotationUtil.isInterceptorBindingAnnotation(annotType))
+            else if (annotationManager.isInterceptorBindingAnnotation(annotType))
             {
                 Target target = clazz.getAnnotation(Target.class);
                 ElementType[] type = target.value();
@@ -2142,7 +2144,8 @@ public final class WebBeansUtil
         }
         else
         {
-            Annotation[] anns = AnnotationUtil.getStereotypeMetaAnnotations(superMethod.getAnnotations());
+            Annotation[] anns = WebBeansContext.getInstance().getAnnotationManager().getStereotypeMetaAnnotations(
+                superMethod.getAnnotations());
             for(Annotation ann : anns)
             {
                 if(ann.annotationType().isAnnotationPresent(Stereotype.class))
@@ -2196,10 +2199,13 @@ public final class WebBeansUtil
                     "array argument can not be empty");
         }
 
+        AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
+
         Annotation old = null;
         for (Annotation interceptorBinding : interceptorBindings)
         {
-            if (!AnnotationUtil.isInterceptorBindingAnnotation(interceptorBinding.annotationType()))
+            if (!annotationManager.isInterceptorBindingAnnotation(
+                interceptorBinding.annotationType()))
             {
                 throw new IllegalArgumentException("Manager.resolveInterceptors() method parameter interceptor" +
                         " bindings array can not contain other annotation that is not @InterceptorBinding");
@@ -2231,10 +2237,12 @@ public final class WebBeansUtil
                     "can not be empty");
         }
 
+        AnnotationManager annotationManager = WebBeansContext.getInstance().getAnnotationManager();
+        
         Annotation old = null;
         for (Annotation qualifier : qualifiers)
         {
-            if (!AnnotationUtil.isQualifierAnnotation(qualifier.annotationType()))
+            if (!annotationManager.isQualifierAnnotation(qualifier.annotationType()))
             {
                 throw new IllegalArgumentException("Manager.resolveDecorators() method parameter qualifiers array " +
                         "can not contain other annotation that is not @Qualifier");
@@ -2331,7 +2339,8 @@ public final class WebBeansUtil
             if (component != null)
             {
                 WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>) component,
-                        AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getDeclaredAnnotations()));
+                                                                    WebBeansContext.getInstance().getAnnotationManager().getInterceptorBindingMetaAnnotations(
+                                                                        clazz.getDeclaredAnnotations()));
             }
         }
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java?rev=1055805&r1=1055804&r2=1055805&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java Thu Jan  6 09:35:31 2011
@@ -71,7 +71,6 @@ import org.apache.webbeans.test.sterotyp
 import org.apache.webbeans.test.sterotype.StereoWithSessionScope;
 import org.apache.webbeans.test.sterotype.StereoWithSessionScope2;
 import org.apache.webbeans.test.unittests.xml.XMLTest;
-import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 import org.apache.webbeans.xml.XMLUtil;
@@ -428,8 +427,9 @@ public abstract class TestContext implem
         WebBeansContext.getInstance().getInterceptorsManager().addNewInterceptor(clazz);
         InterceptorUtil.checkInterceptorConditions(clazz);
         component = ManagedBeanConfigurator.define(clazz, WebBeansType.INTERCEPTOR);
-        WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>) component, 
-                AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getDeclaredAnnotations()));
+        WebBeansInterceptorConfig.configureInterceptorClass((ManagedBean<Object>) component,
+                                                            WebBeansContext.getInstance().getAnnotationManager().getInterceptorBindingMetaAnnotations(
+                                                                clazz.getDeclaredAnnotations()));
 
 
         return component;