[weld-commits] Weld SVN: r5377 - in core/trunk/impl/src/main/java/org/jboss/weld: bean and 3 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Jan 4 07:31:47 EST 2010


Author: dallen6
Date: 2010-01-04 07:31:46 -0500 (Mon, 04 Jan 2010)
New Revision: 5377

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/WeldDecorator.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ExtensionBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
Log:
WELD-6

Modified: core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Validator.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Validator.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -71,9 +71,11 @@
 import org.jboss.weld.bean.AbstractClassBean;
 import org.jboss.weld.bean.AbstractProducerBean;
 import org.jboss.weld.bean.DisposalMethod;
+import org.jboss.weld.bean.InterceptorImpl;
 import org.jboss.weld.bean.NewManagedBean;
 import org.jboss.weld.bean.NewSessionBean;
 import org.jboss.weld.bean.RIBean;
+import org.jboss.weld.bean.WeldDecorator;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.bootstrap.api.Service;
 import org.jboss.weld.introspector.WeldAnnotated;
@@ -92,11 +94,11 @@
  * Checks a list of beans for DeploymentExceptions and their subclasses
  * 
  * @author Nicklas Karlsson
- * 
+ * @author David Allen
  */
 public class Validator implements Service
 {
-   
+
    private void validateBean(Bean<?> bean, BeanManagerImpl beanManager)
    {
       for (InjectionPoint ij : bean.getInjectionPoints())
@@ -109,12 +111,11 @@
          throw new UnproxyableResolutionException(NOT_PROXYABLE, bean);
       }
    }
