openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1081746 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/ portable/
Date Tue, 15 Mar 2011 12:34:24 GMT
Author: struberg
Date: Tue Mar 15 12:34:23 2011
New Revision: 1081746

URL: http://svn.apache.org/viewvc?rev=1081746&view=rev
Log:
OWB-545 OWB-503 reduce static method usage + SecurityService work

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
Tue Mar 15 12:34:23 2011
@@ -67,7 +67,7 @@ public class WebBeansContext
     private WebBeansUtil webBeansUtil = new WebBeansUtil(this);
     private ContextFactory contextFactory = new ContextFactory(this);
     private AlternativesManager alternativesManager = new AlternativesManager(this);
-    private AnnotatedElementFactory annotatedElementFactory = new AnnotatedElementFactory();
+    private AnnotatedElementFactory annotatedElementFactory = new AnnotatedElementFactory(this);
     private BeanManagerImpl beanManagerImpl = new BeanManagerImpl(this);
     private ConversationManager conversationManager = new ConversationManager(this);
     private CreationalContextFactory creationalContextFactory = new CreationalContextFactory(this);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Tue Mar 15 12:34:23 2011
@@ -25,6 +25,7 @@ import java.util.Set;
 
 import javax.enterprise.inject.spi.Annotated;
 
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.util.ClassUtil;
 
 /**
@@ -42,15 +43,19 @@ abstract class AbstractAnnotated impleme
     
     /**Set of annotations*/
     private Set<Annotation> annotations = new HashSet<Annotation>();
+
+    private WebBeansContext webBeansContext;
     
     /**
      * Createa a new annotated element.
-     * 
+     *
+     * @param webBeansContext our WebBeansContext
      * @param baseType annotated element type
      */
-    protected AbstractAnnotated(Type baseType)
+    protected AbstractAnnotated(WebBeansContext webBeansContext, Type baseType)
     {
         this.baseType = baseType;
+        this.webBeansContext = webBeansContext;
     }
 
     /**
@@ -62,7 +67,11 @@ abstract class AbstractAnnotated impleme
     {
         this.annotations.add(annotation);
     }
-    
+
+    protected WebBeansContext getWebBeansContext()
+    {
+        return webBeansContext;
+    }
 
     /**
      * Adds new annotation to set.

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedCallable.java
Tue Mar 15 12:34:23 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.portable;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Member;
 import java.lang.reflect.Type;
@@ -40,20 +42,9 @@ abstract class AbstractAnnotatedCallable
     /**Annotated parameters*/
     private List<AnnotatedParameter<X>> annotatedParameters = new ArrayList<AnnotatedParameter<X>>();
     
-    /**
-     * Creates a new instance.
-     * 
-     * @param baseType base type
-     * @param javaMember member
-     */
-    AbstractAnnotatedCallable(Type baseType, Member javaMember)
-    {
-        this(baseType, javaMember, null);
-    }
-    
-    AbstractAnnotatedCallable(Type baseType, Member javaMember, AnnotatedType<X> declaringType)
+    AbstractAnnotatedCallable(WebBeansContext webBeansContext, Type baseType, Member javaMember,
AnnotatedType<X> declaringType)
     {
-        super(baseType,javaMember,declaringType);
+        super(webBeansContext, baseType,javaMember,declaringType);
     }
     
     protected void setAnnotatedParameters(Type[] genericParameterTypes,Annotation[][] parameterAnnotations)
