openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r904938 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbeans/inject/ main/java/org/apache/webbeans/...
Date Sun, 31 Jan 2010 00:44:32 GMT
Author: gerdogdu
Date: Sun Jan 31 00:44:30 2010
New Revision: 904938

URL: http://svn.apache.org/viewvc?rev=904938&view=rev
Log:
[OWB-258] InjectionPoint meta-data injection into dependent beans not work  and some minor
issues

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/BrokenInitializerMethodBecauseofGeneric.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/BrokenInitializerMethodBecauseofGenericTest.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/InjectionPointMetaDataOwner.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/LoggerInjectedBean.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/LoggerQualifier.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/DependentProducerMethodInjectionPointTest.java
  (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.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/inject/impl/InjectionPointImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java

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=904938&r1=904937&r2=904938&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
Sun Jan 31 00:44:30 2010
@@ -20,9 +20,11 @@
 
 import javax.decorator.Delegate;
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
 
+import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.exception.WebBeansException;
@@ -34,6 +36,7 @@
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.plugins.OpenWebBeansResourcePlugin;
 import org.apache.webbeans.plugins.PluginLoader;
+import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -313,7 +316,18 @@
         {
             if (field.getAnnotation(Delegate.class) == null)
             {
-                injectField(field, instance, creationalContext);
+                if(!field.getType().equals(InjectionPoint.class))
+                {
+                    injectField(field, instance, creationalContext);   
+                }
+                //InjectionPoint.
+                else
+                {
+                    Bean<?> injectionPointBean = getManager().getBeans(InjectionPoint.class,
new DefaultLiteral()).iterator().next();
+                    Object reference = getManager().getReference(injectionPointBean, InjectionPoint.class,
getManager().createCreationalContext(injectionPointBean));
+                    
+                    ClassUtil.setField(instance, field, reference);
+                }
             }
         }                
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Sun Jan 31 00:44:30 2010
@@ -21,6 +21,7 @@
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
@@ -972,6 +973,12 @@
      */
     private static <T> void checkForInjectedInitializerMethod(AbstractInjectionTargetBean<T>
component, Class<T> clazz, Method method)
     {
+        TypeVariable<?>[] args = method.getTypeParameters();
+        if(args.length > 0)
+        {
+            throw new WebBeansConfigurationException("Initializer methods must not be generic
but method : " + method.getName() + " in bean class : " + clazz + " is defined as generic");
+        }
+        
         Annotation[][] anns = method.getParameterAnnotations();
         Type[] type = method.getGenericParameterTypes();
         for (int i = 0; i < anns.length; i++)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
Sun Jan 31 00:44:30 2010
@@ -23,6 +23,7 @@
 import java.util.Set;
 
 import javax.decorator.Delegate;
+import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.Decorator;
 
 import org.apache.webbeans.component.ManagedBean;
@@ -58,6 +59,17 @@
      */
     public static void checkDecoratorConditions(Class<?> decoratorClazz)
     {       
+        Asserts.assertNotNull(decoratorClazz, "Decorator class is null");
+        
+        Method[] methods = decoratorClazz.getDeclaredMethods();
+        for(Method method : methods)
+        {
+            if(AnnotationUtil.hasMethodAnnotation(method, Produces.class))
+            {
+                throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz
+ " can not have producer methods but it has one with name : " + method.getName());
+            }
+        }
+        
         Set<Type> decoratorSet = new HashSet<Type>();
         ClassUtil.setInterfaceTypeHierarchy(decoratorSet, decoratorClazz);
         

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
Sun Jan 31 00:44:30 2010
@@ -92,14 +92,14 @@
             EventBean.local.set(injectionPoint);
         }        
         
-        injected = BeanManagerImpl.getManager().getInjectableReference(injectionPoint, this.injectionOwnerCreationalContext);
-        
         //Injection for dependent instance InjectionPoint fields
         if(WebBeansUtil.isDependent(injectedBean))
         {
-            
-        }
+            InjectionPointBean.local.set(injectionPoint);
+        }        
         
+        injected = BeanManagerImpl.getManager().getInjectableReference(injectionPoint, this.injectionOwnerCreationalContext);
+                
 
         return injected;
     }
