Author: pete.muir(a)jboss.org
Date: 2009-03-24 19:33:28 -0400 (Tue, 24 Mar 2009)
New Revision: 2196
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
Log:
WBRI-206
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-24 21:17:57
UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-24 23:33:28
UTC (rev 2196)
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.Set;
+import javax.context.Dependent;
import javax.event.Event;
import javax.event.Fires;
import javax.inject.AmbiguousDependencyException;
@@ -107,7 +108,7 @@
{
throw new NullableDependencyException("The injection point " +
injectionPoint + " has nullable dependencies");
}
- if (Beans.isPassivatingBean(bean) && !resolvedBean.isSerializable())
+ if (Beans.isPassivatingBean(bean) && !resolvedBean.isSerializable()
&& resolvedBean.getScopeType().equals(Dependent.class))
{
throw new UnserializableDependencyException("The bean " + bean +
" declares a passivating scopes but has non-serializable dependencies");
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-03-24
21:17:57 UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-03-24
23:33:28 UTC (rev 2196)
@@ -17,7 +17,6 @@
package org.jboss.webbeans.bean;
-import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Arrays;
@@ -260,16 +259,14 @@
this.primitive = Reflections.isPrimitive(getType());
}
- protected boolean checkInjectionPointsAreSerializable()
+ private boolean checkInjectionPointsAreSerializable()
{
- // TODO CACHE THIS and rebuild on addBean
- // TODO: a bit crude, don't check *all* injectionpoints, only those listed
- // in the spec for passivation checks
+ boolean passivating =
MetaDataCache.instance().getScopeModel(this.getScopeType()).isPassivating();
for (AnnotatedInjectionPoint<?, ?> injectionPoint : getInjectionPoints())
{
Annotation[] bindings =
injectionPoint.getMetaAnnotationsAsArray(BindingType.class);
Bean<?> resolvedBean = manager.resolveByType(injectionPoint.getRawType(),
bindings).iterator().next();
- if
(MetaDataCache.instance().getScopeModel(this.getScopeType()).isPassivating())
+ if (passivating)
{
if (Dependent.class.equals(resolvedBean.getScopeType()) &&
!resolvedBean.isSerializable() && (((injectionPoint instanceof AnnotatedField)
&& !((AnnotatedField<?>) injectionPoint).isTransient()) || (injectionPoint
instanceof AnnotatedParameter)) )
{
@@ -501,12 +498,12 @@
@Override
public boolean isSerializable()
{
- return _serializable;
+ return _serializable && checkInjectionPointsAreSerializable();
}
protected void initSerializable()
{
- _serializable = isPrimitive() || getTypes().contains(Serializable.class);
+ _serializable = Reflections.isSerializable(type);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-24
21:17:57 UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-24
23:33:28 UTC (rev 2196)
@@ -337,9 +337,9 @@
}
@Override
- public boolean isSerializable()
+ protected void initSerializable()
{
- return checkInjectionPointsAreSerializable();
+ super._serializable = true;
}
public InternalEjbDescriptor<T> getEjbDescriptor()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-03-24
21:17:57 UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-03-24
23:33:28 UTC (rev 2196)
@@ -34,7 +34,6 @@
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
-import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Names;
/**
@@ -228,19 +227,8 @@
buffer.append("API types " + getTypes() + ", binding types " +
getBindings());
return buffer.toString();
}
-
+
@Override
- public boolean isSerializable()
- {
- boolean passivatingScoped =
MetaDataCache.instance().getScopeModel(scopeType).isPassivating();
- if (passivatingScoped)
- {
- return checkInjectionPointsAreSerializable();
- }
- return true;
- }
-
- @Override
public AbstractBean<?, ?> getSpecializedBean()
{
return specializedBean;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-03-24 21:17:57
UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-03-24 23:33:28
UTC (rev 2196)
@@ -78,5 +78,4 @@
return id;
}
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-24
21:17:57 UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-24
23:33:28 UTC (rev 2196)
@@ -330,7 +330,7 @@
throw new DefinitionException("Simple bean " + type + " cannot be
a parameterized type");
}
boolean passivating =
MetaDataCache.instance().getScopeModel(scopeType).isPassivating();
- if (passivating && !Reflections.isSerializable(type))
+ if (passivating && !_serializable)
{
throw new DefinitionException("Simple bean declaring a passivating scope
must have a serializable implementation class " + toString());
}
@@ -509,25 +509,7 @@
return buffer.toString();
}
- /**
- * Indicates if the bean is serializable
- *
- * @return true If serializable, false otherwise
- */
@Override
- public boolean isSerializable()
- {
- if (isDependent())
- {
- return Reflections.isSerializable(getType());
- }
- else
- {
- return checkInjectionPointsAreSerializable();
- }
- }
-
- @Override
public SimpleBean<?> getSpecializedBean()
{
return specializedBean;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-03-24
21:17:57 UTC (rev 2195)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-03-24
23:33:28 UTC (rev 2196)
@@ -556,26 +556,6 @@
}
/**
- * Gets the type hierarchy for a class
- *
- * A recursive function that adds the class to the set of type and then calls
- * itself with the suprerclass as paramater until the top of the hierarchy is
- * reached. For each steps, adds all interfaces of the class to the set.
- * Since the data structure is a set, duplications are eliminated
- *
- *
- * @deprecated see {@link HierarchyDiscovery}
- * @param clazz The class to examine
- * @return The set of classes and interfaces in the hierarchy
- * @see #getTypeHierachy(Class, Set)
- */
- @Deprecated
- public static Set<Class<?>> getTypeHierachy(Class<?> clazz)
- {
- return new HierarchyDiscovery<Class<?>>(clazz).getFlattenedTypes();
- }
-
- /**
* Checks the bindingType to make sure the annotation was declared properly
* as a binding type (annotated with @BindingType).
*
@@ -596,7 +576,7 @@
public static boolean isSerializable(Class<?> clazz)
{
- return getTypeHierachy(clazz).contains(Serializable.class) || clazz.isPrimitive();
+ return clazz.isPrimitive() || Serializable.class.isAssignableFrom(clazz);
}
}
Show replies by date