@@ -62,7 +53,7 @@ abstract class AbstractAnnotatedCallable
         
         for(Type genericParameter : genericParameterTypes)
         {
-            AnnotatedParameterImpl<X> parameterImpl = new AnnotatedParameterImpl<X>(genericParameter,this,i);
+            AnnotatedParameterImpl<X> parameterImpl = new AnnotatedParameterImpl<X>(getWebBeansContext(),
genericParameter,this,i);
             parameterImpl.setAnnotations(parameterAnnotations[i]);
             
             addAnnotatedParameter(parameterImpl);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
Tue Mar 15 12:34:23 2011
@@ -48,27 +48,16 @@ abstract class AbstractAnnotatedMember<X
     /**Member type*/
     protected final Member javaMember;
     
-    /**
-     * Creates a new instance.
-     * 
-     * @param baseType base type
-     * @param javaMember member
-     */
-    AbstractAnnotatedMember(Type baseType, Member javaMember)
-    {
-        this(baseType, javaMember, null);
-    }
-    
-    @SuppressWarnings("unchecked")    
-    AbstractAnnotatedMember(Type baseType, Member javaMember, AnnotatedType<X> declaringType)
+    @SuppressWarnings("unchecked")
+    AbstractAnnotatedMember(WebBeansContext webBeansContext, Type baseType, Member javaMember,
AnnotatedType<X> declaringType)
     {
-        super(baseType);
+        super(webBeansContext, baseType);
         
         this.javaMember = javaMember;
         
         if(declaringType == null)
         {
-            this.declaringType = (AnnotatedType<X>) WebBeansContext.getInstance().getAnnotatedElementFactory().newAnnotatedType(this.javaMember.getDeclaringClass());
+            this.declaringType = (AnnotatedType<X>) getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(this.javaMember.getDeclaringClass());
             
             AnnotatedTypeImpl<X> impl = (AnnotatedTypeImpl<X>)this.declaringType;
             

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
Tue Mar 15 12:34:23 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.portable;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import java.lang.reflect.Constructor;
 
 import javax.enterprise.inject.spi.AnnotatedConstructor;
@@ -35,23 +37,11 @@ class AnnotatedConstructorImpl<X> extend
     /**
      * Create a ew instance.
      * 
-     * @param baseType base type info
-     * @param javaMember constructor
-     */
-    AnnotatedConstructorImpl(Constructor<X> javaMember)
-    {
-        this(javaMember, null);
-    }
-    
-    /**
-     * Create a ew instance.
-     * 
-     * @param baseType base type info
      * @param javaMember constructor
      */
-    AnnotatedConstructorImpl(Constructor<X> javaMember, AnnotatedType<X> declaringType)
+    AnnotatedConstructorImpl(WebBeansContext webBeansContext, Constructor<X> javaMember,
AnnotatedType<X> declaringType)
     {        
-        super(javaMember.getDeclaringClass(), javaMember, declaringType);
+        super(webBeansContext, javaMember.getDeclaringClass(), javaMember, declaringType);
         setAnnotations(javaMember.getDeclaredAnnotations());
         setAnnotatedParameters(javaMember.getGenericParameterTypes(), javaMember.getParameterAnnotations());
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
Tue Mar 15 12:34:23 2011
@@ -66,12 +66,15 @@ public final class AnnotatedElementFacto
     //Cache of AnnotatedField
     private ConcurrentMap<Field, AnnotatedField<?>> annotatedFieldCache =
         new ConcurrentHashMap<Field, AnnotatedField<?>>();
+
+    private WebBeansContext webBeansContext;
     
     /**
      * No instantiate.
      */
-    public AnnotatedElementFactory()
+    public AnnotatedElementFactory(WebBeansContext webBeansContext)
     {
+        this.webBeansContext = webBeansContext;
     }
 
     /**
@@ -94,7 +97,7 @@ public final class AnnotatedElementFacto
         {
             try
             {
-                annotatedType = new AnnotatedTypeImpl<X>(annotatedClass);
+                annotatedType = new AnnotatedTypeImpl<X>(webBeansContext, annotatedClass);
 
                 AnnotatedTypeImpl<X> oldType = (AnnotatedTypeImpl<X>)annotatedTypeCache.putIfAbsent(annotatedClass,
annotatedType);
                 if(oldType != null)
@@ -153,7 +156,7 @@ public final class AnnotatedElementFacto
         }
         else
         {
-            annConstructor = new AnnotatedConstructorImpl<X>(constructor, declaringClass);
+            annConstructor = new AnnotatedConstructorImpl<X>(webBeansContext, constructor,
declaringClass);
             AnnotatedConstructorImpl<X> old = (AnnotatedConstructorImpl<X>)annotatedConstructorCache.putIfAbsent(constructor,
annConstructor);
             if(old != null)
             {
@@ -185,7 +188,7 @@ public final class AnnotatedElementFacto
         }
         else
         {
-            annotField = new AnnotatedFieldImpl<X>(field, declaringClass);
+            annotField = new AnnotatedFieldImpl<X>(webBeansContext, field, declaringClass);
             AnnotatedFieldImpl<X> old = (AnnotatedFieldImpl<X>) annotatedFieldCache.putIfAbsent(field,
annotField);
             if(old != null)
             {
@@ -217,7 +220,7 @@ public final class AnnotatedElementFacto
         }
         else
         {
-            annotMethod = new AnnotatedMethodImpl<X>(method, declaringType);
+            annotMethod = new AnnotatedMethodImpl<X>(webBeansContext, method, declaringType);
             AnnotatedMethodImpl<X> old = (AnnotatedMethodImpl<X>) annotatedMethodCache.putIfAbsent(method,
annotMethod);
             if(old != null)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
Tue Mar 15 12:34:23 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.portable;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import java.lang.reflect.Field;
 
 import javax.enterprise.inject.spi.AnnotatedField;
@@ -36,23 +38,12 @@ public class AnnotatedFieldImpl<X> exten
     /**
      * Creates a new instance
      * 
-     * @param baseType base type
-     * @param javaMember field
-     */
-    AnnotatedFieldImpl(Field javaMember)
-    {
-        this(javaMember, null);
-    }    
-    
-    /**
-     * Creates a new instance
-     * 
-     * @param baseType base type
+     * @param declaringType base type
      * @param javaMember field
      */
-    AnnotatedFieldImpl(Field javaMember, AnnotatedType<X> declaringType)
+    AnnotatedFieldImpl(WebBeansContext webBeansContext, Field javaMember, AnnotatedType<X>
declaringType)
     {
-        super(javaMember.getGenericType(), javaMember,declaringType);
+        super(webBeansContext, javaMember.getGenericType(), javaMember,declaringType);
         
         setAnnotations(javaMember.getDeclaredAnnotations());
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
Tue Mar 15 12:34:23 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.portable;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import java.lang.reflect.Method;
 
 import javax.enterprise.inject.spi.AnnotatedMethod;
@@ -36,24 +38,12 @@ class AnnotatedMethodImpl<X> extends Abs
     /**
      * Create a ew instance.
      * 
-     * @param baseType base type info
-     * @param javaMember method
-     */
-    AnnotatedMethodImpl(Method javaMember)
-    {
-        this(javaMember, null);
-    }
-    
-    /**
-     * Create a ew instance.
-     * 
-     * @param baseType base type info
      * @param declaringType declaring type
      * @param javaMember method
      */
-    AnnotatedMethodImpl(Method javaMember,AnnotatedType<X> declaringType)
+    AnnotatedMethodImpl(WebBeansContext webBeansContext, Method javaMember,AnnotatedType<X>
declaringType)
     {        
-        super(javaMember.getGenericReturnType(), javaMember,declaringType);
+        super(webBeansContext, javaMember.getGenericReturnType(), javaMember,declaringType);
         setAnnotations(javaMember.getDeclaredAnnotations());
         setAnnotatedParameters(javaMember.getGenericParameterTypes(), javaMember.getParameterAnnotations());
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java?rev=1081746&r1=1081745&r2=1081746&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
Tue Mar 15 12:34:23 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.portable;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import java.lang.reflect.Type;
 
 import javax.enterprise.inject.spi.AnnotatedCallable;
@@ -38,9 +40,9 @@ class AnnotatedParameterImpl<X> extends 
     /**Parameter position*/
     private final int position;
     
-    AnnotatedParameterImpl(Type baseType, AnnotatedCallable<X> declaringCallable, int
position)
+    AnnotatedParameterImpl(WebBeansContext webBeansContext, Type baseType, AnnotatedCallable<X>
declaringCallable, int position)
     {
-        super(baseType);
+        super(webBeansContext, baseType);
         this.declaringCallable = declaringCallable;
         this.position = position;
     }

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=1081746&r1=1081745&r2=1081746&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
Tue Mar 15 12:34:23 2011
@@ -18,7 +18,7 @@
  */
 package org.apache.webbeans.portable;
 
-import org.apache.webbeans.util.SecurityUtil;
+import org.apache.webbeans.config.WebBeansContext;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -58,9 +58,9 @@ class AnnotatedTypeImpl<X> extends Abstr
      * 
      * @param annotatedClass class
      */
-    AnnotatedTypeImpl(Class<X> annotatedClass)
+    AnnotatedTypeImpl(WebBeansContext webBeansContext, Class<X> annotatedClass)
     {
-        super(annotatedClass);        
+        super(webBeansContext, annotatedClass);
         this.annotatedClass = annotatedClass;     
         
         setAnnotations(annotatedClass.getDeclaredAnnotations());
@@ -74,24 +74,24 @@ class AnnotatedTypeImpl<X> extends Abstr
             fields = new HashSet<AnnotatedField<? super X>>();
             methods = new HashSet<AnnotatedMethod<? super X>>();
 
-            Field[] decFields = SecurityUtil.doPrivilegedGetDeclaredFields(annotatedClass);
-            Method[] decMethods = SecurityUtil.doPrivilegedGetDeclaredMethods(annotatedClass);
-            Constructor<X>[] decCtxs = SecurityUtil.doPrivilegedGetDeclaredConstructors(annotatedClass);
+            Field[] decFields = getWebBeansContext().getSecurityService().doPrivilegedGetDeclaredFields(annotatedClass);
+            Method[] decMethods = getWebBeansContext().getSecurityService().doPrivilegedGetDeclaredMethods(annotatedClass);
+            Constructor<?>[] decCtxs = getWebBeansContext().getSecurityService().doPrivilegedGetDeclaredConstructors(annotatedClass);
             for(Field f : decFields)
             {
-                AnnotatedField<X> af = new AnnotatedFieldImpl<X>(f, this);
+                AnnotatedField<X> af = new AnnotatedFieldImpl<X>(getWebBeansContext(),
f, this);
                 fields.add(af);
             }
 
             for(Method m : decMethods)
             {
-                AnnotatedMethod<X> am = new AnnotatedMethodImpl<X>(m,this);
+                AnnotatedMethod<X> am = new AnnotatedMethodImpl<X>(getWebBeansContext(),
m,this);
                 methods.add(am);
             }
 
-            for(Constructor<X> ct : decCtxs)
+            for(Constructor<?> ct : decCtxs)
             {
-                AnnotatedConstructor<X> ac = new AnnotatedConstructorImpl<X>(ct,this);
+                AnnotatedConstructor<X> ac = new AnnotatedConstructorImpl<X>(getWebBeansContext(),
(Constructor<X>) ct,this);
                 constructors.add(ac);
             }
         }



Mime
View raw message