openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r900037 - in /openwebbeans/trunk: samples/guess/ samples/reservation/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/contain...
Date Sun, 17 Jan 2010 00:25:35 GMT
Author: gerdogdu
Date: Sun Jan 17 00:25:34 2010
New Revision: 900037

URL: http://svn.apache.org/viewvc?rev=900037&view=rev
Log:
[OWB-235] Pass TCK Event Tests

Modified:
    openwebbeans/trunk/samples/guess/pom.xml
    openwebbeans/trunk/samples/reservation/pom.xml
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/events/MyExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java

Modified: openwebbeans/trunk/samples/guess/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/guess/pom.xml?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/samples/guess/pom.xml (original)
+++ openwebbeans/trunk/samples/guess/pom.xml Sun Jan 17 00:25:34 2010
@@ -99,7 +99,7 @@
        
               <dependency>
                  <groupId>org.apache.geronimo.specs</groupId>
-                 <artifactId>geronimo-cdi_1.0_spec</artifactId>
+                 <artifactId>geronimo-jcdi_1.0_spec</artifactId>
                  <version>${geronimo_cdi.version}</version>
               </dependency>
 

Modified: openwebbeans/trunk/samples/reservation/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/reservation/pom.xml?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/samples/reservation/pom.xml (original)
+++ openwebbeans/trunk/samples/reservation/pom.xml Sun Jan 17 00:25:34 2010
@@ -140,7 +140,7 @@
 				
 		         <dependency>
 		                 <groupId>org.apache.geronimo.specs</groupId>
-		                 <artifactId>geronimo-cdi_1.0_spec</artifactId>
+		                 <artifactId>geronimo-jcdi_1.0_spec</artifactId>
 		                 <version>${geronimo_cdi.version}</version>
 		         </dependency>
 		

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java Sun Jan 17 00:25:34 2010
@@ -14,12 +14,15 @@
 package org.apache.webbeans.component;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
+import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.util.TypeLiteral;
 
+import org.apache.webbeans.event.EventImpl;
 import org.apache.webbeans.exception.WebBeansException;
 
 /**
@@ -27,9 +30,9 @@
  * 
  * @version $Rev$ $Date$
  */