@@ -145,6 +145,7 @@
         return false;
     }
     
+    
     private boolean isEventProviderInjection(InjectionPoint injectionPoint)
     {
         Type type = injectionPoint.getType();
@@ -163,17 +164,6 @@
         return false;
     }
     
-    private boolean isInjectionPointInjection(InjectionPoint injectionPoint)
-    {
-        if(injectionPoint.getType().equals(InjectionPoint.class))
-        {
-            return true;
-        }
-        
-        return false;
-    }
-    
-    
     /**
      * Gets the component.
      * 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
Sun Jan 31 00:44:30 2010
@@ -20,9 +20,14 @@
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 
+import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractBean;
+import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.exception.WebBeansException;
 
 @SuppressWarnings("unchecked")
@@ -69,15 +74,34 @@
                 AnnotatedParameter<?> parameter = (AnnotatedParameter<?>)point.getAnnotated();
                 if(parameter.getPosition() == i)
                 {
-                    if(isDisposable() && parameter.getAnnotation(Disposes.class)
!= null)
+                    boolean injectionPoint = false;
+                    if(this.injectionOwnerBean instanceof ProducerMethodBean)
                     {
-                        list.add(this.producerMethodInstance);
+                        if(parameter.getBaseType().equals(InjectionPoint.class))
+                        {
+                            BeanManager manager = BeanManagerImpl.getManager();
+                            Bean<?> injectionPointBean = manager.getBeans(InjectionPoint.class,
new DefaultLiteral()).iterator().next();
+                            Object reference = manager.getReference(injectionPointBean, InjectionPoint.class,
manager.createCreationalContext(injectionPointBean));
+                            
+                            list.add(reference);
+                            
+                            injectionPoint = true;
+                        }
+   
                     }
-                    else
+                    
+                    if(!injectionPoint)
                     {
-                        list.add(inject(point));    
+                        if(isDisposable() && parameter.getAnnotation(Disposes.class)
!= null)
+                        {
+                            list.add(this.producerMethodInstance);
+                        }
+                        else
+                        {
+                            list.add(inject(point));    
+                        }                        
                     }
-                    
+                                        
                     break;
                 }
             }

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=904938&r1=904937&r2=904938&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 31 00:44:30 2010
@@ -18,11 +18,13 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
+import javax.decorator.Delegate;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.Annotated;
 import javax.enterprise.inject.spi.AnnotatedConstructor;
@@ -153,6 +155,16 @@
         
         
         injectionPoint = new InjectionPointImpl(owner, type, member, annotated);
+        
+        if(AnnotationUtil.hasAnnotation(annots, Delegate.class))
+        {
+            injectionPoint.setDelegate(true);
+        }
+        
+        if(Modifier.isTransient(member.getModifiers()))
+        {
+            injectionPoint.setTransient(true);
+        }
 
         addAnnotation(injectionPoint, qualifierAnnots, true);
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
Sun Jan 31 00:44:30 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.webbeans.inject.impl;
 
+import java.io.IOException;
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -23,13 +25,23 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.util.AnnotationLiteral;
 
-class InjectionPointImpl implements InjectionPoint
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.portable.AnnotatedElementFactory;
+import org.apache.webbeans.proxy.JavassistProxyFactory;
+import org.apache.webbeans.util.ClassUtil;
+
+class InjectionPointImpl implements InjectionPoint, Serializable
 {
     private Set<Annotation> qualifierAnnotations = new HashSet<Annotation>();
     
@@ -40,6 +52,10 @@
     private Type injectionType;
     
     private Annotated annotated;
+    
+    private boolean transientt;
+    
+    private boolean delegate;
 
     InjectionPointImpl(Bean<?> ownerBean, Type type, Member member, Annotated annotated)
     {
@@ -87,15 +103,130 @@
     @Override
     public boolean isDelegate()
     {
-        return false;
+        return this.delegate;
     }
 
     @Override
     public boolean isTransient()
     {
-        return false;
+        return this.transientt;
+    }
+    
+    void setDelegate(boolean delegate)
+    {
+        this.delegate = delegate;
+    }
+    
+    void setTransient(boolean transientt)
+    {
+        this.transientt = transientt;
     }
     
+    private void writeObject(java.io.ObjectOutputStream out) throws IOException
+    {
+        out.writeObject(this.ownerBean.getBeanClass());
+                
+        Set<Annotation> annotations = this.ownerBean.getQualifiers();
+        for(Annotation ann : annotations)
+        {
+            out.writeObject(ann.annotationType());
+        }
+        
+        out.writeObject(new Character('~'));
+        
+        if(this.injectionMember instanceof Field)
+        {
+            out.writeByte(0);
+            out.writeUTF(this.injectionMember.getName()); 
+        }
+        
+        if(this.injectionMember instanceof Method)
+        {
+            out.writeByte(1);
+            out.writeUTF(this.injectionMember.getName());
+            Method method = (Method)this.injectionMember;
+            Class<?>[] parameters = method.getParameterTypes();
+            out.writeObject(parameters);
+            
+            AnnotatedParameter<?> ap = (AnnotatedParameter<?>)this.annotated;
+            out.writeByte(ap.getPosition());
+            
+        }
+        
+        if(this.injectionMember instanceof Constructor)
+        {
+            out.writeByte(2);
+            Constructor<?> constr = (Constructor<?>)this.injectionMember;
+            Class<?>[] parameters = constr.getParameterTypes();
+            out.writeObject(parameters);
+            
+            AnnotatedParameter<?> ap = (AnnotatedParameter<?>)this.annotated;
+            out.writeByte(ap.getPosition());
+            
+        }
+        
+        out.writeBoolean(this.delegate);
+        out.writeBoolean(this.transientt);
+        
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+    {
+        Class<?> beanClass = (Class<?>)in.readObject();
+        Set<Annotation> anns = new HashSet<Annotation>();
+        while(!in.readObject().equals(new Character('~')))
+        {
+            Class<? extends Annotation> ann = (Class<Annotation>) in.readObject();
+            anns.add(JavassistProxyFactory.createNewAnnotationProxy(ann));
+        }
+        
+        this.ownerBean = BeanManagerImpl.getManager().getBeans(beanClass, anns.toArray(new
Annotation[0])).iterator().next();
+        this.qualifierAnnotations = anns;
+        
+        int c = in.readByte();
+        if(c == 0)
+        {
+            String fieldName = in.readUTF();
+            Field field = ClassUtil.getFieldWithName(beanClass, fieldName);
+            
+            this.injectionMember = field;
+            this.annotated = AnnotatedElementFactory.newAnnotatedField(field, beanClass);
+            this.injectionType = field.getGenericType();
+            
+        }
+        else if(c == 1)
+        {
+            String methodName = in.readUTF();
+            Class<?>[] parameters = (Class<?>[])in.readObject();
+            
+            Method method = ClassUtil.getDeclaredMethod(beanClass, methodName, parameters);
+            this.injectionMember = method;
+            
+            AnnotatedMethod<Object> am =  (AnnotatedMethod<Object>)AnnotatedElementFactory.newAnnotatedMethod((Method)this.injectionMember
,beanClass);
+            List<AnnotatedParameter<Object>> annParameters = am.getParameters();
+            
+            this.annotated = annParameters.get(in.readByte());            
+            this.injectionType = this.annotated.getBaseType();
+            
+        }
+        else if(c == 2)
+        {
+            Class<?>[] parameters = (Class<?>[])in.readObject();            
+            this.injectionMember = ClassUtil.getConstructor(beanClass, parameters);
+
+            AnnotatedConstructor<Object> am =  (AnnotatedConstructor<Object>)AnnotatedElementFactory.newAnnotatedConstructor((Constructor<?>)this.injectionMember);
+            List<AnnotatedParameter<Object>> annParameters = am.getParameters();
+            
+            this.annotated = annParameters.get(in.readByte());            
+            this.injectionType = this.annotated.getBaseType();
+        }
+        
+        this.delegate = in.readBoolean();
+        this.transientt = in.readBoolean();
+         
+    }
+
 
     public String toString()
     {
@@ -103,18 +234,18 @@
         if(injectionMember instanceof Constructor)
         {
             Constructor<?> constructor = (Constructor<?>) this.injectionMember;
-            buffer.append("Constructor Injection with name :  " + constructor.getName() +
"."+ ownerBean.toString());
+            buffer.append("Constructor Injection Point, constructor name :  " + constructor.getName()
+ ", Bean Owner : ["+ ownerBean.toString() + "]");
         }
         else if(injectionMember instanceof Method)
         {
             Method method = (Method)this.injectionMember;
-            buffer.append("Method Injection with name :  " + method.getName()  + "."+ ownerBean.toString());
+            buffer.append("Method Injection Point, method name :  " + method.getName() +
", Bean Owner : ["+ ownerBean.toString() + "]");
             
         }
         else if(injectionMember instanceof Field)
         {
             Field field = (Field) this.injectionMember;
-            buffer.append("Field Injection with name :  " + field.getName() + "." + ownerBean.toString());
           
+            buffer.append("Field Injection Point, field name :  " + field.getName() + ",
Bean Owner : ["+ ownerBean.toString() + "]");            
         }
         
         return buffer.toString();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
Sun Jan 31 00:44:30 2010
@@ -169,6 +169,16 @@
     public static void checkInterceptorConditions(Class<?> clazz)
     {
         Asserts.nullCheckForClass(clazz);
+        
+        Method[] methods = clazz.getDeclaredMethods();
+        for(Method method : methods)
+        {
+            if(AnnotationUtil.hasMethodAnnotation(method, Produces.class))
+            {
+                throw new WebBeansConfigurationException("Interceptor class : " + clazz +
" can not have producer methods but it has one with name : " + method.getName());
+            }
+        }
+        
         if (!AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
         {
             throw new WebBeansConfigurationException("WebBeans Interceptor class : " + clazz.getName()
+ " must have at least one @InterceptorBinding annotation");

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=904938&r1=904937&r2=904938&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Sun Jan 31 00:44:30 2010
@@ -1914,4 +1914,16 @@
             return null;
         }
     }
+    
+    public static Constructor<?> getConstructor(Class<?> clazz, Class<?>[]
parameterTypes)
+    {
+        try
+        {
+            return clazz.getConstructor(parameterTypes);
+            
+        }catch(NoSuchMethodException e)
+        {
+            return null;
+        }
+    }    
 }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/BrokenInitializerMethodBecauseofGeneric.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/BrokenInitializerMethodBecauseofGeneric.java?rev=904938&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/BrokenInitializerMethodBecauseofGeneric.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/BrokenInitializerMethodBecauseofGeneric.java
Sun Jan 31 00:44:30 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.concepts.initializerMethods.beans;
+
+import java.util.ArrayList;
+
+import javax.enterprise.inject.New;
+import javax.inject.Inject;
+
+public class BrokenInitializerMethodBecauseofGeneric
+{
+    @Inject
+    public <T> ArrayList<T> initializer(@New ArrayList<T> list)
+    {
+        return new ArrayList<T>();
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/beans/BrokenInitializerMethodBecauseofGeneric.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/BrokenInitializerMethodBecauseofGenericTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/BrokenInitializerMethodBecauseofGenericTest.java?rev=904938&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/BrokenInitializerMethodBecauseofGenericTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/BrokenInitializerMethodBecauseofGenericTest.java
Sun Jan 31 00:44:30 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.concepts.initializerMethods.tests;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.concepts.initializerMethods.beans.BrokenInitializerMethodBecauseofGeneric;
+import org.junit.Test;
+
+public class BrokenInitializerMethodBecauseofGenericTest extends AbstractUnitTest
+{
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testBrokenInitializerBecauseofGeneric()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(BrokenInitializerMethodBecauseofGeneric.class);
+        
+        try
+        {
+            startContainer(beanClasses, beanXmls);   
+        }        
+        finally
+        {
+            shutDownContainer();
+        }
+        
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/initializerMethods/tests/BrokenInitializerMethodBecauseofGenericTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/InjectionPointMetaDataOwner.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/InjectionPointMetaDataOwner.java?rev=904938&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/InjectionPointMetaDataOwner.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/InjectionPointMetaDataOwner.java
Sun Jan 31 00:44:30 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.injectionpoint.beans;
+
+import java.util.logging.Logger;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Named;
+
+import org.apache.webbeans.newtests.injection.injectionpoint.common.LoggerQualifier;
+
+@RequestScoped
+@Named("org.apache.webbeans.newtests.injection.injectionpoint.beans.InjectionPointMetaDataOwner")
+public class InjectionPointMetaDataOwner
+{
+    private InjectionPoint injectionPoint = null;
+    
+    @Produces @LoggerQualifier
+    public Logger getLogger(InjectionPoint injectionPoint)
+    {
+        this.injectionPoint = injectionPoint;
+        return Logger.getLogger(injectionPoint.getBean().getBeanClass().getName());
+    }
+    
+    
+    public InjectionPoint getInjectionPoint()
+    {
+        return this.injectionPoint;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/InjectionPointMetaDataOwner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/LoggerInjectedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/LoggerInjectedBean.java?rev=904938&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/LoggerInjectedBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/LoggerInjectedBean.java
Sun Jan 31 00:44:30 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.injectionpoint.beans;
+
+import java.util.logging.Logger;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.webbeans.newtests.injection.injectionpoint.common.LoggerQualifier;
+
+@RequestScoped
+@Named("org.apache.webbeans.newtests.injection.injectionpoint.beans.LoggerInjectedBean")
+public class LoggerInjectedBean
+{
+    private @Inject @LoggerQualifier Logger logger;
+    
+    public Logger getLogger()
+    {
+        return this.logger;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/beans/LoggerInjectedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/LoggerQualifier.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/LoggerQualifier.java?rev=904938&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/LoggerQualifier.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/LoggerQualifier.java
Sun Jan 31 00:44:30 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.newtests.injection.injectionpoint.common;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER
})
+public @interface LoggerQualifier {
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/common/LoggerQualifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/DependentProducerMethodInjectionPointTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/DependentProducerMethodInjectionPointTest.java?rev=904938&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/DependentProducerMethodInjectionPointTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/DependentProducerMethodInjectionPointTest.java
Sun Jan 31 00:44:30 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.injectionpoint.tests;
+
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.disposes.beans.DisposeModel;
+import org.apache.webbeans.newtests.injection.injectionpoint.beans.InjectionPointMetaDataOwner;
+import org.apache.webbeans.newtests.injection.injectionpoint.beans.LoggerInjectedBean;
+import org.junit.Test;
+
+public class DependentProducerMethodInjectionPointTest extends AbstractUnitTest
+{
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testDependentProducerMethodInjectionPoint()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(InjectionPointMetaDataOwner.class);
+        beanClasses.add(LoggerInjectedBean.class);
+        
+        startContainer(beanClasses, beanXmls);    
+        
+        Bean<LoggerInjectedBean> bean = (Bean<LoggerInjectedBean>)getBeanManager().getBeans(LoggerInjectedBean.class.getName()).iterator().next();
+        
+        CreationalContext<LoggerInjectedBean> cc = getBeanManager().createCreationalContext(bean);
+        LoggerInjectedBean model = (LoggerInjectedBean) getBeanManager().getReference(bean,
LoggerInjectedBean.class, cc);
+        
+        Assert.assertNotNull(model.getLogger());
+
+        Bean<InjectionPointMetaDataOwner> bean2 = (Bean<InjectionPointMetaDataOwner>)getBeanManager().getBeans(InjectionPointMetaDataOwner.class.getName()).iterator().next();
+        
+        CreationalContext<InjectionPointMetaDataOwner> cc2 = getBeanManager().createCreationalContext(bean2);
+        InjectionPointMetaDataOwner model2 = (InjectionPointMetaDataOwner) getBeanManager().getReference(bean2,
InjectionPointMetaDataOwner.class, cc2);
+        
+        InjectionPoint point = model2.getInjectionPoint();
+        Assert.assertTrue(point.getBean().equals(bean));
+        Assert.assertTrue(point.getMember() instanceof Field);
+        
+        shutDownContainer();
+
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/injectionpoint/tests/DependentProducerMethodInjectionPointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message