openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r915604 - 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 00:10:34 GMT
Author: gerdogdu
Date: Wed Feb 24 00:10:33 2010
New Revision: 915604

URL: http://svn.apache.org/viewvc?rev=915604&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/component/OwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.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/inject/instance/InstanceImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.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/portable/events/extensions/AddBeanExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/ExternalTestScopedBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/common/Person.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=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -33,6 +33,8 @@
 import org.apache.webbeans.config.inheritance.BeanInheritedMetaData;
 import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.decorator.WebBeansDecorator;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.inject.InjectableField;
 import org.apache.webbeans.inject.InjectableMethods;
@@ -40,6 +42,7 @@
 import org.apache.webbeans.intercept.InterceptorHandler;
 import org.apache.webbeans.intercept.InterceptorType;
 import org.apache.webbeans.intercept.InvocationContextImpl;
+import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.spi.ServiceLoader;
@@ -657,6 +660,51 @@
     public boolean isFullyInitialize()
     {
         return this.fullyInitialize;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractOwbBean#validatePassivationDependencies()
+     */
+    @Override
+    public void validatePassivationDependencies()
+    {
+        if(isPassivationCapable())
+        {
+            super.validatePassivationDependencies();
+            
+            //Check for interceptors and decorators
+            for(Decorator<?> dec : this.decorators)
+            {
+                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() + " interceptors must be passivating capable");
+                    }
+                    else
+                    {
+                        interceptor.validatePassivationDependencies();
+                    }
+                }
+            }
+            
+        }
     }    
     
+    
+    
 }
\ No newline at end of file

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=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -33,9 +33,11 @@
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.WebBeansUtil;
 
 /**
  * Abstract implementation of the {@link OwbBean} contract. 
@@ -587,4 +589,24 @@
         return getScope().equals(Dependent.class);
     }
     
+    @Override
+    public void validatePassivationDependencies()
+    {
+        if(isPassivationCapable())
+        {
+            Set<InjectionPoint> injectionPoints = getInjectionPoints();
+            for(InjectionPoint injectionPoint : injectionPoints)
+            {
+                if(!injectionPoint.isTransient())
+                {
+                    if(!WebBeansUtil.isPassivationCapableDependency(injectionPoint))
+                    {
+                        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/component/OwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
Wed Feb 24 00:10:33 2010
@@ -20,6 +20,8 @@
 
 import javax.enterprise.inject.spi.*;
 
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+
 /**
  * OWB specific extension of the {@link Bean} interface.
  * It is used internally. Do not use it. Instead use {@link AbstractOwbBean}
@@ -179,4 +181,10 @@
      * @return <code>true</code> if this is a dependent bean
      */
     public boolean isDependent();
+    
+    /**
+     * If bean is passivation capable, it validate all of its dependencies.
+     * @throws WebBeansConfigurationException if not satisfy passivation dependencies
+     */
+    public void validatePassivationDependencies();
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -37,6 +37,7 @@
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.NewBean;
+import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
 import org.apache.webbeans.component.creation.BeanCreator.MetaDataProvider;
