openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r915744 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbea...
Date Wed, 24 Feb 2010 10:43:10 GMT
Author: gerdogdu
Date: Wed Feb 24 10:43:09 2010
New Revision: 915744

URL: http://svn.apache.org/viewvc?rev=915744&view=rev
Log:
Update for TCK

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.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/container/ResolutionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.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/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=915744&r1=915743&r2=915744&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
Wed Feb 24 10:43:09 2010
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.component;
 
+import java.io.Serializable;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -667,41 +668,49 @@
      */
     @Override
     public void validatePassivationDependencies()
-    {
-        if(isPassivationCapable())
+    {        
+        super.validatePassivationDependencies();
+        
+        //Check for interceptors and decorators
+        for(Decorator<?> dec : this.decorators)
         {
-            super.validatePassivationDependencies();
-            
-            //Check for interceptors and decorators
-            for(Decorator<?> dec : this.decorators)
+            WebBeansDecorator<?> decorator = (WebBeansDecorator<?>)dec;
+            if(!decorator.isPassivationCapable())
             {
-                WebBeansDecorator<?> decorator = (WebBeansDecorator<?>)dec;
-                if(!decorator.isPassivationCapable())
+                throw new WebBeansConfigurationException("Passivation bean : " + toString()
+ " decorators must be passivating capable");
+            }
+            else
+            {
+                decorator.validatePassivationDependencies();
+            }
+        }
+        
+        for(InterceptorData interceptorData : this.interceptorStack)
+        {
+            if(interceptorData.isDefinedWithWebBeansInterceptor())
+            {
+                WebBeansInterceptor<?> interceptor = (WebBeansInterceptor<?>)interceptorData.getWebBeansInterceptor();
+                if(!interceptor.isPassivationCapable())
                 {
-                    throw new WebBeansConfigurationException("Passivation bean : " + toString()
+ " decorators must be passivating capable");
+                    throw new WebBeansConfigurationException("Passivation bean : " + toString()
+ " interceptors must be passivating capable");
                 }
                 else
                 {
-                    decorator.validatePassivationDependencies();
+                    interceptor.validatePassivationDependencies();
                 }
             }
-            
-            for(InterceptorData interceptorData : this.interceptorStack)
+            else
             {
-                if(interceptorData.isDefinedWithWebBeansInterceptor())
+                Object interceptorInstance = interceptorData.getInterceptorInstance();
+                if(interceptorInstance != null)
                 {
-                    WebBeansInterceptor<?> interceptor = (WebBeansInterceptor<?>)interceptorData.getWebBeansInterceptor();
-                    if(!interceptor.isPassivationCapable())
+                    Class<?> interceptorClass = interceptorInstance.getClass();
+                    if(!Serializable.class.isAssignableFrom(interceptorClass))
                     {
                         throw new WebBeansConfigurationException("Passivation bean : " +
toString() + " interceptors must be passivating capable");
-                    }
-                    else
-                    {
-                        interceptor.validatePassivationDependencies();
-                    }
+                    }                    
                 }
             }
-            
         }
     }    
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=915744&r1=915743&r2=915744&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
Wed Feb 24 10:43:09 2010
@@ -25,6 +25,7 @@
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
@@ -601,6 +602,10 @@
                 {
                     if(!WebBeansUtil.isPassivationCapableDependency(injectionPoint))
                     {
+                        if(injectionPoint.getAnnotated().isAnnotationPresent(Disposes.class))
+                        {
+                            continue;
+                        }
                         throw new WebBeansConfigurationException("Passivation capable beans
must satisfy passivation capable dependencies. " +
                                 "Bean : " + toString() + " does not satisfy.");
                     }

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=915744&r1=915743&r2=915744&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
Wed Feb 24 10:43:09 2010
@@ -33,6 +33,7 @@
 
 import org.apache.webbeans.WebBeansConstants;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
+import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.NewBean;
@@ -520,7 +521,19 @@
      */
     protected void checkPassivationScope(Bean<?> beanObj)
     {
-        ((OwbBean<?>)beanObj).validatePassivationDependencies();
+        if(BeanManagerImpl.getManager().isPassivatingScope(beanObj.getScope()))
+        {
+            if(WebBeansUtil.isPassivationCapable(beanObj) == null)
+            {
+                if(!(beanObj instanceof AbstractProducerBean))
+                {
+                    throw new WebBeansConfigurationException("Passivation scoped defined
bean must be passivation capable, " +
+                            "but bean : " + toString() + " is not passivation capable");
                   
+                }
+            }
+            
+            ((OwbBean<?>)beanObj).validatePassivationDependencies();
+        } 
     }
 
     /**

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=915744&r1=915743&r2=915744&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
Wed Feb 24 10:43:09 2010
@@ -58,6 +58,7 @@
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.JmsBeanMarker;
+import org.apache.webbeans.component.NewBean;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.third.ThirdpartyBeanImpl;
 import org.apache.webbeans.config.WebBeansFinder;
@@ -737,7 +738,7 @@
         //Check type if bean type is given
         if(beanType != null)
         {
-            if(!ResolutionUtil.checkBeanTypeAssignableToGivenType(bean.getTypes(), beanType))
+            if(!ResolutionUtil.checkBeanTypeAssignableToGivenType(bean.getTypes(), beanType,
bean instanceof NewBean))
             {
                 throw new IllegalArgumentException("Given bean type : " + beanType + " is
not applicable for the bean instance : " + bean);
             }

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=915744&r1=915743&r2=915744&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
Wed Feb 24 10:43:09 2010
@@ -143,11 +143,11 @@
                 
                 if(newQualifier.value() == New.class)
                 {
-                    beanSet.add(WebBeansUtil.createNewComponent(clazz));    
+                    beanSet.add(WebBeansUtil.createNewComponent(clazz, type));    
                 }
                 else
                 {
-                    beanSet.add(WebBeansUtil.createNewComponent(newQualifier.value()));
+                    beanSet.add(WebBeansUtil.createNewComponent(newQualifier.value(),null));
                 }
                 
             }
@@ -209,11 +209,11 @@
                 
                 if(newQualifier.value() == New.class)
                 {
-                    beanSet.add(WebBeansUtil.createNewComponent(clazz));    
+                    beanSet.add(WebBeansUtil.createNewComponent(clazz,type));    
                 }
                 else
                 {
-                    beanSet.add(WebBeansUtil.createNewComponent(newQualifier.value()));
+                    beanSet.add(WebBeansUtil.createNewComponent(newQualifier.value(),null));
                 }
 
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java?rev=915744&r1=915743&r2=915744&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java
Wed Feb 24 10:43:09 2010
@@ -36,7 +36,7 @@
 
     }
 
-    public static boolean checkBeanTypeAssignableToGivenType(Set<Type> beanTypes, Type
givenType)
+    public static boolean checkBeanTypeAssignableToGivenType(Set<Type> beanTypes, Type
givenType, boolean newBean)
     { 
         Iterator<Type> itBeanApiTypes = beanTypes.iterator();
         while (itBeanApiTypes.hasNext())
@@ -46,7 +46,19 @@
             if(ClassUtil.isAssignable(beanApiType, givenType))
             {
                 return true;
-            }                    
+            }           
+            else
+            {
+                //Check for @New
+                if(newBean && ClassUtil.isParametrizedType(givenType))
+                {
+                    Class<?> requiredType = ClassUtil.getClass(givenType);
+                    if(ClassUtil.isClassAssignable(requiredType, ClassUtil.getClass(beanApiType)))
+                    {
+                        return true;
+                    }
+                }                
+            }
         }
         
         return false;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=915744&r1=915743&r2=915744&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
Wed Feb 24 10:43:09 2010
@@ -468,7 +468,7 @@
 
 	@Override
 	public Set<Type> getDecoratedTypes() {
-		return this.wrappedBean.getTypes();
+		return this.decoratedTypes;
 	}
 
     @Override

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=915744&r1=915743&r2=915744&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
Wed Feb 24 10:43:09 2010
@@ -34,6 +34,7 @@
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -97,7 +98,11 @@
         boolean dependentProducer = false;
         if(WebBeansUtil.isDependent(injectedBean))
         {
-            InjectionPointBean.local.set(injectionPoint);
+            if(!InjectionPoint.class.isAssignableFrom(ClassUtil.getClass(injectionPoint.getType())))
+            {
+                InjectionPointBean.local.set(injectionPoint);   
+            }
+            
             if(!injectionPoint.isTransient())
             {
                 if(injectedBean instanceof AbstractProducerBean)

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=915744&r1=915743&r2=915744&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
Wed Feb 24 10:43:09 2010
@@ -564,7 +564,7 @@
      * @param clazz impl. class
      * @return the new component
      */
-    public static <T> NewBean<T> createNewComponent(Class<T> clazz)
+    public static <T> NewBean<T> createNewComponent(Class<T> clazz, Type
apiType)
     {
         Asserts.nullCheckForClass(clazz);
 
@@ -592,7 +592,15 @@
 
         comp.addQualifier(new NewLiteral(clazz));
         comp.setName(null);
-        comp.addApiType(clazz);
+        if(apiType == null)
+        {
+            comp.addApiType(clazz);   
+        }
+        else
+        {
+            comp.getTypes().add(apiType);
+        }
+        
         comp.addApiType(Object.class);
 
         return comp;
@@ -1855,7 +1863,14 @@
         {
             AbstractOwbBean<?> bean = (AbstractOwbBean<?>)it.next();
             
-            if (bean.getTypes().contains(clazz))
+            boolean enterprise = false;
+            if(bean instanceof EnterpriseBeanMarker)
+            {
+                enterprise = true;
+            }
+            
+            if (bean.getTypes().contains(clazz) ||
+                    (enterprise && bean.getBeanClass().equals(clazz)))
             {
                 if(annotate)
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java?rev=915744&r1=915743&r2=915744&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java
Wed Feb 24 10:43:09 2010
@@ -13,6 +13,8 @@
  */
 package org.apache.webbeans.newtests.interceptors.lifecycle;
 
+import java.io.Serializable;
+
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.interceptor.Interceptor;
@@ -20,7 +22,7 @@
 
 @LifecycleBinding
 @Interceptor
-public class LifecycleInterceptor
+public class LifecycleInterceptor implements Serializable
 {
     public static boolean POST_CONSTRUCT = false;
     



Mime
View raw message