openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r940119 [1/2] - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/ webbeans-impl/src/main/java/org/apache/webbeans/component/third/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/s...
Date Sat, 01 May 2010 22:20:54 GMT
Author: gerdogdu
Date: Sat May  1 22:20:53 2010
New Revision: 940119

URL: http://svn.apache.org/viewvc?rev=940119&view=rev
Log:
Strong TCK standalone and Java EE Web Profile testing.

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/OwbElContextListener.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedExpressionFactory.java   (with props)
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedValueExpression.java   (with props)
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplication.java   (with props)
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbApplicationFactory.java   (with props)
Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.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/EJBWebBeansConfigurator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.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/DependentScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.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/WebBeansAnnotatedTypeUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/JSFUtil.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java
    openwebbeans/trunk/webbeans-jsf/src/main/resources/META-INF/faces-config.xml
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
    openwebbeans/trunk/webbeans-openejb/src/test/java/org/apache/webbeans/ejb/EjbTestContext.java
    openwebbeans/trunk/webbeans-openejb/src/test/java/org/apache/webbeans/ejb/bean/SimpleBeanTest.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/AbstractOwbPlugin.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansEjbPlugin.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/plugins/OpenWebBeansPlugin.java
    openwebbeans/trunk/webbeans-tomcat6/src/main/java/org/apache/webbeans/web/tomcat/TomcatWebPlugin.java   (contents, props changed)
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java Sat May  1 22:20:53 2010
@@ -28,6 +28,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
 
 import org.apache.webbeans.component.InjectionTargetWrapper;
 import org.apache.webbeans.component.ProducerFieldBean;
@@ -56,13 +57,13 @@ public final class EjbUtility
         
     }
         
-    public static <T> void fireEvents(Class<T> clazz, BaseEjbBean<T> ejbBean)
+    public static <T> void fireEvents(Class<T> clazz, BaseEjbBean<T> ejbBean,ProcessAnnotatedType<T> event)
     {
         BeanManagerImpl manager = BeanManagerImpl.getManager();
         AnnotatedType<T> annotatedType = AnnotatedElementFactory.newAnnotatedType(clazz);
         
         //Fires ProcessAnnotatedType
-        ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType);             
+        ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = (ProcessAnnotatedTypeImpl<T>)event;             
         EjbBeanCreatorImpl<T> ejbBeanCreator = new EjbBeanCreatorImpl<T>(ejbBean);
         ejbBeanCreator.checkCreateConditions();
         
@@ -99,7 +100,7 @@ public final class EjbUtility
         Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods = new HashMap<ProducerMethodBean<?>, AnnotatedMethod<?>>(); 
         for(ProducerMethodBean<?> producerMethod : producerMethodBeans)
         {
-            AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(producerMethod.getCreatorMethod(), producerMethod.getParent().getReturnType());
+            AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(producerMethod.getCreatorMethod(), annotatedType);
             ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForMethod(producerMethod,method);
             WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducer event observers for ProducerMethods. Look at logs for further details");
 
@@ -112,7 +113,7 @@ public final class EjbUtility
         Map<ProducerFieldBean<?>,AnnotatedField<?>> annotatedFields = new HashMap<ProducerFieldBean<?>, AnnotatedField<?>>();
         for(ProducerFieldBean<?> producerField : producerFieldBeans)
         {
-            AnnotatedField<?> field = AnnotatedElementFactory.newAnnotatedField(producerField.getCreatorField(), producerField.getParent().getReturnType());
+            AnnotatedField<?> field = AnnotatedElementFactory.newAnnotatedField(producerField.getCreatorField(), annotatedType);
             ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForField(producerField, field);
             WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducer event observers for ProducerFields. Look at logs for further details");
             
@@ -127,7 +128,7 @@ public final class EjbUtility
         for(ObserverMethod<?> observerMethod : observerMethods)
         {
             ObserverMethodImpl<?> impl = (ObserverMethodImpl<?>)observerMethod;
-            AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(impl.getObserverMethod(), impl.getBeanClass());
+            AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(impl.getObserverMethod(), annotatedType);
             
             observerMethodsMap.put(observerMethod, method);
         }        
@@ -139,7 +140,7 @@ public final class EjbUtility
         
         
         //Fires ProcessProducerMethod
-        WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods);
+        WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods, annotatedType);
         WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerMethod event observers for producer method beans. Look at logs for further details");
         
         //Fires ProcessProducerField

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java Sat May  1 22:20:53 2010
@@ -27,8 +27,9 @@ import javax.enterprise.inject.spi.Passi
 
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.inject.AlternativesManager;
 
-public class ThirdpartyBeanImpl<T> extends AbstractOwbBean<T>
+public class ThirdpartyBeanImpl<T> extends AbstractOwbBean<T> implements Bean<T>
 {
     private Bean<T> bean = null;
     
@@ -134,4 +135,45 @@ public class ThirdpartyBeanImpl<T> exten
         
     }
 