-   
+
    /**
-    * Validate an RIBean.
+    * Validate an RIBean. This includes validating whether two beans specialize
+    * the same bean
     * 
-    * This includes validating whether two beans specialize the same bean
-    * 
     * @param bean the bean to validate
     * @param beanManager the current manager
     * @param specializedBeans the existing specialized beans
@@ -133,7 +134,7 @@
             }
             specializedBeans.add(abstractBean.getSpecializedBean());
          }
-         if (Beans.isPassivationCapableBean(bean) && bean instanceof AbstractClassBean<?>)
+         if ((bean instanceof AbstractClassBean<?>) && bean.isPassivationCapableBean())
          {
             AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean;
             if (classBean.hasDecorators())
@@ -154,22 +155,23 @@
       }
    }
 
+   @SuppressWarnings("unchecked")
    private void validateDirectlyDefinedInterceptorClasses(BeanManagerImpl beanManager, AbstractClassBean<?> classBean)
    {
-      InterceptionModel<Class<?>, Class<?>> ejbInterceptorModel = beanManager.getClassDeclaredInterceptorsRegistry().getInterceptionModel(((AbstractClassBean<?>) classBean).getType());
+      InterceptionModel<Class<?>, Class<?>> ejbInterceptorModel = beanManager.getClassDeclaredInterceptorsRegistry().getInterceptionModel(classBean.getType());
       if (ejbInterceptorModel != null)
       {
          Class<?>[] classDeclaredInterceptors = ejbInterceptorModel.getAllInterceptors().toArray(new Class<?>[ejbInterceptorModel.getAllInterceptors().size()]);
          if (classDeclaredInterceptors != null)
          {
-            for (Class<?> interceptorClass: classDeclaredInterceptors)
+            for (Class<?> interceptorClass : classDeclaredInterceptors)
             {
                if (!Reflections.isSerializable(interceptorClass))
                {
                   throw new DeploymentException(PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR, this, interceptorClass.getName());
                }
                InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) beanManager.createInjectionTarget(beanManager.createAnnotatedType(interceptorClass));
-               for (InjectionPoint injectionPoint: injectionTarget.getInjectionPoints())
+               for (InjectionPoint injectionPoint : injectionTarget.getInjectionPoints())
                {
                   Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(injectionPoint));
                   validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, beanManager);
@@ -181,33 +183,33 @@
 
    private void validateCdiBoundInterceptors(BeanManagerImpl beanManager, AbstractClassBean<?> classBean)
    {
-      InterceptionModel<Class<?>, SerializableContextual<Interceptor<?>, ?>> cdiInterceptorModel = beanManager.getCdiInterceptorsRegistry().getInterceptionModel(((AbstractClassBean<?>) classBean).getType());
+      InterceptionModel<Class<?>, SerializableContextual<Interceptor<?>, ?>> cdiInterceptorModel = beanManager.getCdiInterceptorsRegistry().getInterceptionModel(classBean.getType());
       if (cdiInterceptorModel != null)
+      {
+         Collection<SerializableContextual<Interceptor<?>, ?>> interceptors = cdiInterceptorModel.getAllInterceptors();
+         if (interceptors.size() > 0)
+         {
+            for (SerializableContextual<Interceptor<?>, ?> serializableContextual : interceptors)
             {
-               Collection<SerializableContextual<Interceptor<?>, ?>> interceptors = cdiInterceptorModel.getAllInterceptors();
-               if (interceptors.size() > 0)
+               if (!((InterceptorImpl<?>)serializableContextual.get()).isSerializable())
                {
-                  for (SerializableContextual<Interceptor<?>, ?> serializableContextual : interceptors)
-                  {
-                     if (!Reflections.isSerializable(serializableContextual.get().getBeanClass()))
-                     {
-                        throw new DeploymentException(PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR, this, serializableContextual.get());
-                     }
-                     for (InjectionPoint injectionPoint: serializableContextual.get().getInjectionPoints())
-                     {
-                        Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(injectionPoint));
-                        validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, beanManager);
-                     }
-                  }
+                  throw new DeploymentException(PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR, classBean, serializableContextual.get());
                }
+               for (InjectionPoint injectionPoint : serializableContextual.get().getInjectionPoints())
+               {
+                  Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(injectionPoint));
+                  validateInjectionPointPassivationCapable(injectionPoint, resolvedBean, beanManager);
+               }
             }
+         }
+      }
    }
 
    private void validateDecorators(BeanManagerImpl beanManager, AbstractClassBean<?> classBean)
    {
       for (Decorator<?> decorator : classBean.getDecorators())
       {
-         if (!Reflections.isSerializable(decorator.getBeanClass()))
+         if (!((WeldDecorator<?>)decorator).getAnnotatedItem().isSerializable())
          {
             throw new UnserializableDependencyException(PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR, classBean, decorator);
          }
@@ -223,7 +225,8 @@
     * Validate an injection point
     * 
     * @param ij the injection point to validate
-    * @param declaringBean the bean into which the injectionPoint has been injected, if null, certain validations aren't available
+    * @param declaringBean the bean into which the injectionPoint has been
+    *           injected, if null, certain validations aren't available
     * @param beanManager
     */
    public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManager)
@@ -238,7 +241,7 @@
       }
       if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(ij.getBean().getScope()))
       {
-         throw new DefinitionException(INJECTION_INTO_NON_DEPENDENT_BEAN, ij); 
+         throw new DefinitionException(INJECTION_INTO_NON_DEPENDENT_BEAN, ij);
       }
       if (ij.getType() instanceof TypeVariable<?>)
       {
@@ -255,7 +258,7 @@
       }
       if (resolvedBeans.size() > 1)
       {
-         throw new DeploymentException(INJECTION_POINT_HAS_AMBIGUOUS_DEPENDENCIES, ij, Arrays.toString(bindings) +"; Possible dependencies: " + resolvedBeans);
+         throw new DeploymentException(INJECTION_POINT_HAS_AMBIGUOUS_DEPENDENCIES, ij, Arrays.toString(bindings) + "; Possible dependencies: " + resolvedBeans);
       }
       Bean<?> resolvedBean = (Bean<?>) resolvedBeans.iterator().next();
       if (beanManager.getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScope()).isNormal() && !Proxies.isTypeProxyable(ij.getType()))