-public class EventBean<T> extends AbstractBean<T>
+public class EventBean<T> extends AbstractBean<Event<T>>
 {
-    private Type eventType = null;
+    public static ThreadLocal<InjectionPoint> local = new ThreadLocal<InjectionPoint>();
 
     /**
      * Creates a new instance of event bean.
@@ -38,48 +41,52 @@
      * @param eventType event type
      * @param definedType webbeans type
      */
-    public EventBean(Class<T> returnType, Type eventType, WebBeansType definedType)
+    public EventBean()
     {
-        super(definedType,returnType);
-        this.eventType = eventType;
+        super(WebBeansType.OBSERVABLE,new TypeLiteral<Event<T>>(){}.getRawType());
     }
     
     /**
      * {@inheritDoc}
      */
     @Override
-    protected T createInstance(CreationalContext<T> creationalContext)
+    protected Event<T> createInstance(CreationalContext<Event<T>> creationalContext)
     {
-        Set<Annotation> setQualifiers = getQualifiers();
-        Annotation[] qualifiers = new Annotation[setQualifiers.size()];
+        Event<T> instance = null;
 
-        qualifiers = setQualifiers.toArray(qualifiers);
-
-        T instance = null;
-
-        try
+        InjectionPoint injectionPoint = local.get();
+        Type eventType = null;
+        
+        if(injectionPoint != null)
         {
-            Constructor<T> constructor = null;
-            constructor = returnType.getConstructor(new Class<?>[] { Annotation[].class, Type.class });
-
-            instance = constructor.newInstance(new Object[] { qualifiers, eventType });
+            Type[] eventActualTypeArgs = new Type[0];
+            Type type = injectionPoint.getType();                        
+            ParameterizedType pt = (ParameterizedType) type;
+            eventActualTypeArgs = pt.getActualTypeArguments();
+
+            //First argument and sole argument is actual Event type
+            //Example : Event<MyEvent>
+            eventType = eventActualTypeArgs[0];
+            
+            //Event qualifiers
+            Annotation[] qualifiers = new Annotation[injectionPoint.getQualifiers().size()];
+            qualifiers = injectionPoint.getQualifiers().toArray(qualifiers);
+            
+            try
+            {
+                instance = new EventImpl<T>(qualifiers, eventType);
+            }
+            catch (Exception e)
+            {
+                throw new WebBeansException("Exception in creating Event implicit component for event type : " + eventType);
+            }           
+            finally
+            {
+                local.set(null);
+            }
+            
         }
-        catch (Exception e)
-        {
-            throw new WebBeansException("Exception in creating Event implicit component for event type : " + eventType);
-        }
-
+                        
         return instance;
-
-    }
-
-    /**
-     * Returns the event type.
-     * 
-     * @return the eventType
-     */
-    public Type getEventType()
-    {
-        return eventType;
     }
-}
\ No newline at end of file
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Sun Jan 17 00:25:34 2010
@@ -192,14 +192,19 @@
     
     private void configureDefaultBeans()
     {
+        BeanManagerImpl beanManager = BeanManagerImpl.getManager();
+        
         // Register Conversation built-in component
-        BeanManagerImpl.getManager().addBean(WebBeansUtil.getConversationBean());
+        beanManager.addBean(WebBeansUtil.getConversationBean());
         
         // Register InjectionPoint bean
-        BeanManagerImpl.getManager().addBean(WebBeansUtil.getInjectionPointBean());
+        beanManager.addBean(WebBeansUtil.getInjectionPointBean());
         
         //Register Instance Bean
-        BeanManagerImpl.getManager().addBean(WebBeansUtil.getInstanceBean());        
+        beanManager.addBean(WebBeansUtil.getInstanceBean());
+        
+        //Register Event Bean
+        beanManager.addBean(WebBeansUtil.getEventBean());
     }
     
     /**
@@ -678,7 +683,11 @@
             managedBeanCreator.defineDecoratorStack();
             managedBeanCreator.defineInterceptorStack();
             
-            Set<ObserverMethod<?>> observerMethods = managedBeanCreator.defineObserverMethods();
+            Set<ObserverMethod<?>> observerMethods = new HashSet<ObserverMethod<?>>();
+            if(managedBean.isEnabled())
+            {
+                observerMethods = managedBeanCreator.defineObserverMethods();
+            }
                                     
             //Fires ProcessInjectionTarget
             ProcessInjectionTargetImpl<T> processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(managedBean);            

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=900037&r1=900036&r2=900037&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 17 00:25:34 2010
@@ -1045,6 +1045,17 @@
         {
 
             EventUtil.checkObserverMethodConditions(candidateMethod, clazz);
+            AbstractBean<?> bean = (AbstractBean<?>) component;
+            if(bean.getScope().equals(Dependent.class))
+            {
+                //Check Reception
+                if(EventUtil.isReceptionIfExist(candidateMethod))
+                {
+                    throw new WebBeansConfigurationException("Dependent Bean : " + bean + " can not define observer method with @Receiver = IF_EXIST");
+                }
+            }
+            
+            
             component.addObservableMethod(candidateMethod);
 
             addMethodInjectionPointMetaData((AbstractBean<T>) component, candidateMethod);
@@ -1099,7 +1110,8 @@
         }        
         else if(EventUtil.checkObservableInjectionPointConditions(injectionPoint))
         {            
-            WebBeansUtil.addInjectedImplicitEventComponent(injectionPoint);
+            //Do nothing
+            //WebBeansUtil.addInjectedImplicitEventComponent(injectionPoint);
         }
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Sun Jan 17 00:25:34 2010
@@ -920,6 +920,11 @@
     @Override
     public <T> Set<ObserverMethod<? super T>> resolveObserverMethods( T event, Annotation... qualifiers ) 
     {
+        if(ClassUtil.isDefinitionConstainsTypeVariables(event.getClass()))
+        {
+            throw new IllegalArgumentException("Event type can not contain type variables. Event class is : " + event.getClass());
+        }
+        
         return this.notificationManager.resolveObservers(event, qualifiers);
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Sun Jan 17 00:25:34 2010
@@ -21,6 +21,7 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import javax.enterprise.event.Event;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.New;
 import javax.enterprise.inject.spi.Bean;
@@ -175,19 +176,15 @@
      */
     public Bean<?> getInjectionPointBean(InjectionPoint injectionPoint)
     {
-        Type type = injectionPoint.getType();
-        
+
+        Type type = injectionPoint.getType();        
         Class<?> clazz = null;
-        boolean injectInstanceProvider = false;
+        
         if (type instanceof ParameterizedType)
         {
             ParameterizedType pt = (ParameterizedType) type;            
             clazz = (Class<?>) pt.getRawType();
                         
-            if(clazz.isAssignableFrom(Instance.class))
-            {
-                injectInstanceProvider = true;
-            }
             
         }
         else
@@ -195,18 +192,13 @@
             clazz = (Class<?>) type;
         }
         
-        Annotation[] qualifiers = new Annotation[1]; 
-            
-        if(injectInstanceProvider)
+        Annotation[] qualifiers = injectionPoint.getQualifiers().toArray(new Annotation[0]);        
+        if(isInstanceOrEventInjection(type))
         {
+            qualifiers = new Annotation[1];
             qualifiers[0] = new AnyLiteral();
         }
-        else
-        {
-            qualifiers = new Annotation[injectionPoint.getQualifiers().size()];
-            qualifiers = injectionPoint.getQualifiers().toArray(qualifiers);            
-        }
-
+        
         Set<Bean<?>> beanSet = implResolveByType(type, qualifiers);
         
         if(beanSet.isEmpty())
@@ -233,6 +225,26 @@
         return beanSet.iterator().next();
         
     }    