+    @Override
+    public Class<?> getBeanClass()
+    {
+        return this.bean.getBeanClass();
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes()
+    {
+        return this.bean.getStereotypes();
+    }
+
+    @Override
+    public boolean isAlternative()
+    {
+        boolean alternative = this.bean.isAlternative();
+        if(alternative)
+        {
+            AlternativesManager manager = AlternativesManager.getInstance();
+            //Class alternative
+            if(manager.isClassAlternative(getBeanClass()))
+            {
+                return true;
+            }
+            
+            Set<Class<? extends Annotation>> stereoTypes = this.bean.getStereotypes();
+            if(stereoTypes != null)
+            {
+                for(Class<? extends Annotation> stereo : stereoTypes)
+                {
+                    if(manager.isStereoAlternative(stereo))
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+        
+        return false;
+    }
+
 }

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=940119&r1=940118&r2=940119&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 Sat May  1 22:20:53 2010
@@ -31,12 +31,14 @@ import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.interceptor.Interceptor;
 
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.InjectionTargetBean;
+import org.apache.webbeans.component.InjectionTargetWrapper;
 import org.apache.webbeans.component.InterceptedMarker;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.NewBean;
@@ -62,6 +64,7 @@ import org.apache.webbeans.plugins.Plugi
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.events.ExtensionLoader;
 import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
+import org.apache.webbeans.portable.events.ProcessInjectionTargetImpl;
 import org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl;
 import org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl;
 import org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl;
@@ -83,6 +86,7 @@ import org.apache.webbeans.xml.XMLSpecia
  * the scanner phase.
  */
 @SuppressWarnings("unchecked")
+//This class written as single threaded.
 public class BeansDeployer
 {
     //Logger instance
@@ -96,7 +100,7 @@ public class BeansDeployer
     
     /**Discover ejb or not*/
     protected boolean discoverEjb = false;
-
+    
     /**
      * Creates a new deployer with given xml configurator.
      * 
@@ -383,6 +387,9 @@ public class BeansDeployer
             
             //Validate Bean names
             validateBeanNames(beanNames);
+            
+            //Clear Names
+            beanNames.clear();
         }
         
     }
@@ -390,41 +397,49 @@ public class BeansDeployer
     private void validateBeanNames(Stack<String> beanNames)
     {
         if(beanNames.size() > 0)
-        {
-            String beanName = beanNames.pop();
-            String part = null;
-            int i = beanName.indexOf('.');
-            if(i != -1)
+        {   
+            for(String beanName : beanNames)
             {
-                part = beanName.substring(0,i);                
-            }
-            
-            for(String other : beanNames)
-            {
-                if(beanName.equals(other))
+                for(String other : beanNames)
                 {
-                    Set<Bean<?>> beans = InjectionResolver.getInstance().implResolveByName(beanName);
-                    if(beans.size() > 1)
+                    String part = null;
+                    int i = beanName.lastIndexOf('.');
+                    if(i != -1)
                     {
-                        throw new WebBeansConfigurationException("There are two different beans with name : " + beanName + " in the deployment archieve");   
+                        part = beanName.substring(0,i);                
                     }
-                }
-                else
-                {
-                    if(part != null)
+                    
+                    if(beanName.equals(other))
                     {
-                        if(part.equals(other))
+                        InjectionResolver resolver = InjectionResolver.getInstance();
+                        Set<Bean<?>> beans = resolver.implResolveByName(beanName);
+                        if(beans.size() > 1)
                         {
-                            throw new WebBeansConfigurationException("EL name of one bean is of the form x.y, where y is a valid bean EL name, and " +
-                                    "x is the EL name of the other bean for the bean name : " + beanName);
-                        }                        
+                            beans = resolver.findByAlternatives(beans);                            
+                            if(beans.size() > 1)
+                            {
+                                throw new WebBeansConfigurationException("There are two different beans with name : " + beanName + " in the deployment archieve");   
+                            }   
+                        }
                     }
-                }
-            }
+                    else
+                    {
+                        if(part != null)
+                        {
+                            if(part.equals(other))
+                            {
+                                throw new WebBeansConfigurationException("EL name of one bean is of the form x.y, where y is a valid bean EL name, and " +
+                                        "x is the EL name of the other bean for the bean name : " + beanName);
+                            }                        
+                        }
+                    }
+                }                
+            }            
         }
     }
     
     
+    
     /**
      * Discovers and deploys classes from class path.
      * 
@@ -438,23 +453,35 @@ public class BeansDeployer
         // Start from the class
         Set<Class<?>> classIndex = scanner.getBeanClasses();
         
+        //Iterating over each class
         if (classIndex != null)
         {
             for(Class<?> implClass : classIndex)
-            {   
-                if (ManagedBeanConfigurator.isManagedBean(implClass))
+            {
+                //Define annotation type
+                AnnotatedType<?> annotatedType = AnnotatedElementFactory.newAnnotatedType(implClass);
+                
+                //Fires ProcessAnnotatedType
+                ProcessAnnotatedTypeImpl<?> processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType);     
+                
+                //if veto() is called
+                if(processAnnotatedEvent.isVeto())
                 {
-                    ManagedBeanConfigurator.checkManagedBeanCondition(implClass);
-                    defineManagedBean(implClass);
+                    return;
                 }
-                else if(this.discoverEjb)
+                
+                //Try class is Managed Bean
+                boolean isDefined = defineManagedBean((Class<Object>)implClass, (ProcessAnnotatedTypeImpl<Object>)processAnnotatedEvent);
+                
+                //Try class is EJB bean
+                if(!isDefined && this.discoverEjb)
                 {                    
                     if(EJBWebBeansConfigurator.isSessionBean(implClass))
                     {
                         logger.info(OWBLogConst.INFO_0010, new Object[]{implClass.getName()});
-                        defineEnterpriseWebBean(implClass);                        
+                        defineEnterpriseWebBean((Class<Object>)implClass, (ProcessAnnotatedTypeImpl<Object>)processAnnotatedEvent);                        
                     }
-                }
+                }                                     
             }
         }
 
@@ -692,69 +719,105 @@ public class BeansDeployer
      * Defines and configures managed bean.
      * @param <T> type info
      * @param clazz bean class
+     * @return true if given class is configured as a managed bean
      */
-    protected <T> void defineManagedBean(Class<T> clazz)
-    {
-        AnnotatedType<T> annotatedType = AnnotatedElementFactory.newAnnotatedType(clazz);
-        
-        //Fires ProcessAnnotatedType
-        ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType);      
-        
-        ManagedBean<T> managedBean = new ManagedBean<T>(clazz,WebBeansType.MANAGED);                  
-        ManagedBeanCreatorImpl<T> managedBeanCreator = new ManagedBeanCreatorImpl<T>(managedBean);
-        
-        if(processAnnotatedEvent.isVeto())
-        {
-            return;
-        }
+    protected <T> boolean defineManagedBean(Class<T> clazz, ProcessAnnotatedTypeImpl<T> processAnnotatedEvent)
+    {   
+        //Bean manager
+        BeanManagerImpl manager = BeanManagerImpl.getManager();
         
-        boolean annotationTypeSet = false;
-        if(processAnnotatedEvent.isSet())
-        {
-            annotationTypeSet = true;
-            managedBean.setAnnotatedType(annotatedType);
-            annotatedType = processAnnotatedEvent.getAnnotatedType();
-            managedBeanCreator.setAnnotatedType(annotatedType);
-            managedBeanCreator.setMetaDataProvider(MetaDataProvider.THIRDPARTY);
+        //Create an annotated type
+        AnnotatedType<T> annotatedType = processAnnotatedEvent.getAnnotatedType();
+                                
+        //Fires ProcessInjectionTarget event for Java EE components instances
+        //That supports injections but not managed beans
+        ProcessInjectionTargetImpl<T> processInjectionTargetEvent = null;
+        if(WebBeansUtil.supportsJavaEeComponentInjections(clazz))
+        {
+            //Fires ProcessInjectionTarget
+            processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEventForJavaEeComponents(clazz);    
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessInjectionTarget event observers. Look at logs for further details");
+            
+            //Sets custom InjectionTarget instance
+            if(processInjectionTargetEvent.isSet())
+            {
+                //Adding injection target
+                manager.putInjectionTargetWrapperForJavaEeComponents(clazz, new InjectionTargetWrapper<T>(processInjectionTargetEvent.getInjectionTarget()));                
+            }
         }
         
-        //Decorator
-        if(WebBeansAnnotatedTypeUtil.isAnnotatedTypeDecorator(annotatedType))
+        //Check for whether this class is candidate for Managed Bean
+        if (ManagedBeanConfigurator.isManagedBean(clazz))
         {
-            logger.debug(OWBLogConst.INFO_0012, new Object[]{annotatedType.getJavaClass().getName()});
-            if(annotationTypeSet)
+            //Check conditions
+            ManagedBeanConfigurator.checkManagedBeanCondition(clazz);
+            
+            //Temporary managed bean instance creationa
+            ManagedBean<T> managedBean = new ManagedBean<T>(clazz,WebBeansType.MANAGED);                  
+            ManagedBeanCreatorImpl<T> managedBeanCreator = new ManagedBeanCreatorImpl<T>(managedBean);
+            
+            boolean annotationTypeSet = false;
+            if(processAnnotatedEvent.isSet())
             {
-                WebBeansAnnotatedTypeUtil.defineDecorator(annotatedType);
-            }
-            else
+                annotationTypeSet = true;
+                managedBean.setAnnotatedType(annotatedType);
+                annotatedType = processAnnotatedEvent.getAnnotatedType();
+                managedBeanCreator.setAnnotatedType(annotatedType);
+                managedBeanCreator.setMetaDataProvider(MetaDataProvider.THIRDPARTY);
+            }            
+            
+            //If ProcessInjectionTargetEvent is not set, set it
+            if(processInjectionTargetEvent == null)
+            {
+                processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(managedBean);   
+            }    
+            
+            //Decorator
+            if(WebBeansAnnotatedTypeUtil.isAnnotatedTypeDecorator(annotatedType))
             {
-                WebBeansUtil.defineDecorator(managedBeanCreator, annotatedType);
+                logger.debug(OWBLogConst.INFO_0012, new Object[]{annotatedType.getJavaClass().getName()});
+                if(annotationTypeSet)
+                {
+                    WebBeansAnnotatedTypeUtil.defineDecorator(annotatedType);
+                }
+                else
+                {
+                    WebBeansUtil.defineDecorator(managedBeanCreator, processInjectionTargetEvent);
+                }
             }
-        }
-        //Interceptor
-        else if(WebBeansAnnotatedTypeUtil.isAnnotatedTypeInterceptor(annotatedType))
-        {
-            logger.debug(OWBLogConst.INFO_0011, new Object[]{annotatedType.getJavaClass().getName()});
-            if(annotationTypeSet)
+            //Interceptor
+            else if(WebBeansAnnotatedTypeUtil.isAnnotatedTypeInterceptor(annotatedType))
             {
-                WebBeansAnnotatedTypeUtil.defineInterceptor(annotatedType);
+                logger.debug(OWBLogConst.INFO_0011, new Object[]{annotatedType.getJavaClass().getName()});
+                if(annotationTypeSet)
+                {
+                    WebBeansAnnotatedTypeUtil.defineInterceptor(annotatedType);
+                }
+                else
+                {
+                    WebBeansUtil.defineInterceptor(managedBeanCreator, processInjectionTargetEvent);
+                }
             }
             else
             {
-                WebBeansUtil.defineInterceptor(managedBeanCreator, annotatedType);
+                if(BeanManagerImpl.getManager().containsCustomDecoratorClass(annotatedType.getJavaClass()) ||
+                        BeanManagerImpl.getManager().containsCustomInterceptorClass(annotatedType.getJavaClass()))
+                {
+                    return false;
+                }
+                
+                logger.debug(OWBLogConst.INFO_0009, new Object[]{annotatedType.getJavaClass().getName()});
+                WebBeansUtil.defineManagedBean(managedBeanCreator, processInjectionTargetEvent);   
             }
+            
+            return true;
         }
+        //Not a managed bean
         else
         {
-            if(BeanManagerImpl.getManager().containsCustomDecoratorClass(annotatedType.getJavaClass()) ||
-                    BeanManagerImpl.getManager().containsCustomInterceptorClass(annotatedType.getJavaClass()))
-            {
-                return;
-            }
-            
-            logger.debug(OWBLogConst.INFO_0009, new Object[]{annotatedType.getJavaClass().getName()});
-            WebBeansUtil.defineManagedBean(managedBeanCreator, annotatedType);   
+            return false;
         }
+                                
     }
     
     /**
@@ -762,9 +825,9 @@ public class BeansDeployer
      * @param <T> bean class type
      * @param clazz bean class
      */
-    protected <T> void defineEnterpriseWebBean(Class<T> clazz)
+    protected <T> void defineEnterpriseWebBean(Class<T> clazz, ProcessAnnotatedType<T> processAnnotatedTypeEvent)
     {
-        InjectionTargetBean<T> bean = (InjectionTargetBean<T>) EJBWebBeansConfigurator.defineEjbBean(clazz);
+        InjectionTargetBean<T> bean = (InjectionTargetBean<T>) EJBWebBeansConfigurator.defineEjbBean(clazz, processAnnotatedTypeEvent);
         WebBeansUtil.setInjectionTargetBeanEnableFlag(bean);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/EJBWebBeansConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/EJBWebBeansConfigurator.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/EJBWebBeansConfigurator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/EJBWebBeansConfigurator.java Sat May  1 22:20:53 2010
@@ -14,6 +14,7 @@
 package org.apache.webbeans.config;
 
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
 
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.plugins.PluginLoader;
@@ -52,7 +53,7 @@ public final class EJBWebBeansConfigurat
      * @param clazz bean class
      * @return ejb bean
      */
-    public static <T> Bean<T> defineEjbBean(Class<T> clazz)
+    public static <T> Bean<T> defineEjbBean(Class<T> clazz, ProcessAnnotatedType<T> processAnnotatedTypeEvent)
     {
         PluginLoader loader = PluginLoader.getInstance();
         OpenWebBeansEjbPlugin ejbPlugin = loader.getEjbPlugin();
@@ -62,7 +63,7 @@ public final class EJBWebBeansConfigurat
             throw new IllegalStateException("There is no provided EJB plugin. Unable to define session bean for class : " + clazz.getName());
         }
         
-        return ejbPlugin.defineSessionBean(clazz);
+        return ejbPlugin.defineSessionBean(clazz, processAnnotatedTypeEvent);
     }
     
 }

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=940119&r1=940118&r2=940119&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 Sat May  1 22:20:53 2010
@@ -70,6 +70,7 @@ import org.apache.webbeans.decorator.Dec
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.el.WebBeansELResolver;
+import org.apache.webbeans.el.WrappedExpressionFactory;
 import org.apache.webbeans.event.NotificationManager;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.inject.DefinitionException;
@@ -160,6 +161,10 @@ public class BeanManagerImpl implements 
     
     private Map<Contextual<?>, InjectionTargetWrapper<?>> injectionTargetWrappers = 
         Collections.synchronizedMap(new IdentityHashMap<Contextual<?>, InjectionTargetWrapper<?>>());
+    
+    /**InjectionTargets for Java EE component instances that supports injections*/
+    private Map<Class<?>, InjectionTargetWrapper<?>> injectionTargetForJavaEeComponents = 
+        new ConcurrentHashMap<Class<?>, InjectionTargetWrapper<?>>();
 
     /**
      * The parent Manager this child is depending from.
@@ -191,6 +196,20 @@ public class BeanManagerImpl implements 
         return (InjectionTargetWrapper<T>)this.injectionTargetWrappers.get(contextual);
     }
     
+    public <T> void putInjectionTargetWrapperForJavaEeComponents(Class<T> javaEeComponentClass, InjectionTargetWrapper<T> wrapper)
+    {
+        Asserts.assertNotNull(javaEeComponentClass);
+        Asserts.assertNotNull(wrapper);
+        
+        this.injectionTargetForJavaEeComponents.put(javaEeComponentClass, wrapper);
+    }
+    
+    public <T> InjectionTargetWrapper<T> getInjectionTargetWrapper(Class<T> javaEeComponentClass)
+    {
+        Asserts.assertNotNull(javaEeComponentClass);
+        return (InjectionTargetWrapper<T>)this.injectionTargetForJavaEeComponents.get(javaEeComponentClass);
+    }    
+    
     public ErrorStack getErrorStack()
     {
         return this.errorStack;
@@ -1043,7 +1062,7 @@ public class BeanManagerImpl implements 
     @Override
     public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory)
     {
-        return null;
+        return new WrappedExpressionFactory(expressionFactory);
     }
 
     public void addAdditionalQualifier(Class<? extends Annotation> qualifier)

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/OwbElContextListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/OwbElContextListener.java?rev=940119&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/OwbElContextListener.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/OwbElContextListener.java Sat May  1 22:20:53 2010
@@ -0,0 +1,37 @@
+/*
+ * 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.el;
+
+import javax.el.ELContext;
+import javax.el.ELContextEvent;
+import javax.el.ELContextListener;
+
+public class OwbElContextListener implements ELContextListener
+{
+
+    @Override
+    public void contextCreated(ELContextEvent event)
+    {
+        ELContext elContext = event.getELContext();
+        ELContextStore store = new ELContextStore(elContext);
+        
+        WebBeansELResolver.LOCAL_CONTEXT.set(store);
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/OwbElContextListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java Sat May  1 22:20:53 2010
@@ -50,6 +50,11 @@ public class WebBeansELResolver extends 
 
     public static ThreadLocal<ELContextStore> LOCAL_CONTEXT = new ThreadLocal<ELContextStore>();
     
+    public WebBeansELResolver()
+    {
+        
+    }
+    
     /**
      * {@inheritDoc}
      */
@@ -84,61 +89,52 @@ public class WebBeansELResolver extends 
     @SuppressWarnings("unchecked")
     public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
     {
+        //Manager instance
         BeanManagerImpl manager = BeanManagerImpl.getManager();
+        
+        //Bean instance
         Object object = null;
+        
+        //Managed bean
         Bean<Object> bean = null;
-        CreationalContext<Object> creationalContext = null;        
-        ELContextStore store = null;
-        boolean canBe = false;
         
+        //Creational context for creating instance
+        CreationalContext<Object> creationalContext = null;
+        
+        //Local store, set by the OwbELContextListener
+        ELContextStore store = LOCAL_CONTEXT.get();        
         if (obj == null)
-        {
-            if((store = LOCAL_CONTEXT.get()) != null)
-            {
-                ELContext oldContext = store.getELContext();
-                if(!oldContext.equals(context))
-                {
-                    store.destroy();
-                    LOCAL_CONTEXT.set(null);
-                    LOCAL_CONTEXT.remove();
-                }
-                else
-                {
-                    canBe = true;
-                }
-            }
-                        
-            String name = (String) property;            
+        {                      
+            //Name of the bean
+            String name = (String) property;
+            //Get beans
             Set<Bean<?>> beans = manager.getBeans(name);
             
+            //Found?
             if(beans != null && !beans.isEmpty())
             {
                 bean = (Bean<Object>)beans.iterator().next();
                 creationalContext = manager.createCreationalContext(bean);                    
-                
+                //Already registered in store
                 if(bean.getScope().equals(Dependent.class))
                 {
-                    if(canBe)
-                    {
-                       object = store.getDependent(bean);
-                    }
+                    object = store.getDependent(bean);
                 }                    
             }
             
-            
+            //If no object found on the store
             if(object == null)
             {
-                object = manager.getInstanceByName(name,creationalContext);
-                
+                //Getting object
+                object = manager.getInstanceByName(name,creationalContext);                
                 if (object != null)
                 {                    
-                    context.setPropertyResolved(true);
-                    
-                    store = new ELContextStore(context);
+                    context.setPropertyResolved(true);   
+                    //Adding into store
                     store.addDependent(bean, object, creationalContext);
-                    LOCAL_CONTEXT.set(store);
                 }                    
             }
+            //Object found on the store
             else
             {
                 context.setPropertyResolved(true);                    

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedExpressionFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedExpressionFactory.java?rev=940119&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedExpressionFactory.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedExpressionFactory.java Sat May  1 22:20:53 2010
@@ -0,0 +1,63 @@
+/*
+ * 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.el;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+public class WrappedExpressionFactory extends ExpressionFactory
+{
+    private ExpressionFactory expressionFactory;
+
+    public WrappedExpressionFactory(ExpressionFactory expressionFactory)
+    {
+        this.expressionFactory = expressionFactory;
+    }
+    
+    @Override
+    public Object coerceToType(Object arg0, Class<?> arg1) throws ELException
+    {
+        return this.expressionFactory.coerceToType(arg0, arg1);
+    }
+
+    @Override
+    public MethodExpression createMethodExpression(ELContext arg0, String arg1, Class<?> arg2, Class<?>[] arg3) throws ELException, NullPointerException
+    {
+        return this.expressionFactory.createMethodExpression(arg0, arg1, arg2, arg3);
+    }
+
+    @Override
+    public ValueExpression createValueExpression(Object arg0, Class<?> arg1)
+    {
+        ValueExpression wrapped = this.expressionFactory.createValueExpression(arg0, arg1);
+        
+        return new WrappedValueExpression(wrapped);
+    }
+
+    @Override
+    public ValueExpression createValueExpression(ELContext arg0, String arg1, Class<?> arg2) throws NullPointerException, ELException
+    {   
+        ValueExpression wrapped = this.expressionFactory.createValueExpression(arg0, arg1, arg2);
+                
+        return new WrappedValueExpression(wrapped);
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedExpressionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedValueExpression.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedValueExpression.java?rev=940119&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedValueExpression.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedValueExpression.java Sat May  1 22:20:53 2010
@@ -0,0 +1,121 @@
+/*
+ * 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.el;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+import javax.el.ValueReference;
+
+public class WrappedValueExpression extends ValueExpression
+{
+    private static final long serialVersionUID = 1L;
+
+    private ValueExpression valueExpression;
+    
+    public WrappedValueExpression(ValueExpression valueExpression)
+    {
+        this.valueExpression = valueExpression;
+    }
+    
+    
+
+    /* (non-Javadoc)
+     * @see javax.el.ValueExpression#getValueReference(javax.el.ELContext)
+     */
+    @Override
+    public ValueReference getValueReference(ELContext context)
+    {
+        return valueExpression.getValueReference(context);
+    }
+
+    @Override
+    public Class<?> getExpectedType()
+    {
+        return this.valueExpression.getExpectedType();
+    }
+
+    @Override
+    public Class<?> getType(ELContext arg0) throws NullPointerException, PropertyNotFoundException, ELException
+    {        
+        return this.valueExpression.getType(arg0);
+    }
+
+    @Override
+    public Object getValue(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
+    {
+        Object value = null;
+        try
+        {
+           value = this.valueExpression.getValue(context);           
+            
+        }finally
+        {
+            //Destroy dependent store
+            ELContextStore store = WebBeansELResolver.LOCAL_CONTEXT.get();
+            if(store != null)
+            {
+                store.destroy();
+                WebBeansELResolver.LOCAL_CONTEXT.set(null);
+                WebBeansELResolver.LOCAL_CONTEXT.remove();
+            }
+        }
+        
+        return value;
+    }
+
+    @Override
+    public boolean isReadOnly(ELContext arg0) throws NullPointerException, PropertyNotFoundException, ELException
+    {        
+        return this.valueExpression.isReadOnly(arg0);
+    }
+
+    @Override
+    public void setValue(ELContext arg0, Object arg1) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException
+    {
+        this.valueExpression.setValue(arg0, arg1);        
+    }
+
+    @Override
+    public boolean equals(Object arg0)
+    {        
+        return this.valueExpression.equals(arg0);
+    }
+
+    @Override
+    public String getExpressionString()
+    {       
+        return this.valueExpression.getExpressionString();
+    }
+
+    @Override
+    public int hashCode()
+    {        
+        return this.valueExpression.hashCode();
+    }
+
+    @Override
+    public boolean isLiteralText()
+    {        
+        return this.valueExpression.isLiteralText();
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WrappedValueExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=940119&r1=940118&r2=940119&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 Sat May  1 22:20:53 2010
@@ -35,6 +35,7 @@ import javax.enterprise.event.ObserverEx
 import javax.enterprise.event.Observes;
 import javax.enterprise.event.Reception;
 import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessObserverMethod;
 import javax.enterprise.util.TypeLiteral;
@@ -465,27 +466,63 @@ public final class NotificationManager
         Asserts.assertNotNull(component, "component parameter can not be null");
         Set<Method> observableMethods = component.getObservableMethods();
         Set<ObserverMethod<?>> observerMethods = new HashSet<ObserverMethod<?>>();
-
-        for (Method observableMethod : observableMethods)
+        
+        //check for null
+        if(observableMethods != null)
         {
-            Observes observes = AnnotationUtil.getMethodFirstParameterAnnotation(observableMethod, Observes.class);
+            for (Method observableMethod : observableMethods)
+            {
+                Observes observes = AnnotationUtil.getMethodFirstParameterAnnotation(observableMethod, Observes.class);
 
-            boolean ifExist = false;
+                boolean ifExist = false;
 
-            if (observes.notifyObserver().equals(Reception.IF_EXISTS))
-            {
-                ifExist = true;
-            }
+                if (observes.notifyObserver().equals(Reception.IF_EXISTS))
+                {
+                    ifExist = true;
+                }
 
-            ObserverMethodImpl<T> observer = new ObserverMethodImpl(component, observableMethod, ifExist);
+                ObserverMethodImpl<T> observer = new ObserverMethodImpl(component, observableMethod, ifExist);
 
-            Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(observableMethod, Observes.class);
+                Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(observableMethod, Observes.class);
 
-            addObserver(observer, type);
-            
-            observerMethods.add(observer);
+                addObserver(observer, type);
+                
+                observerMethods.add(observer);
+            }            
         }
 
         return observerMethods;
     }
+    
+    /**
+     * Gets observer method from given annotated method.
+     * @param <T> bean type info
+     * @param annotatedMethod annotated method for observer
+     * @param bean bean instance 
+     * @return ObserverMethod
+     */
+    public <T> ObserverMethod<?> getObservableMethodForAnnotatedMethod(AnnotatedMethod<?> annotatedMethod, InjectionTargetBean<T> bean)
+    {
+        Asserts.assertNotNull(annotatedMethod, "annotatedMethod parameter can not be null");
+
+        Observes observes = AnnotationUtil.getAnnotatedMethodFirstParameterAnnotation(annotatedMethod, Observes.class);
+        boolean ifExist = false;
+        if(observes != null)
+        {
+            if (observes.notifyObserver().equals(Reception.IF_EXISTS))
+            {
+                ifExist = true;
+            }            
+        }
+
+        ObserverMethodImpl<T> observer = new ObserverMethodImpl(bean, annotatedMethod.getJavaMember(), ifExist);
+        Type type = AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Observes.class);
+        
+        //Adds this observer
+        addObserver(observer, type);
+        
+
+        return observer;
+    }
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/OWBInjector.java Sat May  1 22:20:53 2010
@@ -26,12 +26,12 @@ import java.util.Set;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
 import javax.inject.Inject;
 
 import org.apache.webbeans.component.InjectionPointBean;
+import org.apache.webbeans.component.InjectionTargetWrapper;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
@@ -53,18 +53,35 @@ public final class OWBInjector implement
     
     private CreationalContextImpl<?> ownerCreationalContext = null;
     
+    private Object javaEEInstance;
+    
     public OWBInjector()
     {
         
     }
     
+    @SuppressWarnings("unchecked")
     public void destroy()
     {
-        if(this.ownerCreationalContext != null)
+        BeanManagerImpl beanManager = BeanManagerImpl.getManager();
+        
+        //Look for custom InjectionTarget
+        InjectionTargetWrapper<Object> wrapper = beanManager.getInjectionTargetWrapper((Class<Object>)javaEEInstance.getClass());
+        if(wrapper != null)
         {
-            this.ownerCreationalContext.release();
-            this.ownerCreationalContext = null;
+           wrapper.dispose(javaEEInstance);
+           this.javaEEInstance = null;
+           this.ownerCreationalContext = null;
         }
+        
+        else
+        {
+            if(this.ownerCreationalContext != null)
+            {
+                this.ownerCreationalContext.release();
+                this.ownerCreationalContext = null;
+            }            
+        }        
     }
     
     public  OWBInjector inject(Object javaEeComponentInstance) throws Exception
@@ -75,20 +92,31 @@ public final class OWBInjector implement
     @SuppressWarnings("unchecked")
     public  OWBInjector inject(Object javaEeComponentInstance, CreationalContext<?> creationalContext) throws Exception
     {
-        BeanManager beanManager = BeanManagerImpl.getManager();
+        BeanManagerImpl beanManager = BeanManagerImpl.getManager();
         try
         {
-            Class<?> injectableComponentClass = javaEeComponentInstance.getClass();
+            this.javaEEInstance = javaEeComponentInstance;
+            if(creationalContext == null)
+            {
+                this.ownerCreationalContext = (CreationalContextImpl<?>) beanManager.createCreationalContext(null);   
+            }
+
+            Class<Object> injectableComponentClass = (Class<Object>)javaEeComponentInstance.getClass();
+            InjectionTarget<Object> injectionTarget = null;
+            
+            //Look for custom InjectionTarget
+            InjectionTargetWrapper<Object> wrapper = beanManager.getInjectionTargetWrapper(injectableComponentClass);
+            if(wrapper != null)
+            {
+                wrapper.inject(javaEeComponentInstance, (CreationalContext<Object>)this.ownerCreationalContext);
+                return this;
+            }
+            
             AnnotatedType<Object> annotated = (AnnotatedType<Object>) beanManager.createAnnotatedType(injectableComponentClass);
-            InjectionTarget<Object> injectionTarget = beanManager.createInjectionTarget(annotated);
+            injectionTarget = beanManager.createInjectionTarget(annotated);
             Set<InjectionPoint> injectionPoints = injectionTarget.getInjectionPoints();
             if(injectionPoints != null && injectionPoints.size() > 0)
             {
-                if(creationalContext == null)
-                {
-                    this.ownerCreationalContext = (CreationalContextImpl<?>) beanManager.createCreationalContext(null);   
-                }
-                
                 for(InjectionPoint injectionPoint : injectionPoints)
                 {
                     boolean injectionPointBeanSet = false;

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=940119&r1=940118&r2=940119&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 Sat May  1 22:20:53 2010
@@ -31,6 +31,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Named;
@@ -97,7 +98,9 @@ public class InjectionPointFactory
         
         if(!checkFieldApplicable(annots))
         {
-            return getGenericInjectionPoint(owner, annots, member.getGenericType(), member, AnnotatedElementFactory.newAnnotatedField(member, member.getDeclaringClass()));   
+            AnnotatedType<?> annotated = AnnotatedElementFactory.newAnnotatedType(member.getDeclaringClass());
+            return getGenericInjectionPoint(owner, annots, member.getGenericType(), member, 
+                    AnnotatedElementFactory.newAnnotatedField(member, annotated));   
         }        
         else
         {
@@ -199,8 +202,9 @@ public class InjectionPointFactory
         Asserts.assertNotNull(member, "member parameter can not be null");
 
         List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
-
-        AnnotatedMethod method = AnnotatedElementFactory.newAnnotatedMethod(member, member.getDeclaringClass());
+        
+        AnnotatedType<?> annotated = AnnotatedElementFactory.newAnnotatedType(member.getDeclaringClass());
+        AnnotatedMethod method = AnnotatedElementFactory.newAnnotatedMethod(member, annotated);
         List<AnnotatedParameter<?>> parameters = method.getParameters();
         
         InjectionPoint point = null;
@@ -301,7 +305,8 @@ public class InjectionPointFactory
 
         List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
 
-        AnnotatedConstructor constructor = AnnotatedElementFactory.newAnnotatedConstructor(member);
+        AnnotatedType<Object> annotated = (AnnotatedType<Object>)AnnotatedElementFactory.newAnnotatedType(member.getDeclaringClass());
+        AnnotatedConstructor constructor = AnnotatedElementFactory.newAnnotatedConstructor((Constructor<Object>)member,annotated);
         List<AnnotatedParameter<?>> parameters = constructor.getParameters();
         
         InjectionPoint point = null;

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=940119&r1=940118&r2=940119&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 Sat May  1 22:20:53 2010
@@ -32,6 +32,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 
@@ -192,7 +193,9 @@ class InjectionPointImpl implements Inje
             Field field = ClassUtil.getFieldWithName(beanClass, fieldName);
             
             this.injectionMember = field;
-            this.annotated = AnnotatedElementFactory.newAnnotatedField(field, beanClass);
+            
+            AnnotatedType<?> annotated = AnnotatedElementFactory.newAnnotatedType(beanClass);
+            this.annotated = AnnotatedElementFactory.newAnnotatedField(field, annotated);
             this.injectionType = field.getGenericType();
             
         }
@@ -204,7 +207,9 @@ class InjectionPointImpl implements Inje
             Method method = ClassUtil.getDeclaredMethod(beanClass, methodName, parameters);
             this.injectionMember = method;
             
-            AnnotatedMethod<Object> am =  (AnnotatedMethod<Object>)AnnotatedElementFactory.newAnnotatedMethod((Method)this.injectionMember ,beanClass);
+            AnnotatedType<?> annotated = AnnotatedElementFactory.newAnnotatedType(beanClass);
+            AnnotatedMethod<Object> am =  (AnnotatedMethod<Object>)AnnotatedElementFactory.
+                                    newAnnotatedMethod((Method)this.injectionMember ,annotated);
             List<AnnotatedParameter<Object>> annParameters = am.getParameters();
             
             this.annotated = annParameters.get(in.readByte());            
@@ -216,7 +221,9 @@ class InjectionPointImpl implements Inje
             Class<?>[] parameters = (Class<?>[])in.readObject();            
             this.injectionMember = ClassUtil.getConstructor(beanClass, parameters);
 
-            AnnotatedConstructor<Object> am =  (AnnotatedConstructor<Object>)AnnotatedElementFactory.newAnnotatedConstructor((Constructor<?>)this.injectionMember);
+            AnnotatedType<Object> annotated = (AnnotatedType<Object>)AnnotatedElementFactory.newAnnotatedType(beanClass);
+            AnnotatedConstructor<Object> am =  (AnnotatedConstructor<Object>)AnnotatedElementFactory
+                                            .newAnnotatedConstructor((Constructor<Object>)this.injectionMember,annotated);
             List<AnnotatedParameter<Object>> annParameters = am.getParameters();
             
             this.annotated = annParameters.get(in.readByte());            

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java Sat May  1 22:20:53 2010
@@ -53,6 +53,17 @@ public class DependentScopedBeanIntercep
         super(bean);        
         this.actualInstance = instance;
         this.creationalContext = creationalContext;
+        
+        if(creationalContext instanceof CreationalContextImpl)
+        {
+            //If this creational context is owned by this DependentBean, add it
+            CreationalContextImpl<?> ccImpl = (CreationalContextImpl<?>)creationalContext;
+            if(ccImpl.getBean().equals(bean))
+            {
+                //Owner of the dependent is itself
+                ccImpl.addDependent(instance, bean, instance);
+            }            
+        }
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java Sat May  1 22:20:53 2010
@@ -204,6 +204,7 @@ public class PluginLoader
         return null;
     }
     
+    
     public OpenWebBeansJavaEEPlugin getJavaEEPlugin()
     {
         for(OpenWebBeansPlugin plugin : this.plugins)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java Sat May  1 22:20:53 2010
@@ -118,9 +118,11 @@ public final class AnnotatedElementFacto
      * @return new annotated constructor
      */
     @SuppressWarnings("unchecked")
-    public static <X> AnnotatedConstructor<X> newAnnotatedConstructor(Constructor<X> constructor)
+    public static <X> AnnotatedConstructor<X> newAnnotatedConstructor(Constructor<X> constructor, AnnotatedType<X> declaringClass)
     {
         Asserts.assertNotNull(constructor, "constructor is null");
+        Asserts.assertNotNull(declaringClass, "declaringClass is null");
+        
         AnnotatedConstructorImpl<X> annConstructor = null;
         if(annotatedConstructorCache.containsKey(constructor))
         {
@@ -128,7 +130,7 @@ public final class AnnotatedElementFacto
         }
         else
         {
-            annConstructor = new AnnotatedConstructorImpl<X>(constructor);
+            annConstructor = new AnnotatedConstructorImpl<X>(constructor, declaringClass);
             AnnotatedConstructorImpl<X> old = (AnnotatedConstructorImpl<X>)annotatedConstructorCache.putIfAbsent(constructor, annConstructor);
             if(old != null)
             {
@@ -148,7 +150,7 @@ public final class AnnotatedElementFacto
      * @return new annotated field
      */
     @SuppressWarnings("unchecked")
-    public static <X> AnnotatedField<X> newAnnotatedField(Field field, Class<X> declaringClass)
+    public static <X> AnnotatedField<X> newAnnotatedField(Field field, AnnotatedType<X> declaringClass)
     {
         Asserts.assertNotNull(field, "field is null");
         Asserts.assertNotNull(declaringClass, "declaringClass is null");
@@ -160,7 +162,7 @@ public final class AnnotatedElementFacto
         }
         else
         {
-            annotField = new AnnotatedFieldImpl<X>(field);
+            annotField = new AnnotatedFieldImpl<X>(field, declaringClass);
             AnnotatedFieldImpl<X> old = (AnnotatedFieldImpl<X>) annotatedFieldCache.putIfAbsent(field, annotField);
             if(old != null)
             {
@@ -180,10 +182,10 @@ public final class AnnotatedElementFacto
      * @return new annotated method
      */
     @SuppressWarnings("unchecked")
-    public static <X> AnnotatedMethod<X> newAnnotatedMethod(Method method, Class<X> declaringClass)
+    public static <X> AnnotatedMethod<X> newAnnotatedMethod(Method method, AnnotatedType<X> declaringType)
     {
         Asserts.assertNotNull(method, "method is null");
-        Asserts.assertNotNull(declaringClass, "declaringClass is null");
+        Asserts.assertNotNull(declaringType, "declaringType is null");
         
         AnnotatedMethodImpl<X> annotMethod = null;
         if(annotatedMethodCache.containsKey(method))
@@ -192,7 +194,7 @@ public final class AnnotatedElementFacto
         }
         else
         {
-            annotMethod = new AnnotatedMethodImpl<X>(method);
+            annotMethod = new AnnotatedMethodImpl<X>(method, declaringType);
             AnnotatedMethodImpl<X> old = (AnnotatedMethodImpl<X>) annotatedMethodCache.putIfAbsent(method, annotMethod);
             if(old != null)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java Sat May  1 22:20:53 2010
@@ -24,8 +24,6 @@ import javax.enterprise.inject.spi.Proce
 import javax.enterprise.inject.spi.ProcessObserverMethod;
 
 import org.apache.webbeans.component.ManagedBean;
-import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.event.NotificationManager;
@@ -67,9 +65,7 @@ public class AfterBeanDiscoveryImpl impl
         if(bean instanceof Interceptor)
         {
             //Required for custom interceptors
-            ManagedBean managedBean = new ManagedBean(bean.getBeanClass(),WebBeansType.MANAGED);                  
-            ManagedBeanCreatorImpl managedBeanCreator = new ManagedBeanCreatorImpl(managedBean);
-            managedBean = WebBeansUtil.defineManagedBean(managedBeanCreator, annotatedType);
+            ManagedBean managedBean = WebBeansUtil.defineManagedBeanWithoutFireEvents(annotatedType);
             
             CustomInterceptor<?> interceptor = new CustomInterceptor(managedBean, (Interceptor<?>)bean);
             
@@ -80,9 +76,7 @@ public class AfterBeanDiscoveryImpl impl
         else if(bean instanceof Decorator)
         {
             //Required for custom decorators
-            ManagedBean managedBean = new ManagedBean(bean.getBeanClass(),WebBeansType.MANAGED);                  
-            ManagedBeanCreatorImpl managedBeanCreator = new ManagedBeanCreatorImpl(managedBean);
-            managedBean = WebBeansUtil.defineManagedBean(managedBeanCreator, annotatedType);
+            ManagedBean managedBean = WebBeansUtil.defineManagedBeanWithoutFireEvents(annotatedType);
             
             this.beanManager.addDecorator(new WebBeansDecorator(managedBean, (Decorator)bean));
             BeanManagerImpl.getManager().addCustomInterceptorClass(bean.getBeanClass());            

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Sat May  1 22:20:53 2010
@@ -34,6 +34,7 @@ import javax.enterprise.inject.spi.Decor
 import org.apache.webbeans.annotation.WebBeansAnnotation;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.InjectionTargetBean;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.WebBeansDecorator;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.intercept.ApplicationScopedBeanIntereptorHandler;
@@ -166,6 +167,26 @@ public final class JavassistProxyFactory
         //No need to return proxy
         if(!notInInterceptorClassAndLifecycle && decorators.isEmpty())
         {
+            //Adding this dependent instance into creational context
+            //This occurs when no owner of this dependent instance
+            if(creastionalContext instanceof CreationalContextImpl)
+            {
+                //If this creational context is owned by itself, add it
+                //For example, getting it directly BeanManager#getReference(bean,creational context)
+                CreationalContextImpl<?> ccImpl = (CreationalContextImpl<?>)creastionalContext;
+                
+                //Non contextual instance --> Bean --> Null
+                //See OWBInjector
+                if(ccImpl.getBean() != null)
+                {
+                    if(ccImpl.getBean().equals(bean))
+                    {
+                        //Owner of the dependent is itself
+                        ccImpl.addDependent(actualInstance, bean, actualInstance);
+                    }                                
+                }
+            }
+            
             return actualInstance;
         }
         

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=940119&r1=940118&r2=940119&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 Sat May  1 22:20:53 2010
@@ -795,7 +795,7 @@ public final class ClassUtil
         Asserts.assertNotNull(beanType, "beanType parameter can not be null");
         Asserts.assertNotNull(requiredType, "requiredType parameter can not be null");
         
-        //Bean abd required types are ParametrizedType
+        //Bean and required types are ParametrizedType
         if (beanType instanceof ParameterizedType && requiredType instanceof ParameterizedType)
         {
             return isAssignableForParametrized((ParameterizedType) beanType, (ParameterizedType) requiredType);
@@ -885,8 +885,16 @@ public final class ClassUtil
         }
     }
 
+    /**
+     * Checks that event is applicable
+     * for the given observer type.
+     * @param eventType event type
+     * @param observerType observer type
+     * @return true if event is applicable
+     */
     public static boolean checkEventTypeAssignability(Type eventType, Type observerType)
     {
+        //Observer type is a TypeVariable
         if(isTypeVariable(observerType))
         {
             Class<?> eventClass = getClass(eventType);
@@ -896,18 +904,19 @@ public final class ClassUtil
             
             if(tvBound instanceof Class)
             {
-                Class<?> clazzTvBound = (Class<?>)tvBound;
-                
+                Class<?> clazzTvBound = (Class<?>)tvBound;                
                 if(clazzTvBound.isAssignableFrom(eventClass))
                 {
                     return true;
                 }                    
             }
         }
+        //Both of them are ParametrizedType
         else if(observerType instanceof ParameterizedType && eventType instanceof ParameterizedType)
         {
             return isAssignableForParametrized((ParameterizedType)eventType, (ParameterizedType)observerType);
         }
+        //Observer is class and Event type is Parametrized
         else if(observerType instanceof Class && eventType instanceof ParameterizedType)
         {
             Class<?> clazzBeanType = (Class<?>)observerType;
@@ -921,6 +930,7 @@ public final class ClassUtil
             
             return false;            
         }
+        //Both of them is class type
         else if(observerType instanceof Class && eventType instanceof Class)
         {
             return isClassAssignable((Class<?>)observerType, (Class<?>) eventType);
@@ -1101,27 +1111,27 @@ public final class ClassUtil
             Class<?> clazzBeanTypeArg = (Class<?>)beanTypeArg;
             if(upperBoundRequiredTypeArg instanceof Class)
             {
-                Class<?> clazzUpperBoundTypeArg = (Class<?>)upperBoundRequiredTypeArg;                
+                //Check upper bounds
+                Class<?> clazzUpperBoundTypeArg = (Class<?>)upperBoundRequiredTypeArg;
                 if(clazzUpperBoundTypeArg != Object.class)
                 {
-                    if(clazzUpperBoundTypeArg.isAssignableFrom(clazzBeanTypeArg))
-                    {                                         
-                        if(lowerBoundRequiredTypeArgs.length > 0 &&  lowerBoundRequiredTypeArgs[0] instanceof Class)
-                        {
-                            Class<?> clazzLowerBoundTypeArg = (Class<?>)lowerBoundRequiredTypeArgs[0];
-                            
-                            if(clazzLowerBoundTypeArg != Object.class)
-                            {
-                                if(!clazzBeanTypeArg.isAssignableFrom(clazzLowerBoundTypeArg))
-                                {
-                                    return false;
-                                }                                
-                            }
-                        }
+                    if(!clazzUpperBoundTypeArg.isAssignableFrom(clazzBeanTypeArg))
+                    {                                       
+                        return false;
                     }
-                    else
+                }
+                
+                //Check lower bounds
+                if(lowerBoundRequiredTypeArgs.length > 0 &&  lowerBoundRequiredTypeArgs[0] instanceof Class)
+                {
+                    Class<?> clazzLowerBoundTypeArg = (Class<?>)lowerBoundRequiredTypeArgs[0];
+                    
+                    if(clazzLowerBoundTypeArg != Object.class)
                     {
-                        return false;
+                        if(!clazzBeanTypeArg.isAssignableFrom(clazzLowerBoundTypeArg))
+                        {
+                            return false;
+                        }                                
                     }
                 }
             }                    
@@ -1140,26 +1150,25 @@ public final class ClassUtil
                     Class<?> clazzUpperBoundTypeArg = (Class<?>)upperBoundRequiredTypeArg;                    
                     if(clazzUpperBoundTypeArg != Object.class && clazzTvBound != Object.class)
                     {
-                        if(clazzUpperBoundTypeArg.isAssignableFrom(clazzTvBound))
-                        {                            
-                            if(lowerBoundRequiredTypeArgs.length > 0 &&  lowerBoundRequiredTypeArgs[0] instanceof Class)
-                            {
-                                Class<?> clazzLowerBoundTypeArg = (Class<?>)lowerBoundRequiredTypeArgs[0];
-                                
-                                if(clazzLowerBoundTypeArg != Object.class)
-                                {
-                                    if(!clazzTvBound.isAssignableFrom(clazzLowerBoundTypeArg))
-                                    {
-                                        return false;
-                                    }                                    
-                                }
-                            }
-                        }
-                        else
-                        {
+                        if(!clazzUpperBoundTypeArg.isAssignableFrom(clazzTvBound))
+                        {   
                             return false;
-                        }
+                        }                       
                     }
+                    
+                    //Check lower bounds
+                    if(lowerBoundRequiredTypeArgs.length > 0 &&  lowerBoundRequiredTypeArgs[0] instanceof Class)
+                    {
+                        Class<?> clazzLowerBoundTypeArg = (Class<?>)lowerBoundRequiredTypeArgs[0];
+                        
+                        if(clazzLowerBoundTypeArg != Object.class)
+                        {
+                            if(!clazzTvBound.isAssignableFrom(clazzLowerBoundTypeArg))
+                            {
+                                return false;
+                            }                                    
+                        }
+                    }                    
                 }                                    
             }
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=940119&r1=940118&r2=940119&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Sat May  1 22:20:53 2010
@@ -170,6 +170,7 @@ public final class WebBeansAnnotatedType
     @SuppressWarnings("unchecked")
     public static <X> Set<ObserverMethod<?>> defineObserverMethods(AbstractInjectionTargetBean<X> bean,AnnotatedType<X> annotatedType)
     {
+        Set<ObserverMethod<?>> definedObservers = new HashSet<ObserverMethod<?>>();
         Set<AnnotatedMethod<? super X>> annotatedMethods = annotatedType.getMethods();    
         for (AnnotatedMethod<? super X> annotatedMethod : annotatedMethods)
         {
@@ -201,14 +202,22 @@ public final class WebBeansAnnotatedType
                      }
                 }
                 
-                
+                //Add method
                 bean.addObservableMethod(annotatedMethod.getJavaMember());
 
-                addMethodInjectionPointMetaData(bean, annotatedMethod);                
+                //Add injection point data
+                addMethodInjectionPointMetaData(bean, annotatedMethod);
+                
+                //Looking for ObserverMethod
+                ObserverMethod<?> definedObserver = NotificationManager.getInstance().getObservableMethodForAnnotatedMethod(annotatedMethod, bean);
+                if(definedObserver != null)
+                {
+                    definedObservers.add(definedObserver);
+                }
             }
         }
         
-        return NotificationManager.getInstance().addObservableComponentMethods(bean);
+        return definedObservers;
     }
     
     @SuppressWarnings("unchecked")



Mime
View raw message