openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1432510 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-impl/src/main/java/org/apache/webbeans/annotation/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src...
Date Sat, 12 Jan 2013 20:44:40 GMT
Author: arne
Date: Sat Jan 12 20:44:40 2013
New Revision: 1432510

URL: http://svn.apache.org/viewvc?rev=1432510&view=rev
Log:
OWB-748: Fixed Annotation inheritance and removed IBeanInheritedMetaData

Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inheritance/
Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
Sat Jan 12 20:44:40 2013
@@ -61,9 +61,6 @@ public abstract class BaseEjbBean<T> ext
         
         //type of the ejb
         this.ejbType = type;
-        
-        //Setting inherited meta data instance
-        setInheritedMetaData();
     }
 
 

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=1432510&r1=1432509&r2=1432510&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
Sat Jan 12 20:44:40 2013
@@ -79,6 +79,18 @@ public final class AnnotationManager
         beanManagerImpl = context.getBeanManagerImpl();
     }
 
+    public Annotation getDeclaredScopeAnnotation(Class<?> beanClass)
+    {
+        for (Annotation annotation : beanClass.getDeclaredAnnotations())
+        {
+            if (beanManagerImpl.isScope(annotation.annotationType()))
+            {
+                return annotation;
+            }
+        }
+        return null;
+    }
+
     /**
      * Returns true if the annotation is defined in xml or annotated with
      * {@link javax.interceptor.InterceptorBinding} or an InterceptorBinding
@@ -403,9 +415,33 @@ public final class AnnotationManager
      */
     public boolean isStereoTypeAnnotation(Class<? extends Annotation> clazz)
     {
+        return isStereoTypeAnnotation(clazz, new HashSet<Class<? extends Annotation>>());
+    }
+    
+    private boolean isStereoTypeAnnotation(Class<? extends Annotation> clazz, Set<Class<?
extends Annotation>> checkedAnnotations)
+    {
         Asserts.nullCheckForClass(clazz);
 
-        return clazz.isAnnotationPresent(Stereotype.class);
+        if (clazz.isAnnotationPresent(Stereotype.class))
+        {
+            return true;
+        }
+        else
+        {
+            for (Annotation annotation: clazz.getAnnotations())
+            {
+                if (checkedAnnotations.contains(annotation.annotationType()))
+                {
+                    continue;
+                }
+                checkedAnnotations.add(annotation.annotationType());
+                if (isStereoTypeAnnotation(annotation.annotationType(), checkedAnnotations))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
     }
 
     public boolean hasStereoTypeMetaAnnotation(Set<Class<? extends Annotation>>
anns)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
Sat Jan 12 20:44:40 2013
@@ -31,8 +31,6 @@ import javax.enterprise.inject.spi.Decor
 
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.config.inheritance.BeanInheritedMetaData;
-import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
@@ -71,9 +69,6 @@ public abstract class AbstractInjectionT
      */
     protected List<Decorator<?>> decorators = new ArrayList<Decorator<?>>();
     
-    /**Bean inherited meta data*/
-    protected IBeanInheritedMetaData inheritedMetaData;    
-    
     /**
      * Creates a new observer owner component.
      * 
@@ -329,22 +324,6 @@ public abstract class AbstractInjectionT
     /**
      * {@inheritDoc}
      */
-    public IBeanInheritedMetaData getInheritedMetaData()
-    {
-        return inheritedMetaData;
-    }
-    
-    /**
-     * Sets inherited meta data.
-     */
-    protected void setInheritedMetaData()
-    {
-        inheritedMetaData = new BeanInheritedMetaData<T>(this);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public AnnotatedType<T> getAnnotatedType()
     {
         return annotatedType;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
Sat Jan 12 20:44:40 2013
@@ -24,7 +24,6 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Decorator;
 
-import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
 import org.apache.webbeans.intercept.InterceptorData;
 
 /**
@@ -45,12 +44,6 @@ public interface InjectionTargetBean<T> 
     public void injectResources(T instance, CreationalContext<T> creationalContext);
 
     /**
-     * Gets inherited meta data.
-     * @return inherited meta data
-     */
-    public IBeanInheritedMetaData getInheritedMetaData();
-    
-    /**
      * Gets interceptor stack of bean instance.
      * @return interceptor stack
      */

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
Sat Jan 12 20:44:40 2013
@@ -60,9 +60,6 @@ public class ManagedBean<T> extends Abst
     public ManagedBean(WebBeansContext webBeansContext, Class<T> returnType, WebBeansType
type, AnnotatedType<T> annotatedType)
     {
         super(webBeansContext, type, returnType, annotatedType);
-        
-        //Setting inherited meta data instance
-        setInheritedMetaData();
     }
     
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
Sat Jan 12 20:44:40 2013
@@ -314,8 +314,6 @@ public abstract class AbstractBeanBuilde
             }
         }
         
-        defineInheritedQualifiers(qualifiers);
-
         // No-binding annotation
         if (qualifiers.size() == 0 )
         {
@@ -343,23 +341,6 @@ public abstract class AbstractBeanBuilde
         injectionPoints.add(member);
     }
 
-    protected void defineInheritedQualifiers(Set<Annotation> qualifiers)
-    {
-        // hook for subclasses
-    }
-    
-    protected void defineInheritedStereotypes(Set<Class<? extends Annotation>>
stereotypes)
-    {
-        // hook for subclasses
-    }
-    
-    protected Class<? extends Annotation> defineInheritedScope()
-    {
-        // hook for subclasses
-        return null;
-    }
-
-
     /**
      * Returns true if any binding exist
      * 
@@ -372,6 +353,11 @@ public abstract class AbstractBeanBuilde
 
     public void defineScopeType(String errorMessage)
     {
+        defineScopeType(null, errorMessage);
+    }
+
+    protected void defineScopeType(Class<?> declaringClass, String errorMessage)
+    {
         Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
         boolean found = false;
 
@@ -379,6 +365,10 @@ public abstract class AbstractBeanBuilde
         
         for (Annotation annotation : annotations)
         {   
+            if (declaringClass != null && AnnotationUtil.getDeclaringClass(annotation,
declaringClass) != null && !AnnotationUtil.isDeclaringClass(declaringClass, annotation))
+            {
+                continue;
+            }
             Class<? extends Annotation> annotationType = annotation.annotationType();
             
             /*Normal scope*/
@@ -438,17 +428,18 @@ public abstract class AbstractBeanBuilde
             }
         }
 