+    
+    
+    private boolean isInstanceOrEventInjection(Type type)
+    {
+        Class<?> clazz = null;
+        boolean injectInstanceOrEventProvider = false;
+        if (type instanceof ParameterizedType)
+        {
+            ParameterizedType pt = (ParameterizedType) type;            
+            clazz = (Class<?>) pt.getRawType();
+                        
+            if(clazz.isAssignableFrom(Instance.class) || clazz.isAssignableFrom(Event.class))
+            {
+                injectInstanceOrEventProvider = true;
+            }            
+        }
+        
+        return injectInstanceOrEventProvider;
+    }
+    
         
     /**
      * Returns set of beans for given bean name.
@@ -343,12 +355,21 @@
 
         boolean currentQualifier = false;
         boolean returnAll = false;
-
-        if (qualifier.length == 0)
+        
+        if(isInstanceOrEventInjection(injectionPointType))
         {
             qualifier = new Annotation[1];
-            qualifier[0] = new DefaultLiteral();
-            currentQualifier = true;
+            qualifier[0] = new AnyLiteral();
+        }
+        
+        else
+        {
+            if (qualifier.length == 0)
+            {
+                qualifier = new Annotation[1];
+                qualifier[0] = new DefaultLiteral();
+                currentQualifier = true;
+            }                        
         }
         
         if (injectionPointType.equals(Object.class) && currentQualifier)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java Sun Jan 17 00:25:34 2010
@@ -13,10 +13,12 @@
  */
 package org.apache.webbeans.event;
 
+import java.io.IOException;
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
 
 import javax.enterprise.event.Event;
 import javax.enterprise.util.TypeLiteral;
@@ -33,7 +35,7 @@
  * @param <T> event type
  * @see Event
  */