@@ -271,12 +274,12 @@
          validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
       }
    }
-   
+
    public void validateInjectionPointPassivationCapable(InjectionPoint ij, Bean<?> resolvedBean, BeanManagerImpl beanManager)
    {
       if (!ij.isTransient() && !Beans.isPassivationCapableDependency(resolvedBean))
       {
-         if (resolvedBean.getScope().equals(Dependent.class) && resolvedBean instanceof AbstractProducerBean<?, ?,?>)
+         if (resolvedBean.getScope().equals(Dependent.class) && resolvedBean instanceof AbstractProducerBean<?, ?, ?>)
          {
             throw new IllegalProductException(NON_SERIALIZABLE_BEAN_INJECTED_INTO_PASSIVATING_BEAN, ij.getBean(), resolvedBean);
          }
@@ -294,7 +297,7 @@
       validateDisposalMethods(environment);
       validateBeanNames(manager);
    }
-   
+
    public void validateBeans(Collection<? extends Bean<?>> beans, Collection<RIBean<?>> specializedBeans, BeanManagerImpl manager)
    {
       for (Bean<?> bean : beans)
@@ -309,17 +312,17 @@
          }
       }
    }
-   
+
    public void validateBeanNames(BeanManagerImpl beanManager)
    {
       Multimap<String, Bean<?>> namedAccessibleBeans = Multimaps.newSetMultimap(new HashMap<String, Collection<Bean<?>>>(), new Supplier<Set<Bean<?>>>()
       {
-         
+
          public Set<Bean<?>> get()
          {
             return new HashSet<Bean<?>>();
          }
-         
+
       });
       for (Bean<?> bean : beanManager.getAccessibleBeans())
       {
@@ -328,19 +331,19 @@
             namedAccessibleBeans.put(bean.getName(), bean);
          }
       }
-      
+
       List<String> accessibleNamespaces = new ArrayList<String>();
       for (String namespace : beanManager.getAccessibleNamespaces())
       {
          accessibleNamespaces.add(namespace);
       }
-      
+
       for (String name : namedAccessibleBeans.keySet())
       {
          Set<Bean<?>> resolvedBeans = beanManager.getBeanResolver().resolve(namedAccessibleBeans.get(name));
          if (resolvedBeans.size() > 1)
          {
-            throw new DeploymentException(AMBIGUOUS_EL_NAME, name, resolvedBeans );
+            throw new DeploymentException(AMBIGUOUS_EL_NAME, name, resolvedBeans);
          }
          if (accessibleNamespaces.contains(name))
          {
@@ -356,10 +359,9 @@
       {
          interceptorBeanClasses.add(interceptor.getBeanClass());
       }
-      for (Class<?> enabledInterceptorClass: beanManager.getEnabledInterceptorClasses())
+      for (Class<?> enabledInterceptorClass : beanManager.getEnabledInterceptorClasses())
       {
-         if (beanManager.getEnabledInterceptorClasses().indexOf(enabledInterceptorClass)
-               < beanManager.getEnabledInterceptorClasses().lastIndexOf(enabledInterceptorClass))
+         if (beanManager.getEnabledInterceptorClasses().indexOf(enabledInterceptorClass) < beanManager.getEnabledInterceptorClasses().lastIndexOf(enabledInterceptorClass))
          {
             throw new DeploymentException(INTERCEPTOR_SPECIFIED_TWICE, enabledInterceptorClass + " specified twice");
          }
@@ -369,7 +371,7 @@
          }
       }
    }
-   
+
    private void validateEnabledDecoratorClasses(BeanManagerImpl beanManager)
    {
       // TODO Move building this list to the boot or sth
@@ -391,7 +393,6 @@
       }
    }
 