-        if (!found)
+        if (!found && declaringClass != null && !hasDeclaredNonInheritedScope(declaringClass))
+        {
+            defineScopeType(declaringClass.getSuperclass(), errorMessage);
+        }
+        else if (!found)
         {
             defineDefaultScopeType(errorMessage);
         }
     }
 
-
     private void defineDefaultScopeType(String exceptionMessage)
     {
-        scope = defineInheritedScope();
-        
         if (scope == null)
         {
             Set<Class<? extends Annotation>> stereos = stereotypes;
@@ -504,6 +495,11 @@ public abstract class AbstractBeanBuilde
         }
     }
 
+    private boolean hasDeclaredNonInheritedScope(Class<?> type)
+    {
+        return webBeansContext.getAnnotationManager().getDeclaredScopeAnnotation(type) !=
null;
+    }
+
     /**
      * Checks the unproxiable condition.
      * @throws WebBeansConfigurationException if bean is not proxied by the container
@@ -596,7 +592,6 @@ public abstract class AbstractBeanBuilde
                 stereotypes.add(stereo.annotationType());
             }
         }
-        defineInheritedStereotypes(stereotypes);
     }
 
     protected <X> void addFieldInjectionPointMetaData(OwbBean<T> bean, AnnotatedField<X>
annotField)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
Sat Jan 12 20:44:40 2013
@@ -54,7 +54,6 @@ import org.apache.webbeans.component.Pro
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.spi.api.ResourceReference;
@@ -273,6 +272,11 @@ public abstract class AbstractInjectionT
         }        
     }
 
+    public void defineScopeType(String errorMessage)
+    {
+        defineScopeType(getAnnotated().getJavaClass(), errorMessage);
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -697,78 +701,6 @@ public abstract class AbstractInjectionT
     }
 
     @Override
-    protected void defineInheritedQualifiers(Set<Annotation> qualifiers)
-    {
-        // Adding inherited qualifiers
-        IBeanInheritedMetaData inheritedMetaData = getBean().getInheritedMetaData();
-        
-        if (inheritedMetaData != null)
-        {
-            Set<Annotation> inheritedTypes = inheritedMetaData.getInheritedQualifiers();
-            for (Annotation inherited : inheritedTypes)
-            {
-                boolean found = false;
-                for (Annotation existQualifier : qualifiers)
-                {
-                    if (existQualifier.annotationType().equals(inherited.annotationType()))
-                    {
-                        found = true;
-                        break;
-                    }
-                }
-                if (!found)
-                {
-                    qualifiers.add(inherited);
-                }
-            }
-        }
-    }
-
-    @Override
-    protected void defineInheritedStereotypes(Set<Class<? extends Annotation>>
stereotypes)
-    {
-        // Adding inherited qualifiers
-        IBeanInheritedMetaData inheritedMetaData = getBean().getInheritedMetaData();
-        
-        if (inheritedMetaData != null)
-        {
-            Set<Annotation> inheritedTypes = inheritedMetaData.getInheritedStereoTypes();
       
-            for (Annotation inherited : inheritedTypes)
-            {
-                Set<Class<? extends Annotation>> qualifiers = stereotypes;
-                boolean found = false;
-                for (Class<? extends Annotation> existQualifier : qualifiers)
-                {
-                    if (existQualifier.equals(inherited.annotationType()))
-                    {
-                        found = true;
-                        break;
-                    }
-                }
-                if (!found)
-                {
-                    stereotypes.add(inherited.annotationType());
-                }
-            }
-        }
-    }
-    
-    @Override
-    protected Class<? extends Annotation> defineInheritedScope()
-    {
-        IBeanInheritedMetaData metaData = getBean().getInheritedMetaData();
-        if (metaData != null)
-        {
-            Annotation inheritedScope = metaData.getInheritedScopeType();
-            if (inheritedScope != null)
-            {
-                return inheritedScope.annotationType();
-            }
-        }
-        return null;
-    }
-
-    @Override
     protected Class<?> getBeanType()
     {
         return getAnnotated().getJavaClass();

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=1432510&r1=1432509&r2=1432510&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
Sat Jan 12 20:44:40 2013
@@ -23,7 +23,6 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptorBeanPleaseRemove;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
@@ -46,7 +45,6 @@ import javax.interceptor.AroundInvoke;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -205,49 +203,6 @@ public final class WebBeansInterceptorCo
         Annotation[] anns;
         Set<Interceptor<?>> componentInterceptors = null;
 
-        // Look for inherited binding types, keeping in mind that
-        // IBeanInheritedMetaData knows nothing of the transitive
-        // relationships of Interceptor Bindings or Stereotypes. We must resolve
-        // these here.
-        IBeanInheritedMetaData metadata = component.getInheritedMetaData();
-        if (metadata != null)
-        {
-            Set<Annotation> inheritedBindingTypes = metadata.getInheritedInterceptorBindings();
-            if (!inheritedBindingTypes.isEmpty())
-            {
-                Annotation[] inheritedAnns = new Annotation[inheritedBindingTypes.size()];
-                inheritedAnns = inheritedBindingTypes.toArray(inheritedAnns);
-                anns = annotationManager.getInterceptorBindingMetaAnnotations(inheritedAnns);
-                bindingTypeSet.addAll(Arrays.asList(anns));
-            }
-
-            // Retrieve inherited stereotypes, check for meta-annotations, and
-            // find the ultimate set of bindings
-            Set<Annotation> inheritedStereotypes = metadata.getInheritedStereoTypes();
-
-            if (!inheritedStereotypes.isEmpty())
-            {
-                // We need AnnotationUtil to resolve the transitive relationship
-                // of stereotypes we've found
-                Annotation[] inherited = new Annotation[inheritedStereotypes.size()];
-                inherited = inheritedStereotypes.toArray(inherited);
-                Annotation[] transitiveStereotypes = annotationManager.getStereotypeMetaAnnotations(inherited);
-
-                for (Annotation stereo : transitiveStereotypes)
-                {
-                    if (annotationManager.hasInterceptorBindingMetaAnnotation(stereo.annotationType().getDeclaredAnnotations()))
-                    {
-                        Annotation[] steroInterceptorBindings =
-                            annotationManager.getInterceptorBindingMetaAnnotations(stereo.annotationType().getDeclaredAnnotations());
-                        for (Annotation ann : steroInterceptorBindings)
-                        {
-                            bindingTypeSet.add(ann);
-                        }
-                    }
-                }
-            }
-        }
-
         anns = bindingTypeSet.toArray(new Annotation[bindingTypeSet.size()]);
 
         //Spec Section 9.5.2

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
Sat Jan 12 20:44:40 2013
@@ -18,14 +18,15 @@
  */
 package org.apache.webbeans.portable;
 
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.util.ClassUtil;
-
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Inherited;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedConstructor;
@@ -33,6 +34,9 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
 
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.util.ClassUtil;
+
 /**
  * Implementation of the {@link AnnotatedType} interface.
  * 
@@ -68,7 +72,29 @@ class AnnotatedTypeImpl<X> extends Abstr
         this.supertype = supertype;
         this.annotatedClass = annotatedClass;     
         
-        setAnnotations(annotatedClass.getDeclaredAnnotations());
+        if (supertype == null)
+        {
+            setAnnotations(annotatedClass.getDeclaredAnnotations());
+        }
+        else
+        {
+            Set<Class<? extends Annotation>> annotationTypes = new HashSet<Class<?
extends Annotation>>();
+            List<Annotation> annotations = new ArrayList<Annotation>();
+            for (Annotation annotation: annotatedClass.getDeclaredAnnotations())
+            {
+                annotations.add(annotation);
+                annotationTypes.add(annotation.annotationType());
+            }
+            for (Annotation annotation: supertype.getAnnotations())
+            {
+                if (annotation.annotationType().isAnnotationPresent(Inherited.class) &&
!annotationTypes.contains(annotation.annotationType()))
+                {
+                    annotations.add(annotation);
+                    annotationTypes.add(annotation.annotationType());
+                }
+            }
+            setAnnotations(annotations.toArray(new Annotation[annotations.size()]));
+        }
     }
 
     private synchronized void init()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java?rev=1432510&r1=1432509&r2=1432510&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
Sat Jan 12 20:44:40 2013
@@ -179,7 +179,7 @@ public class InjectionTargetImpl<T> exte
 
     private Constructor<T> getDefaultConstructor()
     {
-        return context.getSecurityService().doPrivilegedGetConstructor(type.getJavaClass());
+        return context.getWebBeansUtil().getNoArgConstructor(type.getJavaClass());
     }
     
     private boolean isProducerMethod(InjectionPoint injectionPoint)

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=1432510&r1=1432509&r2=1432510&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
Sat Jan 12 20:44:40 2013
@@ -53,6 +53,38 @@ public final class AnnotationUtil
     }
 
     /**
+     * Checks, if the given class declares the specified annotation
+     */
+    public static boolean isDeclaringClass(Class<?> declaringClass, Annotation declaredAnnotation)
+    {
+        for (Annotation annotation: declaringClass.getDeclaredAnnotations())
+        {
+            if (annotation.equals(declaredAnnotation))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns the declaring class for the specified annotation, using the specified type
hierarchy.
+     */
+    public static Class<?> getDeclaringClass(Annotation declaredAnnotation, Class<?>
typeHierarchy)
+    {
+        if (typeHierarchy == null)
+        {
+            return null;
+        }
+        if (isDeclaringClass(typeHierarchy, declaredAnnotation))
+        {
+            return typeHierarchy;
+        }
+        return getDeclaringClass(declaredAnnotation, typeHierarchy.getSuperclass());
+    }
+
+
+    /**
      * Check given annotation exist on the method.
      * 
      * @param method method



Mime
View raw message