-public class EventImpl<T> implements Event<T>
+public class EventImpl<T> implements Event<T>, Serializable
 {
     /**Event binding types*/
     private Annotation[] injectedBindings;
@@ -42,7 +44,7 @@
     private Type eventType;
 
     /**Bean manager*/
-    private BeanManagerImpl manager = null;
+    private transient BeanManagerImpl manager = null;
 
     /**
      * Creates a new event.
@@ -75,7 +77,13 @@
     {
         AnnotationUtil.checkQualifierConditions(annotations);
         
-        List<Annotation> eventBindings = new ArrayList<Annotation>();
+        Set<Annotation> eventBindings = new HashSet<Annotation>();
+        
+        for(Annotation ann : this.injectedBindings)
+        {
+            eventBindings.add(ann);
+        }
+        
         Annotation[] anns = null;
 
         for (Annotation binding : annotations)
@@ -132,4 +140,10 @@
     {
         return select(subtype.getRawType(), bindings);
     }
+    
+    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+    {
+        in.defaultReadObject();
+        this.manager = BeanManagerImpl.getManager();
+    }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java Sun Jan 17 00:25:34 2010
@@ -14,6 +14,8 @@
 package org.apache.webbeans.event;
 
 import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -21,6 +23,7 @@
 
 import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
 import javax.enterprise.event.TransactionPhase;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
@@ -56,6 +59,18 @@
 
     public static void checkEventBindings(Annotation... annotations)
     {
+        for(Annotation ann : annotations)
+        {
+            //This is added, because TCK Event tests for this.
+            Retention retention = ann.annotationType().getAnnotation(Retention.class);
+            RetentionPolicy policy = retention.value();
+            if(!policy.equals(RetentionPolicy.RUNTIME))
+            {
+                throw new IllegalArgumentException("Event qualifiere RetentionPolicy must be RUNTIME for qualifier : " + ann);
+            }
+            ///////////////////////////////////////////////////////
+
+        }        
         AnnotationUtil.checkQualifierConditions(annotations);
     }
 
@@ -89,25 +104,19 @@
         if (AnnotationUtil.hasMethodParameterAnnotation(candidateObserverMethod, Disposes.class))
         {
             throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName() + " can not annotated with annotation @Disposes");
+        }                
+    }
+    
+    public static boolean isReceptionIfExist(Method observerMethod)
+    {
+        Observes observes = AnnotationUtil.getMethodFirstParameterAnnotation(observerMethod, Observes.class);
+        Reception reception = observes.notifyObserver();
+        if(reception.equals(Reception.IF_EXISTS))
+        {
+            return true;
         }
 
-//        Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(candidateObserverMethod, Observes.class);
-//        
-//        Class<?> eventType = null;
-//       
-//        if (type instanceof ParameterizedType)
-//        {
-//            eventType = (Class<?>) ((ParameterizedType) type).getRawType();
-//        }
-//        else
-//        {
-//            eventType = (Class<?>) type;
-//        }
-
-//        if (ClassUtil.isDefinitionConstainsTypeVariables(eventType))
-//        {
-//            throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName() + " can not defined as generic");
-//        }
+        return false;
     }
 
 
@@ -153,17 +162,18 @@
                 {                                        
                     if(typeArgs.length == 1)
                     {
-                        Type actualArgument = typeArgs[0];
-                        
-                        if(ClassUtil.isParametrizedType(actualArgument) || ClassUtil.isWildCardType(actualArgument) || ClassUtil.isTypeVariable(actualArgument))
-                        {                            
-                            throw new IllegalArgumentException("@Observable field injection " + injectionPoint.toString() + " actual type argument can not be Parametrized, Wildcard type or Type variable");                            
-                        }
-                                                
-                        if(ClassUtil.isDefinitionConstainsTypeVariables((Class<?>)actualArgument))
-                        {
-                            throw new IllegalArgumentException("@Observable field injection " + injectionPoint.toString() + " must not have TypeVariable or WildCard generic type argument");                            
-                        }
+                        //TCK does not check those! Also specification not talk about them.
+//                        Type actualArgument = typeArgs[0];
+//                        
+//                        if(ClassUtil.isParametrizedType(actualArgument) || ClassUtil.isWildCardType(actualArgument) || ClassUtil.isTypeVariable(actualArgument))
+//                        {                            
+//                            throw new IllegalArgumentException("@Observable field injection " + injectionPoint.toString() + " actual type argument can not be Parametrized, Wildcard type or Type variable");                            
+//                        }
+//                                                
+//                        if(ClassUtil.isDefinitionConstainsTypeVariables((Class<?>)actualArgument))
+//                        {
+//                            throw new IllegalArgumentException("@Observable field injection " + injectionPoint.toString() + " must not have TypeVariable or WildCard generic type argument");                            
+//                        }
                     }
                     else
                     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java Sun Jan 17 00:25:34 2010
@@ -20,8 +20,10 @@
 package org.apache.webbeans.event;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Map;
@@ -32,14 +34,13 @@
 import javax.enterprise.event.Observes;
 import javax.enterprise.event.Reception;
 import javax.enterprise.event.TransactionPhase;
-import javax.enterprise.inject.Any;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.util.TypeLiteral;
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
 import javax.transaction.Transaction;
 
-import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.container.BeanManagerImpl;
@@ -51,6 +52,7 @@
 import org.apache.webbeans.util.ArrayUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.WebBeansUtil;
 
 @SuppressWarnings("unchecked")
 public final class NotificationManager
@@ -91,7 +93,7 @@
     {
         EventUtil.checkEventType(typeLiteral.getRawType());
 
-        addObserver(observer, typeLiteral.getRawType());
+        addObserver(observer, typeLiteral.getType());
     }
 
     public <T> void removeObserver(ObserverMethod<T> observer, Class<T> eventType, Annotation... annotations)
@@ -101,7 +103,7 @@
 
         if (observers.containsKey(eventType))
         {
-            Set<ObserverMethod<?>> set = observers.get(eventType);
+            Set<ObserverMethod<?>> set = this.observers.get(eventType);
             for (ObserverMethod<?> ob : set)
             {
                 Set<Annotation> evenBindings = ob.getObservedQualifiers();
@@ -125,7 +127,7 @@
     {
         EventUtil.checkEventBindings(eventQualifiers);
 
-        Set<Annotation> qualifiers = toQualiferSet(eventQualifiers);
+        Set<Annotation> qualifiers = ArrayUtil.asSet(eventQualifiers);
 
         Class<T> eventType = (Class<T>) event.getClass();
         // EventUtil.checkEventType(eventType);
@@ -139,10 +141,31 @@
 
     private <T> Set<ObserverMethod<? super T>> filterByType(Class<T> eventType)
     {
+        if(WebBeansUtil.isExtensionEventType(eventType))
+        {
+            return filterByExtensionEventType(eventType);
+        }
+        
         Set<ObserverMethod<? super T>> matching = new HashSet<ObserverMethod<? super T>>();
 
         Set<Type> types = new HashSet<Type>();
-        ClassUtil.setTypeHierarchy(types, eventType);
+        types.add(eventType);
+        
+        Type superClazz = eventType.getGenericSuperclass();
+        if(superClazz != null)
+        {
+            types.add(superClazz);    
+        }
+        
+        Type[] genericInts = eventType.getGenericInterfaces();
+        
+        if(genericInts != null && genericInts.length > 0)
+        {
+            for(Type genericInt : genericInts)
+            {
+                types.add(genericInt);
+            }            
+        }
 
         Set<Type> keySet = this.observers.keySet();
 
@@ -150,7 +173,7 @@
         {
             for (Type check : types)
             {
-                if (ClassUtil.isAssignable(check, type))
+                if (ClassUtil.checkEventTypeAssignability(check, type))
                 {
                     Set<ObserverMethod<?>> wrappers = this.observers.get(type);
 
@@ -164,6 +187,45 @@
         }
         return matching;
     }
+    
+    private <T> Set<ObserverMethod<? super T>> filterByExtensionEventType(Class<T> eventType)
+    {
+        Set<ObserverMethod<? super T>> matching = new HashSet<ObserverMethod<? super T>>();
+        
+        Set<Type> keySet = this.observers.keySet();
+
+        for (Type type : keySet)
+        {
+            Class<?> clazz = null;
+            
+            if(ClassUtil.isTypeVariable(type))
+            {
+                TypeVariable<?> tvBeanTypeArg = (TypeVariable<?>)type;
+                Type tvBound = tvBeanTypeArg.getBounds()[0];
+                
+                clazz = ClassUtil.getClass(tvBound);
+            }
+            
+            if(clazz == null)
+            {
+                clazz = ClassUtil.getClazz(type);    
+            }
+            
+            if(clazz.isAssignableFrom(eventType))
+            {
+                Set<ObserverMethod<?>> wrappers = this.observers.get(type);
+
+                for (ObserverMethod<?> wrapper : wrappers)
+                {
+                    matching.add((ObserverMethod<T>) wrapper);
+                }
+                break;                
+            }
+        }
+        
+        return matching;
+        
+    }
 
     /**
      * filter out all {@code ObserverMethod}s which do not fit the given
@@ -171,11 +233,8 @@
      */
     private <T> Set<ObserverMethod<? super T>> filterByQualifiers(Set<ObserverMethod<? super T>> observers, Set<Annotation> eventQualifiers)
     {
-        if (eventQualifiers.size() == 1 && eventQualifiers.iterator().next() instanceof Any)
-        {
-            return observers;
-        }
-
+        eventQualifiers.add(new AnyLiteral());
+                
         Set<ObserverMethod<? super T>> matching = new HashSet<ObserverMethod<? super T>>();
 
         search: for (ObserverMethod<? super T> ob : observers)
@@ -186,10 +245,21 @@
             {
                 continue;
             }
+            
 
             for (Annotation qualifier : qualifiers)
             {
-                if (!eventQualifiers.contains(qualifier))
+                boolean found = false;
+                for(Annotation inList : eventQualifiers)
+                {
+                    if(AnnotationUtil.hasAnnotationMember(qualifier.annotationType(), inList, qualifier))
+                    {
+                        found = true;
+                        break;
+                    }
+                }
+                
+                if(!found)
                 {
                     continue search;
                 }
@@ -242,13 +312,20 @@
             }
             catch (WebBeansException e)
             {
-                if (!RuntimeException.class.isAssignableFrom(e.getCause().getClass()))
+                Throwable exc = e.getCause();
+                if(exc instanceof InvocationTargetException)
+                {
+                    InvocationTargetException invt = (InvocationTargetException)exc;
+                    exc = invt.getCause();
+                }
+                
+                if (!RuntimeException.class.isAssignableFrom(exc.getClass()))
                 {
                     throw new ObserverException(logger.getTokenString(OWBLogConst.EXCEPT_0008) + event.getClass().getName(), e);
                 }
                 else
                 {
-                    RuntimeException rte = (RuntimeException) e.getCause();
+                    RuntimeException rte = (RuntimeException) exc;
                     throw rte;
                 }
             }
@@ -283,9 +360,9 @@
 
             ObserverMethodImpl<T> observer = new ObserverMethodImpl(component, observableMethod, ifExist);
 
-            Class<T> clazz = (Class<T>) AnnotationUtil.getMethodFirstParameterTypeClazzWithAnnotation(observableMethod, Observes.class);
+            Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(observableMethod, Observes.class);
 
-            addObserver(observer, clazz);
+            addObserver(observer, type);
             
             observerMethods.add(observer);
         }
@@ -293,21 +370,6 @@
         return observerMethods;
     }
 