-
    private void validateEnabledAlternatives(BeanManagerImpl beanManager)
    {
       List<Class<?>> seenAlternatives = new ArrayList<Class<?>>();
@@ -420,7 +421,7 @@
          seenAlternatives.add(clazz);
       }
    }
-   
+
    private void validateDisposalMethods(BeanDeployerEnvironment environment)
    {
       Set<DisposalMethod<?, ?>> beans = environment.getUnresolvedDisposalBeans();
@@ -451,10 +452,11 @@
             throw new DefinitionException(INJECTION_POINT_MUST_HAVE_TYPE_PARAMETER, type, injectionPoint);
          }
       }
-      
+
    }
 
+   public void cleanup()
+   {
+   }
 
-   public void cleanup() {}
-
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -41,7 +41,6 @@
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.Stereotype;
 import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.Bean;
 import javax.inject.Named;
 import javax.inject.Qualifier;
 
@@ -51,8 +50,6 @@
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.injection.WeldInjectionPoint;
 import org.jboss.weld.introspector.WeldAnnotated;
-import org.jboss.weld.introspector.WeldField;
-import org.jboss.weld.introspector.WeldParameter;
 import org.jboss.weld.literal.AnyLiteral;
 import org.jboss.weld.literal.DefaultLiteral;
 import org.jboss.weld.metadata.cache.MergedStereotypes;
@@ -301,24 +298,6 @@
       this.primitive = Reflections.isPrimitive(getType());
    }
 