@@ -297,17 +298,23 @@
         {
             for (Bean<?> bean : beans)
             {
-                checkPassivationScope(bean);
-                
                 //Configure decorator and interceptor stack for ManagedBeans
                 if((bean instanceof AbstractInjectionTargetBean) && 
-                        !(bean instanceof NewBean) &&
-                        !(bean instanceof EnterpriseBeanMarker))
+                        !(bean instanceof NewBean))
                 {
-                    DefinitionUtil.defineDecoratorStack((AbstractInjectionTargetBean<Object>)bean);
-                    DefinitionUtil.defineBeanInterceptorStack((AbstractInjectionTargetBean<Object>)bean);
+                    if(!(bean instanceof Decorator) && !(bean instanceof javax.enterprise.inject.spi.Interceptor))
+                    {
+                        DefinitionUtil.defineDecoratorStack((AbstractInjectionTargetBean<Object>)bean);
  
+                    }
+                    
+                    if(!(bean instanceof javax.enterprise.inject.spi.Interceptor))
+                    {
+                        DefinitionUtil.defineBeanInterceptorStack((AbstractInjectionTargetBean<Object>)bean);
  
+                    }
                 }
                 
+                checkPassivationScope(bean);
+                                
                 //Bean injection points
                 Set<InjectionPoint> injectionPoints = bean.getInjectionPoints();
                                 
@@ -510,17 +517,7 @@
      */
     protected void checkPassivationScope(Bean<?> beanObj)
     {
-        if (beanObj instanceof ManagedBean)
-        {
-            ManagedBean<?> bean = (ManagedBean<?>) beanObj;
-            if(BeanManagerImpl.getManager().isPassivatingScope(bean.getScope()))
-            {
-                if(!bean.isPassivationCapable())
-                {
-                    throw new WebBeansConfigurationException("Bean : " + bean.toString()+
 " must be passivation capable becuase it defines passivation capable scope");
-                }
-            }
-        }
+        ((OwbBean<?>)beanObj).validatePassivationDependencies();
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Wed Feb 24 00:10:33 2010
@@ -841,6 +841,15 @@
         {
             for (Field field : fields)
             {
+                //Check for public fields
+                if(ClassUtil.isPublic(field.getModifiers()) && !ClassUtil.isStatic(field.getModifiers()))
+                {
+                    if(!component.getScope().equals(Dependent.class))
+                    {
+                        throw new WebBeansConfigurationException("If bean has a public field,
bean scope must be defined as @Dependent");
+                    }
+                }                
+                                
                 if(!useOwbSpecificInjection)
                 {
                     if(!field.isAnnotationPresent(Inject.class))
@@ -849,14 +858,6 @@
                     }                       
                 }
                 
-                if(ClassUtil.isPublic(field.getModifiers()))
-                {
-                    if(!component.getScope().equals(Dependent.class))
-                    {
-                        throw new WebBeansConfigurationException("If bean has a public modifier
injection point, bean scope must be defined as @Dependent");
-                    }
-                }                
-                
                 Annotation[] anns = field.getDeclaredAnnotations();
 
                 // Injected fields can not be @Produces

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=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -48,6 +48,7 @@
 import javax.enterprise.inject.spi.*;
 import javax.enterprise.util.TypeLiteral;
 import javax.inject.Scope;
+import javax.interceptor.InterceptorBinding;
 import javax.naming.NamingException;
 import javax.naming.Reference;
 import javax.naming.Referenceable;
@@ -691,12 +692,15 @@
     @Override
     public Set<Annotation> getInterceptorBindingDefinition(Class<? extends Annotation>
binding)
     {
-        Annotation[] annotations = AnnotationUtil.getInterceptorBindingMetaAnnotations(binding.getDeclaredAnnotations());
+        Annotation[] annotations = binding.getDeclaredAnnotations();
         Set<Annotation> set = new HashSet<Annotation>();
         
-        for(Annotation ann : annotations)
+        if(binding.isAnnotationPresent(InterceptorBinding.class))
         {
-            set.add(ann);
+            for(Annotation ann : annotations)
+            {
+                set.add(ann);
+            }            
         }
         
         return set;
@@ -816,12 +820,15 @@
     @Override
     public Set<Annotation> getStereotypeDefinition(Class<? extends Annotation>
stereotype)
     {
-        Annotation[] annotations = AnnotationUtil.getStereotypeMetaAnnotations(stereotype.getDeclaredAnnotations());
+        Annotation[] annotations = stereotype.getDeclaredAnnotations();
         Set<Annotation> set = new HashSet<Annotation>();
         
-        for(Annotation ann : annotations)
+        if(stereotype.isAnnotationPresent(Stereotype.class))
         {
-            set.add(ann);
+            for(Annotation ann : annotations)
+            {
+                set.add(ann);
+            }            
         }
         
         return set;
@@ -842,10 +849,19 @@
     @Override
     public boolean isScope(Class<? extends Annotation> annotationType)
     {
-        if(AnnotationUtil.hasAnnotation(annotationType.getDeclaredAnnotations(), Scope.class))
+        if(AnnotationUtil.hasAnnotation(annotationType.getDeclaredAnnotations(), Scope.class)
||
+                AnnotationUtil.hasAnnotation(annotationType.getDeclaredAnnotations(), NormalScope.class))
         {
             return true;
         }
+        
+        for(ExternalScope ext : this.additionalScopes)
+        {
+            if(ext.getScope().equals(annotationType))
+            {
+                return true;
+            }
+        }
      
         return false;
     }
@@ -853,6 +869,14 @@
     @Override
     public boolean isNormalScope(Class<? extends Annotation> annotationType)
     {
+        for (ExternalScope extScope : additionalScopes)
+        {
+            if (extScope.getScope().equals(annotationType))
+            {
+                return extScope.isNormal();
+            }
+        }
+        
         if(AnnotationUtil.hasAnnotation(annotationType.getDeclaredAnnotations(), NormalScope.class))
         {
             return true;
@@ -933,8 +957,7 @@
         // check for InjectionPoint injection
         if (rawType.equals(InjectionPoint.class))
         {
-            Annotated annotated = injectionPoint.getAnnotated();
-            if (annotated.getAnnotations().size() == 1 && annotated.isAnnotationPresent(Default.class))
+            if (AnnotationUtil.hasAnnotation(AnnotationUtil.getAnnotationsFromSet(injectionPoint.getQualifiers()),
Default.class))
             {
                 if (!bean.getScope().equals(Dependent.class))
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
Wed Feb 24 00:10:33 2010
@@ -14,7 +14,6 @@
 package org.apache.webbeans.decorator;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.util.HashSet;
@@ -22,7 +21,6 @@
 import java.util.List;
 import java.util.Set;
 
-import javax.decorator.Delegate;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.Decorator;
@@ -84,70 +82,8 @@
             decoratorSet.remove(java.io.Serializable.class);
         }
         
-        //No-Decorates found, check from super class
-        if(!checkInternalDecoratorConditions(decoratorClazz, decoratorSet))
-        {
-           boolean found = checkInternalDecoratorConditionsRecursivley(decoratorClazz,decoratorSet);
-           
-           if(!found)
-           {
-               throw new WebBeansConfigurationException(logger.getTokenString(OWBLogConst.EXCEPT_0011)
+ decoratorClazz.getName());
-           }
-        }
-    }
-    
-    private static boolean checkInternalDecoratorConditionsRecursivley(Class<?> decoratorClazz,Set<Type>
decoratorSet)
-    {
-        Class<?> superClazz = decoratorClazz.getSuperclass();
-        if(!superClazz.equals(Object.class))
-        {
-            boolean found = checkInternalDecoratorConditions(superClazz, decoratorSet);
-            if(!found)
-            {
-                return checkInternalDecoratorConditionsRecursivley(superClazz, decoratorSet);
-            }
-            else
-            {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    private static boolean checkInternalDecoratorConditions(Class<?> decoratorClazz,Set<Type>
decoratorSet)
-    {
-        Field[] fields = decoratorClazz.getDeclaredFields();
-        boolean found = false;
-        for (Field field : fields)
-        {
-            if (AnnotationUtil.hasAnnotation(field.getDeclaredAnnotations(), Delegate.class))
-            {
-                if (found)
-                {
-                    throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz.getName()
+ " can only contain one delegate attribute but find more than one!.");
-                }
-                else
-                {
-                    Class<?> fieldType = field.getType();
-
-                    for (Type decType : decoratorSet)
-                    {
-                        if (!(ClassUtil.getClass(decType)).isAssignableFrom(fieldType))
-                        {
-                            throw new WebBeansConfigurationException("Decorator class : "
+ decoratorClazz.getName() + " delegate attribute must implement all of the decorator decorated
types.");
-                        }
-                    }
-
-                    found = true;
-                }
-            }
-        }
-        
-        return found;
-        
     }
-
+   
     public static void checkManagedBeanDecoratorConditions(ManagedBean<?> component)
     {
         Asserts.assertNotNull("component", "component parameter can not be null");

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=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -147,7 +147,12 @@
         
     }
     
-    
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return this.wrappedBean.isPassivationCapable();
+    }
+
     private void initDelegateInternal(InjectionPoint ip)
     {
         this.delegateType = ip.getType();
@@ -165,7 +170,7 @@
                 throw new WebBeansConfigurationException("Delegate injection field is not
found for decorator : " + toString());
             }
             
-            if(fields.length > 0)
+            if(fields.length > 1)
             {
                 throw new WebBeansConfigurationException("More than one delegate injection
field is found for decorator : " + toString());
             }
@@ -471,4 +476,11 @@
     {
         return this.wrappedBean.isAlternative();
     }
+    
+    @Override
+    public void validatePassivationDependencies()
+    {
+        this.wrappedBean.validatePassivationDependencies();
+    }    
+    
 }

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=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.inject;
 
+import java.io.Serializable;
 import java.lang.reflect.Member;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -20,10 +21,12 @@
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Event;
+import javax.enterprise.inject.IllegalProductException;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Provider;
 
+import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.component.EventBean;
 import org.apache.webbeans.component.InjectionPointBean;
 import org.apache.webbeans.component.InstanceBean;
@@ -91,13 +94,33 @@
         }        
         
         //Injection for dependent instance InjectionPoint fields
+        boolean dependentProducer = false;
         if(WebBeansUtil.isDependent(injectedBean))
         {
             InjectionPointBean.local.set(injectionPoint);
+            if(!injectionPoint.isTransient())
+            {
+                if(injectedBean instanceof AbstractProducerBean)
+                {
+                    if(this.injectionOwnerBean.isPassivationCapable())
+                    {
+                        dependentProducer = true;   
+                    }
+                }
+            }
         }        
         
         injected = BeanManagerImpl.getManager().getInjectableReference(injectionPoint, this.injectionOwnerCreationalContext);
-                
+        
+        if(dependentProducer)
+        {
+            if(!Serializable.class.isAssignableFrom(injected.getClass()))
+            {
+                throw new IllegalProductException("If a producer method or field of scope
@Dependent returns an serializable object for injection " +
+                		                                "into an injection point "+ injectionPoint
+" that requires a passivation capable dependency");
+            }
+        }
+        
 
         return injected;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
Wed Feb 24 00:10:33 2010
@@ -13,6 +13,8 @@
  */
 package org.apache.webbeans.inject.instance;
 
+import java.io.IOException;
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.HashSet;
@@ -34,7 +36,7 @@
  * 
  * @param <T> specific instance type
  */
-class InstanceImpl<T> implements Instance<T>
+class InstanceImpl<T> implements Instance<T>, Serializable
 {
     /** Injected class type */
     private Type injectionClazz;
@@ -235,4 +237,28 @@
 
         return builder.toString();
     }
+    
+    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
+    {
+        this.injectionClazz = (Type)in.readObject();
+        int q = in.readByte();
+        if(q != 0)
+        {
+            this.qualifierAnnotations = new HashSet<Annotation>();
+            for(int i =0; i< q; i++)
+            {
+                this.qualifierAnnotations.add((Annotation)in.readObject());
+            }
+        }
+    }
+    
+    private void writeObject(java.io.ObjectOutputStream out) throws IOException
+    {
+        out.writeObject(this.injectionClazz);
+        out.writeByte(this.qualifierAnnotations.size());
+        for(Annotation ann : this.qualifierAnnotations)
+        {
+            out.writeObject(ann);
+        }
+    }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Wed Feb 24 00:10:33 2010
@@ -27,6 +27,7 @@
 import javax.annotation.PreDestroy;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.interceptor.AroundInvoke;
 
@@ -34,6 +35,7 @@
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.util.AnnotationUtil;
@@ -69,14 +71,32 @@
         logger.debug("Configuring interceptor class : " + delegate.getReturnType());
         WebBeansInterceptor<T> interceptor = new WebBeansInterceptor<T>(delegate);
 
+        List<Annotation> anns = Arrays.asList(interceptorBindingTypes);
+        
         for (Annotation ann : interceptorBindingTypes)
         {
+            checkAnns(anns, ann, delegate);
             interceptor.addInterceptorBinding(ann.annotationType(), ann);
         }
+                
 
         BeanManagerImpl.getManager().addInterceptor(interceptor);
 
     }
+    
+    private static void checkAnns(List<Annotation> list, Annotation ann, Bean<?>
bean)
+    {
+        for(Annotation old : list)
+        {
+            if(old.annotationType().equals(ann.annotationType()))
+            {
+                if(!AnnotationUtil.hasAnnotationMember(ann.annotationType(), ann, old))
+                {
+                    throw new WebBeansConfigurationException("Interceptor Binding types must
be equal for interceptor : " + bean);
+                }                
+            }
+        }
+    }
 
     /**
      * Configures the given class for applicable interceptors.
@@ -174,9 +194,16 @@
                 }
             }
         }
-
+        
         anns = new Annotation[bindingTypeSet.size()];
         anns = bindingTypeSet.toArray(anns);
+        
+        //Spec Section 9.5.2
+        List<Annotation> beanAnnots = Arrays.asList(anns);
+        for(Annotation checkAnn : anns)
+        {
+            checkAnns(beanAnnots, checkAnn, component);
+        }
 
         if (anns.length > 0)
         {
@@ -237,6 +264,21 @@
     {
         // All methods, not just those declared
         Method[] methods = clazz.getMethods();
+        Set<Method> set = new HashSet<Method>();
+        for(Method m : methods)
+        {
+            set.add(m);
+        }
+        
+        //GE : I added for private, protected etc. methods.
+        //Not just for public methods.
+        methods = clazz.getDeclaredMethods();
+        for(Method m : methods)
+        {
+            set.add(m);
+        }
+        
+        methods = set.toArray(new Method[0]);
 
         for (Method method : methods)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Wed Feb 24 00:10:33 2010
@@ -460,6 +460,14 @@
     @Override
     public boolean isPassivationCapable()
     {
-        return true;
+        return this.delegateBean.isPassivationCapable();
+    }
+
+    @Override
+    public void validatePassivationDependencies()
+    {
+        this.delegateBean.validatePassivationDependencies();
     }    
+    
+    
 }
\ No newline at end of file

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=915604&r1=915603&r2=915604&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 00:10:33 2010
@@ -115,6 +115,7 @@
 import org.apache.webbeans.component.NewBean;
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
 import org.apache.webbeans.config.DefinitionUtil;
@@ -123,6 +124,7 @@
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.ExternalScope;
+import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.conversation.ConversationImpl;
 import org.apache.webbeans.decorator.DecoratorUtil;
@@ -570,6 +572,7 @@
         if (ManagedBeanConfigurator.isManagedBean(clazz))
         {
             comp = new NewBean<T>(clazz, WebBeansType.MANAGED);
+            comp.setImplScopeType(new DependentScopeLiteral());
             comp.setConstructor(WebBeansUtil.defineConstructor(clazz));
             DefinitionUtil.addConstructorInjectionPointMetaData(comp, comp.getConstructor());
 
@@ -579,13 +582,13 @@
         else if (EJBWebBeansConfigurator.isSessionBean(clazz))
         {
             comp = new NewBean<T>(clazz, WebBeansType.ENTERPRISE);
+            comp.setImplScopeType(new DependentScopeLiteral());
         }
         else
         {
             throw new WebBeansConfigurationException("@New annotation on type : " + clazz.getName()
+ " must defined as a simple or an enterprise web bean");
         }
 
-        comp.setImplScopeType(new DependentScopeLiteral());
         comp.addQualifier(new NewLiteral(clazz));
         comp.setName(null);
         comp.addApiType(clazz);
@@ -2070,20 +2073,15 @@
         
     }
     
-    public static void checkSerializableScopeType(Class<?> scopeType, boolean isSerializable,
String errorMessage)
+    public static void checkSerializableScopeType(Class<? extends Annotation> scopeType,
boolean isSerializable, String errorMessage)
     {
-        // Scope type check
-        NormalScope scope = scopeType.getAnnotation(NormalScope.class);
-        if(scope != null)
+        if (BeanManagerImpl.getManager().isPassivatingScope(scopeType))
         {
-            if (scope.passivating())
+            if (!isSerializable)
             {
-                if (!isSerializable)
-                {
-                    throw new IllegalProductException(errorMessage);
-                }
-            }            
-        }
+                throw new IllegalProductException(errorMessage);
+            }
+        }            
     }
     
     public static boolean isManagedBean(AbstractOwbBean<?> component)
@@ -2757,4 +2755,32 @@
         return false;
     }
     
+    public static boolean isPassivationCapableDependency(InjectionPoint injectionPoint)
+    {
+        Bean<?> bean = InjectionResolver.getInstance().getInjectionPointBean(injectionPoint);
+        if((bean instanceof EnterpriseBeanMarker) ||
+                (bean instanceof ResourceBean) ||
+                (bean instanceof InstanceBean) ||
+                (bean instanceof EventBean) ||
+                (bean instanceof InjectionPointBean) ||
+                (bean instanceof BeanManagerBean)
+                )
+        {
+            return true;
+        }
+        
+        else if(BeanManagerImpl.getManager().isNormalScope(bean.getScope()))
+        {
+            return true;
+        }        
+        else
+        {
+            if(isPassivationCapable(bean) != null)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+    
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
Wed Feb 24 00:10:33 2010
@@ -30,6 +30,8 @@
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessBean;
 
+import org.apache.webbeans.annotation.DependentScopeLiteral;
+
 public class AddBeanExtension implements Extension
 {
     public static class MyBean
@@ -82,8 +84,7 @@
             @Override
             public Class<? extends Annotation> getScope()
             {
-                // TODO Auto-generated method stub
-                return null;
+                return new DependentScopeLiteral().annotationType();
             }
 
             @Override

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/ExternalTestScopedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/ExternalTestScopedBean.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/ExternalTestScopedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/ExternalTestScopedBean.java
Wed Feb 24 00:10:33 2010
@@ -25,7 +25,7 @@
 
 	private static final long serialVersionUID = -917790714891819356L;
 	
-	public int i = 0;
+	private int i = 0;
 
     public int getI() {
         return i;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/common/Person.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/common/Person.java?rev=915604&r1=915603&r2=915604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/common/Person.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/common/Person.java
Wed Feb 24 00:10:33 2010
@@ -18,7 +18,9 @@
  */
 package org.apache.webbeans.newtests.promethods.common;
 
-public class Person
+import java.io.Serializable;
+
+public class Person implements Serializable
 {
 
 }



Mime
View raw message