-    /**
-     * Converts the given qualifiers array to a Set. This function additionally
-     * fixes @Default and @Any conditions.
-     */
-    private static Set<Annotation> toQualiferSet(Annotation... qualifiers)
-    {
-        Set<Annotation> set = ArrayUtil.asSet(qualifiers);
-
-        if (qualifiers.length == 0)
-        {
-            set.add(new DefaultLiteral());
-        }
-
-        return set;
-    }
 
     private static class AbstractSynchronization<T> implements Synchronization
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java Sun Jan 17 00:25:34 2010
@@ -39,6 +39,7 @@
 
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractBean;
+import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.container.BeanManagerImpl;
@@ -117,7 +118,7 @@
         {
             observedQualifiers.add(qualifier);
         }
-
+        
         this.observedEventType = AnnotationUtil.getTypeOfParameterWithGivenAnnotation(observerMethod, Observes.class);
         
         this.phase = EventUtil.getObserverMethodTransactionType(observerMethod);
@@ -163,49 +164,52 @@
         
         try
         {
-            BeanManagerImpl manager = BeanManagerImpl.getManager();
-            specializedComponent = (AbstractBean<Object>)WebBeansUtil.getMostSpecializedBean(manager, baseComponent);        
-            Context context = manager.getContext(specializedComponent.getScope());
-            
-            creationalContext = manager.createCreationalContext(specializedComponent);
+            Object[] args = null;
             
-            if(this.ifExist)
-            {
-                object = context.get(specializedComponent);
-            }
-            else
+            List<Object> argsObjects = getMethodArguments(event);
+            args = new Object[argsObjects.size()];
+            args = argsObjects.toArray(args);
+
+            if (!this.observerMethod.isAccessible())
             {
-                object = manager.getInstance(specializedComponent, creationalContext);    
+                this.observerMethod.setAccessible(true);
             }
             
-
-            if (this.ifExist && object == null)
+            //Static or not
+            if (Modifier.isStatic(this.observerMethod.getModifiers()))
             {
-                return;
+                //Invoke Method
+                this.observerMethod.invoke(object, args);
             }
-
-            if (object != null)
+            else
             {
-                Object[] args = null;
+                BeanManagerImpl manager = BeanManagerImpl.getManager();
+                specializedComponent = (AbstractBean<Object>)WebBeansUtil.getMostSpecializedBean(manager, baseComponent);        
+                Context context = manager.getContext(specializedComponent.getScope());
                 
-                List<Object> argsObjects = getMethodArguments(event);
-                args = new Object[argsObjects.size()];
-                args = argsObjects.toArray(args);
-
-                if (!this.observerMethod.isAccessible())
+                creationalContext = manager.createCreationalContext(specializedComponent);
+                
+                if(this.ifExist)
+                {
+                    object = context.get(specializedComponent);
+                }
+                else
                 {
-                    this.observerMethod.setAccessible(true);
+                    object = manager.getReference(specializedComponent, specializedComponent.getBeanClass(), creationalContext);
                 }
+                
 
-                //Static or not
-                if (Modifier.isStatic(this.observerMethod.getModifiers()))
+                if (this.ifExist && object == null)
                 {
-                    object = null;
+                    return;
                 }
 
-                //Invoke Method
-                this.observerMethod.invoke(object, args);
-            }
+                if (object != null)
+                {
+                    //Invoke Method
+                    this.observerMethod.invoke(object, args);
+                }
+            }                        
         }
         catch (Exception e)
         {
@@ -294,9 +298,11 @@
      * 
      * @return the bean
      */
+    @SuppressWarnings("unchecked")
     public Class<?> getBeanClass()
     {
-        return bean.getClass();
+        AbstractInjectionTargetBean<T> abs = (AbstractInjectionTargetBean<T>)this.bean;
+        return abs.getBeanClass();
     }
 
     /** 

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=900037&r1=900036&r2=900037&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 17 00:25:34 2010
@@ -21,12 +21,14 @@
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Event;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.apache.webbeans.component.AbstractBean;
+import org.apache.webbeans.component.EventBean;
 import org.apache.webbeans.component.InstanceBean;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectionResolver;
@@ -91,6 +93,11 @@
             InstanceBean.local.set(injectionPoint);
         }
         
+        else if(isEventProviderInjection(injectionPoint))
+        {
+            EventBean.local.set(injectionPoint);
+        }
+        
         //Get injection point Bean to look for @Dependent
         Bean<?> injectedBean = InjectionResolver.getInstance().getInjectionPointBean(injectionPoint);
         
@@ -214,6 +221,25 @@
         return false;
     }
     
+    private boolean isEventProviderInjection(InjectionPoint injectionPoint)
+    {
+        Type type = injectionPoint.getType();
+        
+        if (type instanceof ParameterizedType)
+        {
+            ParameterizedType pt = (ParameterizedType) type;            
+            Class<?> clazz = (Class<?>) pt.getRawType();
+            
+            if(clazz.isAssignableFrom(Event.class))
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    
     
     /**
      * Gets the component.

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=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java Sun Jan 17 00:25:34 2010
@@ -276,6 +276,7 @@
             return (Class<?>) type;
         }
     }
+        
     
     /**
      * Gets the method first found parameter qualifiers.

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=900037&r1=900036&r2=900037&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 17 00:25:34 2010
@@ -846,7 +846,49 @@
         }
     }
 
-    
+    public static boolean checkEventTypeAssignability(Type eventType, Type observerType)
+    {
+        if(isTypeVariable(observerType))
+        {
+            Class<?> eventClass = getClass(eventType);
+                        
+            TypeVariable<?> tvBeanTypeArg = (TypeVariable<?>)observerType;
+            Type tvBound = tvBeanTypeArg.getBounds()[0];
+            
+            if(tvBound instanceof Class)
+            {
+                Class<?> clazzTvBound = (Class<?>)tvBound;
+                
+                if(clazzTvBound.isAssignableFrom(eventClass))
+                {
+                    return true;
+                }                    
+            }
+        }
+        else if(observerType instanceof ParameterizedType && eventType instanceof ParameterizedType)
+        {
+            return isAssignableForParametrized((ParameterizedType)eventType, (ParameterizedType)observerType);
+        }
+        else if(observerType instanceof Class && eventType instanceof ParameterizedType)
+        {
+            Class<?> clazzBeanType = (Class<?>)observerType;
+            ParameterizedType ptEvent = (ParameterizedType)eventType;
+            Class<?> eventClazz = (Class<?>)ptEvent.getRawType();
+            
+            if(isAssignable(clazzBeanType, eventClazz))
+            {
+                return true;
+            }
+            
+            return false;            
+        }
+        else if(observerType instanceof Class && eventType instanceof Class)
+        {
+            return isAssignable((Class<?>)observerType, (Class<?>) eventType);
+        }
+        
+        return false;
+    }
     
     
     /**

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=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sun Jan 17 00:25:34 2010
@@ -45,6 +45,7 @@
 import javax.enterprise.context.NormalScope;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Alternative;
 import javax.enterprise.inject.Disposes;
@@ -55,11 +56,15 @@
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.Stereotype;
 import javax.enterprise.inject.UnproxyableResolutionException;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.BeforeShutdown;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
@@ -104,7 +109,6 @@
 import org.apache.webbeans.decorator.DecoratorUtil;
 import org.apache.webbeans.decorator.DecoratorsManager;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
-import org.apache.webbeans.event.EventImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.exception.WebBeansPassivationException;
@@ -124,10 +128,12 @@
 import org.apache.webbeans.portable.creation.InjectionTargetProducer;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
+import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
 import org.apache.webbeans.portable.events.generics.GProcessObservableMethod;
 import org.apache.webbeans.portable.events.generics.GProcessProducer;
 import org.apache.webbeans.portable.events.generics.GProcessProducerField;
 import org.apache.webbeans.portable.events.generics.GProcessProducerMethod;
+import org.apache.webbeans.portable.events.generics.GProcessSessionBean;
 
 /**
  * Contains some utility methods used in the all project.
@@ -609,6 +615,7 @@
 
         ExtensionBean<T> comp = null;
         comp = new ExtensionBean<T>(clazz);
+        comp.setEnabled(true);
         
         DefinitionUtil.defineApiTypes(comp, clazz);
         
@@ -669,25 +676,25 @@
         return comp;
     }    
     
-    /**
-     * Creates a new event bean instance.
-     * @param <T> type info
-     * @param returnType bean api type
-     * @param eventType event type
-     * @param annotations event binding annotations
-     * @return new event bean instance
-     */
-    public static <T> EventBean<T> createObservableImplicitComponent(Class<T> returnType, Type eventType, Annotation... annotations)
-    {
-        EventBean<T> component = new EventBean<T>(returnType, eventType, WebBeansType.OBSERVABLE);
-
-        DefinitionUtil.defineApiTypes(component, returnType);
-        DefinitionUtil.defineQualifiers(component, annotations);
-
-        component.setImplScopeType(new DependentScopeLiteral());                      
-
-        return component;
-    }
+//    /**
+//     * Creates a new event bean instance.
+//     * @param <T> type info
+//     * @param returnType bean api type
+//     * @param eventType event type
+//     * @param annotations event binding annotations
+//     * @return new event bean instance
+//     */
+//    public static <T> EventBean<T> createObservableImplicitComponent(Class<T> returnType, Type eventType, Annotation... annotations)
+//    {
+//        EventBean<T> component = new EventBean<T>(returnType, eventType, WebBeansType.OBSERVABLE);
+//
+//        DefinitionUtil.defineApiTypes(component, returnType);
+//        DefinitionUtil.defineQualifiers(component, annotations);
+//
+//        component.setImplScopeType(new DependentScopeLiteral());                      
+//
+//        return component;
+//    }
 
     /**
      * Creates a new manager bean instance.
@@ -708,27 +715,41 @@
     
     /**
      * Creates a new instance bean.
-     * @param <T> type info
-     * @param instance Instance instance
-     * @param clazz Instance class
-     * @param injectedType injected type
-     * @param obtainsBindings instance bindings
      * @return new instance bean
      */
     public static <T> InstanceBean<T> getInstanceBean()
     {
-        InstanceBean<T> instanceComponent = new InstanceBean<T>();
+        InstanceBean<T> instanceBean = new InstanceBean<T>();
+        
+        instanceBean.getTypes().add(new TypeLiteral<Instance<?>>(){}.getRawType());
+        instanceBean.getTypes().add(new TypeLiteral<Provider<?>>(){}.getRawType());
+        instanceBean.addApiType(Object.class);
+        
+        instanceBean.addQualifier(new AnyLiteral());
+        instanceBean.setImplScopeType(new DependentScopeLiteral());
+        instanceBean.setName(null);
+                
+        return instanceBean;
+    }
+    
+    /**
+     * Creates a new event bean.
+     * @return new event bean
+     */
+    public static <T> EventBean<T> getEventBean()
+    {
+        EventBean<T> eventBean = new EventBean<T>();
+        
+        eventBean.getTypes().add(new TypeLiteral<Event<?>>(){}.getRawType());
+        eventBean.addApiType(Object.class);
         
-        instanceComponent.getTypes().add(new TypeLiteral<Instance<?>>(){}.getRawType());
-        instanceComponent.getTypes().add(new TypeLiteral<Provider<?>>(){}.getRawType());
-        instanceComponent.addApiType(Object.class);
-        
-        instanceComponent.addQualifier(new AnyLiteral());
-        instanceComponent.setImplScopeType(new DependentScopeLiteral());
-        instanceComponent.setName(null);
+        eventBean.addQualifier(new AnyLiteral());
+        eventBean.setImplScopeType(new DependentScopeLiteral());
+        eventBean.setName(null);
                 
-        return instanceComponent;
+        return eventBean;
     }
+    
 
     /**
      * Returns new conversation bean instance.
@@ -1856,32 +1877,32 @@
         return false;
     }
     
-    public static void addInjectedImplicitEventComponent(InjectionPoint injectionPoint)
-    {
-        Type type = injectionPoint.getType();
-        
-        if(!(type instanceof ParameterizedType))
-        {
-            return;
-        }
-        
-        Type[] args = new Type[0];
-        
-        Class<?> clazz = null;
-        if (type instanceof ParameterizedType)
-        {
-            ParameterizedType pt = (ParameterizedType) type;
-            args = pt.getActualTypeArguments();
-        }
-        
-        clazz = (Class<?>)args[0];
-        
-        Annotation[] qualifiers = new Annotation[injectionPoint.getQualifiers().size()];
-        qualifiers = injectionPoint.getQualifiers().toArray(qualifiers);
-        
-        Bean<?> bean = createObservableImplicitComponent(EventImpl.class, clazz, qualifiers);
-        BeanManagerImpl.getManager().addBean(bean);                  
-    }
+//    public static void addInjectedImplicitEventComponent(InjectionPoint injectionPoint)
+//    {
+//        Type type = injectionPoint.getType();
+//        
+//        if(!(type instanceof ParameterizedType))
+//        {
+//            return;
+//        }
+//        
+//        Type[] args = new Type[0];
+//        
+//        Class<?> clazz = null;
+//        if (type instanceof ParameterizedType)
+//        {
+//            ParameterizedType pt = (ParameterizedType) type;
+//            args = pt.getActualTypeArguments();
+//        }
+//        
+//        clazz = (Class<?>)args[0];
+//        
+//        Annotation[] qualifiers = new Annotation[injectionPoint.getQualifiers().size()];
+//        qualifiers = injectionPoint.getQualifiers().toArray(qualifiers);
+//        
+//        Bean<?> bean = createObservableImplicitComponent(EventImpl.class, clazz, qualifiers);
+//        BeanManagerImpl.getManager().addBean(bean);                  
+//    }
     
     
 //    public static <T> void addInjectedImplicitInstanceComponent(InjectionPoint injectionPoint)
@@ -2163,4 +2184,26 @@
         
         return null;
     }
+    
+    public static boolean isExtensionEventType(Class<?> clazz)
+    {
+        if(clazz.equals(BeforeBeanDiscovery.class) ||
+                clazz.equals(AfterBeanDiscovery.class) ||
+                clazz.equals(AfterDeploymentValidation.class) ||
+                clazz.equals(BeforeShutdown.class) ||
+                clazz.equals(GProcessAnnotatedType.class) ||
+                clazz.equals(GProcessInjectionTarget.class) ||
+                clazz.equals(GProcessProducer.class) ||
+                clazz.equals(GProcessProducerField.class) ||
+                clazz.equals(GProcessProducerMethod.class) ||
+                clazz.equals(GProcessManagedBean.class) ||
+                clazz.equals(GProcessSessionBean.class) ||
+                clazz.equals(GProcessObservableMethod.class)
+                )
+        {
+            return true;
+        }
+        
+        return false;
+    }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/events/MyExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/events/MyExtension.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/events/MyExtension.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/events/MyExtension.java Sun Jan 17 00:25:34 2010
@@ -88,7 +88,7 @@
         beforeShutdownEvent = bs;
     }
 
-    public void observeProcessAnnotatedTypeEvent(@Observes @Default ProcessAnnotatedType<?> annotatedType)
+    public void observeProcessAnnotatedTypeEvent(@Observes ProcessAnnotatedType<?> annotatedType)
     {
         processAnnotatedTypeEvent = annotatedType;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java?rev=900037&r1=900036&r2=900037&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java Sun Jan 17 00:25:34 2010
@@ -32,6 +32,7 @@
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves1;
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves2;
 import org.apache.webbeans.test.event.LoggedInEvent;
+import org.apache.webbeans.util.WebBeansUtil;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -72,6 +73,8 @@
     public void testWithObservable()
     {
         clear();
+        
+        getManager().addBean(WebBeansUtil.getEventBean());
 
         AbstractBean<ComponentWithObserves1> component = defineManagedBean(ComponentWithObserves1.class);
         AbstractBean<ComponentWithObservable1> componentObservable = defineManagedBean(ComponentWithObservable1.class);
@@ -91,6 +94,8 @@
     {
         clear();
 
+        getManager().addBean(WebBeansUtil.getEventBean());
+        
         AbstractBean<ComponentWithObserves1> component = defineManagedBean(ComponentWithObserves1.class);
         ContextFactory.initRequestContext(null);
 
@@ -113,7 +118,7 @@
 
         ComponentWithObserves1 instance = getManager().getInstance(component);
 
-        Assert.assertNull(instance.getUserName());
+        Assert.assertNotNull(instance.getUserName());
 
         Assert.assertEquals("Gurkan", instance.getUserNameWithMember());
     }
@@ -123,6 +128,8 @@
     {
         clear();
 
+        getManager().addBean(WebBeansUtil.getEventBean());
+        
         AbstractBean<ComponentWithObserves1> component = defineManagedBean(ComponentWithObserves1.class);
         ContextFactory.initRequestContext(null);
 
@@ -136,7 +143,7 @@
         ComponentWithObserves1 instance = getManager().getInstance(component);
 
         Assert.assertEquals("Mark", instance.getUserName());
-        Assert.assertEquals("Mark", instance.getUserNameWithMember());
+        Assert.assertNull(instance.getUserNameWithMember());
     }
 
 



Mime
View raw message