-   private boolean checkInjectionPointsAreSerializable()
-   {
-      boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(this.getScope()).isPassivating();
-      for (WeldInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
-      {
-         Annotation[] bindings = injectionPoint.getMetaAnnotationsAsArray(Qualifier.class);
-         Bean<?> resolvedBean = manager.getBeans(injectionPoint.getJavaClass(), bindings).iterator().next();
-         if (passivating)
-         {
-            if (Dependent.class.equals(resolvedBean.getScope()) && !Reflections.isSerializable(resolvedBean.getBeanClass()) && (((injectionPoint instanceof WeldField<?, ?>) && !((WeldField<?, ?>) injectionPoint).isTransient()) || (injectionPoint instanceof WeldParameter<?, ?>)))
-            {
-               return false;
-            }
-         }
-      }
-      return true;
-   }
-
    /**
     * Initializes the scope type
     */

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -81,34 +81,38 @@
  * An abstract bean representation common for class-based beans
  * 
  * @author Pete Muir
+ * @author David Allen
  * 
- * @param <T>
- * @param <E>
+ * @param <T> the type of class for the bean
  */
 public abstract class AbstractClassBean<T> extends AbstractBean<T, Class<T>>
 {
    // Logger
    private static final LocLogger log = loggerFactory().getLogger(BEAN);
+
    // The item representation
    protected WeldClass<T> annotatedItem;
+
    // The injectable fields of each type in the type hierarchy, with the actual type at the bottom 
    private List<Set<FieldInjectionPoint<?, ?>>> injectableFields;
+
    // The initializer methods of each type in the type hierarchy, with the actual type at the bottom
    private List<Set<MethodInjectionPoint<?, ?>>> initializerMethods;
 
-   private List<Decorator<?>> decorators;
-
-   private Class<T> proxyClassForDecorators;
-
+   // Decorators
+   private List<Decorator<?>>         decorators;
+   private Class<T>                   proxyClassForDecorators;
    private final ThreadLocal<Integer> decoratorStackPosition;
+   private final ThreadLocal<T>       decoratedActualInstance = new ThreadLocal<T>();
 
-   private final ThreadLocal<T> decoratedActualInstance = new ThreadLocal<T>();
-
+   // Interceptors
    private boolean hasSerializationOrInvocationInterceptorMethods;
 
+   // Bean callback methods
    private WeldMethod<?, ?> postConstruct;
    private WeldMethod<?, ?> preDestroy;
    
+   // Injection target for the bean
    private InjectionTarget<T> injectionTarget;
 
    /**

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -42,6 +42,7 @@
 import java.lang.reflect.WildcardType;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.Callable;
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.NormalScope;
@@ -62,6 +63,7 @@
 import org.jboss.weld.metadata.cache.MetaAnnotationStore;
 import org.jboss.weld.util.Beans;
 import org.jboss.weld.util.Names;
+import org.jboss.weld.util.collections.ConcurrentCache;
 import org.jboss.weld.util.reflection.Reflections;
 import org.slf4j.cal10n.LocLogger;
 
@@ -69,17 +71,26 @@
  * The implicit producer bean
  * 
  * @author Gavin King
+ * @author David Allen
  * 
+ * @param <X>
  * @param <T>
  * @param <S>
  */
 public abstract class AbstractProducerBean<X, T, S extends Member> extends AbstractReceiverBean<X, T, S>
 {
+   // Logger for messages
    private static final LocLogger log = loggerFactory().getLogger(BEAN);
    
+   // Underlying Producer represented by this bean
    private Producer<T> producer;
+   
+   // Passivation flags
    private boolean passivationCapableBean;
    private boolean passivationCapableDependency;
+   
+   // Serialization cache for produced types at runtime
+   private ConcurrentCache<Class<?>, Boolean> serializationCheckCache;
 
    /**
     * Constructor
@@ -89,6 +100,7 @@
    public AbstractProducerBean(String idSuffix, AbstractClassBean<X> declaringBean, BeanManagerImpl manager)
    {
       super(idSuffix, declaringBean, manager);
+      serializationCheckCache = new ConcurrentCache<Class<?>, Boolean>();
    }
 
    @Override
@@ -230,7 +242,8 @@
       else if (instance != null)
       {
          boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(getScope()).isPassivating();
-         if (passivating && !Reflections.isSerializable(instance.getClass()))
+         boolean instanceSerializable = isTypeSerializable(instance.getClass());
+         if (passivating && !instanceSerializable)
          {
             throw new IllegalProductException(NON_SERIALIZABLE_PRODUCT_ERROR, getProducer());
          }
@@ -239,11 +252,11 @@
          {
             return;
          }
-         if (!Reflections.isSerializable(instance.getClass()) && Beans.isPassivatingScope(injectionPoint.getBean(), manager))
+         if (!instanceSerializable && Beans.isPassivatingScope(injectionPoint.getBean(), manager))
          {
             if (injectionPoint.getMember() instanceof Field)
             {
-               if (!injectionPoint.isTransient() && instance != null && !Reflections.isSerializable(instance.getClass()))
+               if (!injectionPoint.isTransient() && instance != null && !instanceSerializable)
                {
                   throw new IllegalProductException(NON_SERIALIZABLE_FIELD_INJECTION_ERROR, this, injectionPoint);
                }
@@ -268,6 +281,19 @@
       }
    }
 
+   protected boolean isTypeSerializable(final Class<?> clazz)
+   {
+      return serializationCheckCache.putIfAbsent(clazz, new Callable<Boolean>()
+      {
+
+         public Boolean call() throws Exception
+         {
+            return Reflections.isSerializable(clazz);
+         }
+
+      });
+   }
+
    @Override
    protected void initScopeType()
    {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -45,11 +45,14 @@
    private final InterceptorClassMetadata interceptorClassMetadata;
 
    private final Set<Annotation> interceptorBindingTypes;
+   
+   private boolean serializable;
 
    protected InterceptorImpl(WeldClass<T> type, BeanManagerImpl manager)
    {
       super(type, new StringBuilder().append(Interceptor.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(type.getName()).toString(), manager);
       this.interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(type.getJavaClass());
+      this.serializable = type.isSerializable();
       this.interceptorBindingTypes = new HashSet<Annotation>();
       interceptorBindingTypes.addAll(flattenInterceptorBindings(manager, getAnnotatedItem().getAnnotations()));
       for (Class<? extends Annotation> annotation : getStereotypes())
@@ -92,6 +95,11 @@
       return interceptorClassMetadata.getInterceptorMethods(org.jboss.interceptor.model.InterceptionType.valueOf(type.name())).size() > 0;
    }
 
+   public boolean isSerializable()
+   {
+      return serializable;
+   }
+
    @Override
    protected void defaultPostConstruct(T instance) 
    {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -284,7 +284,7 @@
       {
          for (Decorator<?> decorator : this.getDecorators())
          {
-            if (!(PassivationCapable.class.isAssignableFrom(decorator.getClass())) || !Reflections.isSerializable(decorator.getBeanClass()))
+            if (!(PassivationCapable.class.isAssignableFrom(decorator.getClass())) || !((WeldDecorator<?>)decorator).getAnnotatedItem().isSerializable())
             {
                this.passivationCapableBean = false;
                break;
@@ -295,7 +295,7 @@
       {
          for (SerializableContextual<Interceptor<?>, ?> interceptor : getManager().getCdiInterceptorsRegistry().getInterceptionModel(getType()).getAllInterceptors())
          {
-            if (!(PassivationCapable.class.isAssignableFrom(interceptor.get().getClass())) || !Reflections.isSerializable(interceptor.get().getBeanClass()))
+            if (!(PassivationCapable.class.isAssignableFrom(interceptor.get().getClass())) || !((InterceptorImpl<?>)interceptor.get()).isSerializable())
             {
                this.passivationCapableBean = false;
                break;
@@ -317,7 +317,7 @@
 
    private void initPassivationCapable()
    {
-      this.passivationCapableBean = Reflections.isSerializable(getAnnotatedItem().getJavaClass());
+      this.passivationCapableBean = getAnnotatedItem().isSerializable();
       if (Container.instance().deploymentServices().get(MetaAnnotationStore.class).getScopeModel(getScope()).isNormal())
       {
          this.passivationCapableDependency = true;

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/WeldDecorator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/WeldDecorator.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/WeldDecorator.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -35,8 +35,8 @@
 public interface WeldDecorator<T> extends Decorator<T>
 {
 
-   WeldClass<?> getAnnotatedItem();
+   public WeldClass<?> getAnnotatedItem();
 
-   Set<MethodSignature> getDecoratedMethodSignatures();
+   public Set<MethodSignature> getDecoratedMethodSignatures();
    
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ExtensionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ExtensionBean.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ExtensionBean.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -26,7 +26,6 @@
 
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.introspector.WeldClass;
-import org.jboss.weld.util.reflection.Reflections;
 
 /**
  * @author pmuir
@@ -47,7 +46,7 @@
       super(new StringBuilder().append(ID_PREFIX).append(BEAN_ID_SEPARATOR).append(clazz.getName()).toString(), manager);
       this.clazz = clazz;
       this.instance = instance;
-      this.passivationCapable = Reflections.isSerializable(clazz.getJavaClass());
+      this.passivationCapable = clazz.isSerializable();
    }
 
    @Override

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -137,7 +137,12 @@
    {
       return delegate().isEnum();
    }
-   
+
+   public boolean isSerializable()
+   {
+      return delegate().isSerializable();
+   }
+
    @Deprecated
    public WeldMethod<?, ?> getDeclaredWeldMethod(Method method)
    {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -216,6 +216,8 @@
    
    public boolean isAnonymousClass();
 
+   public boolean isSerializable();
+
    public <S> S cast(Object object);
 
    public <U> WeldClass<? extends U> asWeldSubclass(WeldClass<U> clazz);

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java	2010-01-03 13:30:58 UTC (rev 5376)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java	2010-01-04 12:31:46 UTC (rev 5377)
@@ -59,23 +59,28 @@
  * This class is immutable, and therefore threadsafe
  * 
  * @author Pete Muir
+ * @author David Allen
  * 
- * @param <T>
+ * @param <T> the type of the class
  */
 public class WeldClassImpl<T> extends AbstractWeldAnnotated<T, Class<T>> implements WeldClass<T>
 {
    
-// The superclass abstraction of the type
+   // Class attributes
    private final WeldClass<?> superclass;
-   // The name of the type
-   private final String name;
-   
-   private final String _simpleName;
-   private final boolean _public;
-   private final boolean _private;
-   private final boolean _packagePrivate;
-   private final Package _package;
-  
+   private final String       name;
+   private final String       _simpleName;
+   private final boolean      _public;
+   private final boolean      _private;
+   private final boolean      _packagePrivate;
+   private final Package      _package;
+   private final boolean      _abstract;
+   private final boolean      _member;
+   private final boolean      _local;
+   private final boolean      _anonymous;
+   private final boolean      _enum;
+   private final boolean      _serializable;
+
    private static List<Class<?>> NO_ARGUMENTS = Collections.emptyList();
 
    // The set of abstracted fields
@@ -122,11 +127,6 @@
    // Cached string representation
    private final String toString;
 
-   private final boolean _abstract;
-   private final boolean _member;
-   private final boolean _local;
-   private final boolean _anonymous;
-   private final boolean _enum;
 
    public static <T> WeldClass<T> of(Class<T> clazz, ClassTransformer classTransformer)
    {
@@ -150,6 +150,8 @@
    {
       super(annotationStore, rawType, type, typeClosure);
       this.toString = "class " + Names.classToString(rawType);
+      
+      // Assign class attributes
       this.name = rawType.getName();
       this._simpleName = rawType.getSimpleName();
       if (rawType.getSuperclass() != null)
@@ -164,7 +166,14 @@
       this._private = Modifier.isPrivate(rawType.getModifiers());
       this._packagePrivate = Reflections.isPackagePrivate(rawType.getModifiers());
       this._package = rawType.getPackage();
+      this._local = rawType.isLocalClass();
+      this._anonymous = rawType.isAnonymousClass();
+      this._member = rawType.isMemberClass();
+      this._abstract = Reflections.isAbstract(rawType);
+      this._enum = rawType.isEnum();
+      this._serializable = Reflections.isSerializable(rawType);
       
+      // Assign class field information
       this.fields = new HashSet<WeldField<?, ?>>();
       this.annotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), new Supplier< Set<WeldField<?, ?>>>()
       {
@@ -204,12 +213,6 @@
          }
         
       });
-      this._local = rawType.isLocalClass();
-      this._anonymous = rawType.isAnonymousClass();
-      this._member = rawType.isMemberClass();
-      this._abstract = Reflections.isAbstract(rawType);
-      this._enum = rawType.isEnum();
-
       
       Map<Field, AnnotatedField<? super T>> annotatedTypeFields = new HashMap<Field, AnnotatedField<? super T>>();
       if (annotatedType != null)
@@ -264,6 +267,7 @@
          }
       }
 
+      // Assign constructor information
       this.constructors = new HashSet<WeldConstructor<T>>();
       this.constructorsByArgumentMap = new HashMap<List<Class<?>>, WeldConstructor<T>>();
       this.annotatedConstructors = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldConstructor<T>>>(), new Supplier< Set<WeldConstructor<T>>>()
@@ -337,6 +341,7 @@
          }
       }
 
+      // Assign method information
       this.methods = new HashSet<WeldMethod<?, ?>>();
       this.annotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, ?>>>(), new Supplier< Set<WeldMethod<?, ?>>>()
       {
@@ -569,6 +574,11 @@
       return _enum;
    }
 
+   public boolean isSerializable()
+   {
+      return _serializable;
+   }
+
    /**
     * Gets the abstracted methods that have a certain annotation type present
     * 



More information about the weld-commits mailing list