[webbeans-commits] Webbeans SVN: r750 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: bean and 6 other directories.
by webbeans-commits@lists.jboss.org
Author: nickarls
Date: 2009-01-02 06:25:07 -0500 (Fri, 02 Jan 2009)
New Revision: 750
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/UTTransaction.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
Log:
Structures for passivating scopes.
Got tests but need to sort them out first...
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -42,6 +42,7 @@
import javax.webbeans.Standard;
import javax.webbeans.TypeLiteral;
import javax.webbeans.UnsatisfiedDependencyException;
+import javax.webbeans.UnserializableDependencyException;
import javax.webbeans.manager.Bean;
import javax.webbeans.manager.Context;
import javax.webbeans.manager.Decorator;
@@ -98,7 +99,7 @@
private Set<Interceptor> interceptors;
private EjbDescriptorCache ejbDescriptorCache;
-
+
// The Naming (JNDI) access
private Naming naming;
@@ -711,32 +712,68 @@
public Manager parse(InputStream xmlStream)
{
// TODO Implement XML parsing
- return null;
+ return this;
}
public Manager validate()
{
- // TODO Implement XML parsing
- return null;
+ checkPassivation();
+ return this;
}
+ private void checkPassivation()
+ {
+ for (Bean<?> bean : beans)
+ {
+ boolean passivatingScoped = MetaDataCache.instance().getScopeModel(bean.getScopeType()).isPassivating();
+ if (passivatingScoped && !bean.isSerializable())
+ {
+ throw new UnserializableDependencyException(bean + " is not serializable or has unserializable dependencies");
+ }
+ // // TODO: Not that pretty. Can this logic be moved to the
+ // isSerializable()
+ // // of SimpleBean and EnterpriseBean or are they too strict there?
+ // if (bean instanceof EnterpriseBean)
+ // {
+ // boolean stateful =
+ // getEjbDescriptorCache().containsKey(((EnterpriseBean<?>)
+ // bean).getType());
+ // if (stateful && !bean.isSerializable())
+ // {
+ // throw new UnserializableDependencyException(bean +
+ // " is not serializable or has unserializable dependencies");
+ // }
+ // }
+ // else if (bean instanceof SimpleBean)
+ // {
+ // boolean passivating =
+ // MetaDataCache.instance().getScopeModel(bean.getScopeType()).isPassivating();
+ // if (passivating && !bean.isSerializable())
+ // {
+ // throw new UnserializableDependencyException(bean +
+ // " is not serializable or has unserializable dependencies");
+ // }
+ // }
+ }
+ }
+
public Manager createChildManager()
{
// TODO Implement hierarchical managers
- return null;
+ return this;
}
public Manager setCurrent()
{
// TODO Implement hierarchical managers
- return null;
+ return this;
}
-
+
public Naming getNaming()
{
return naming;
}
-
+
public void setNaming(Naming naming)
{
this.naming = naming;
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -90,7 +90,7 @@
private Set<Annotation> bindingTypes;
// The name
protected String name;
- // The scope type
+ // The scope type
protected Class<? extends Annotation> scopeType;
// The merged stereotypes
private MergedStereotypes<T, E> mergedStereotypes;
@@ -212,7 +212,7 @@
*/
protected void initInjectionPoints()
{
- injectionPoints = new HashSet<AnnotatedItem<?,?>>();
+ injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
}
/**
@@ -503,18 +503,11 @@
return primitive;
}
- /**
- * Indicates if bean is serializable
- *
- * @return True if serializable, false otherwise
- *
- * @see @see javax.webbeans.manager.Bean#isSerializable()
- */
@Override
public boolean isSerializable()
{
- // TODO Implement passivating scopes
- return false;
+ // TODO: OK?
+ return true;
}
/**
@@ -544,5 +537,5 @@
buffer.append(mergedStereotypes.toString() + "\n");
return buffer.toString();
}
-
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -23,19 +23,26 @@
import javax.webbeans.BindingType;
import javax.webbeans.DefinitionException;
+import javax.webbeans.Dependent;
import javax.webbeans.Destructor;
import javax.webbeans.Disposes;
+import javax.webbeans.IllegalProductException;
import javax.webbeans.Initializer;
import javax.webbeans.Observes;
import javax.webbeans.Produces;
import javax.webbeans.Production;
import javax.webbeans.UnproxyableDependencyException;
+import javax.webbeans.UnserializableDependencyException;
+import javax.webbeans.manager.Bean;
+import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedField;
+import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedMember;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -87,6 +94,23 @@
initInitializerMethods();
}
+ protected void checkPassivation()
+ {
+ for (AnnotatedField<Object> injectableField : injectableFields)
+ {
+ if (injectableField.isTransient())
+ {
+ continue;
+ }
+
+ Bean<?> bean = CurrentManager.rootManager().resolveByType(injectableField).iterator().next();
+ if (Dependent.class.equals(bean.getScopeType()) && !bean.isSerializable())
+ {
+ throw new UnserializableDependencyException("Dependent Web Beans cannot be injected into non-transient fields of beans declaring a passivating scope");
+ }
+ }
+ }
+
/**
* Initializes the bean type
*/
@@ -121,7 +145,8 @@
/**
* Gets the observer methods
*
- * @return A set of observer methods. An empty set is returned if there are no matches.
+ * @return A set of observer methods. An empty set is returned if there are
+ * no matches.
*/
public Set<AnnotatedMethod<Object>> getObserverMethods()
{
@@ -303,7 +328,7 @@
}
@Override
- /**
+ /*
* Gets the default deployment type
*
* @return The default deployment type
@@ -312,4 +337,38 @@
{
return Production.class;
}
+
+ protected void checkProducedInjectionPoints()
+ {
+ for (AnnotatedItem<?, ?> injectionPoint : getInjectionPoints())
+ {
+ if (injectionPoint instanceof AbstractAnnotatedMember)
+ {
+ if (((AbstractAnnotatedMember<?, ?>) injectionPoint).isTransient())
+ {
+ continue;
+ }
+ }
+ Annotation[] bindings = injectionPoint.getMetaAnnotationsAsArray(BindingType.class);
+ Bean<?> bean = manager.resolveByType(injectionPoint.getType(), bindings).iterator().next();
+ boolean producerBean = (bean instanceof ProducerMethodBean || bean instanceof ProducerFieldBean);
+ if (producerBean && Dependent.class.equals(bean.getScopeType()) && !bean.isSerializable())
+ {
+ throw new IllegalProductException("Dependent-scoped producer bean " + producerBean + " produces a non-serializable product for injection for " + injectionPoint + " in " + this);
+ }
+ }
+ }
+
+ protected void checkInjectionPoints()
+ {
+ for (AnnotatedItem<?, ?> injectionPoint : getInjectionPoints())
+ {
+ Annotation[] bindings = injectionPoint.getMetaAnnotationsAsArray(BindingType.class);
+ Bean<?> bean = manager.resolveByType(injectionPoint.getType(), bindings).iterator().next();
+ if (Dependent.class.equals(bean.getScopeType()) && !bean.isSerializable())
+ {
+ throw new UnserializableDependencyException(bean + " is a non-serializable dependent injection for " + injectionPoint + " in " + this);
+ }
+ }
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -26,7 +26,9 @@
import javax.webbeans.IllegalProductException;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
/**
* The implicit producer bean
@@ -151,6 +153,11 @@
{
throw new IllegalProductException("Cannot return null from a non-dependent producer method");
}
+ boolean passivating = MetaDataCache.instance().getScopeModel(getScopeType()).isPassivating();
+ if (passivating && !Reflections.isSerializable(instance.getClass()))
+ {
+ throw new IllegalProductException("Producers cannot declare passivating and return non-serializable class");
+ }
}
/**
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -54,13 +54,12 @@
public class EnterpriseBean<T> extends AbstractClassBean<T>
{
private LogProvider log = Logging.getLogProvider(EnterpriseBean.class);
-
+
// The EJB descriptor
private EjbDescriptor<T> ejbDescriptor;
-
+
// The remove method on the bean class (do not call!)
private AnnotatedMethod<?> removeMethod;
-
/**
* Constructor
@@ -94,7 +93,7 @@
}
else
{
- throw new RuntimeException("TODO Multiple EJBs have the same bean class! " + getType() );
+ throw new RuntimeException("TODO Multiple EJBs have the same bean class! " + getType());
}
}
initRemoveMethod();
@@ -180,7 +179,7 @@
{
throw new DefinitionException("Multiple @Destructor methods not allowed on " + getAnnotatedItem());
}
-
+
if (getAnnotatedItem().getAnnotatedMethods(Destructor.class).size() == 1)
{
AnnotatedMethod<?> destructorMethod = getAnnotatedItem().getAnnotatedMethods(Destructor.class).iterator().next();
@@ -207,14 +206,14 @@
this.removeMethod = annotatedItem.getMethod(noArgsRemoveMethods.iterator().next());
return;
}
-
+
if (!getScopeType().equals(Dependent.class))
{
throw new DefinitionException("Only @Dependent scoped enterprise beans can be without remove methods " + toString());
}
}
-
+
/**
* Validates the remove method
*/
@@ -257,7 +256,8 @@
try
{
DependentContext.INSTANCE.setActive(true);
- // TODO Implement enterprise bean proxies and select the correct jndiName
+ // TODO Implement enterprise bean proxies and select the correct
+ // jndiName
return (T) manager.getNaming().lookup(ejbDescriptor.getLocalJndiName(), getType());
}
catch (Exception e)
@@ -283,7 +283,7 @@
DependentContext.INSTANCE.setActive(true);
removeMethod.invokeOnInstance(instance, manager);
}
- catch (Exception e)
+ catch (Exception e)
{
log.error("Error destroying " + toString(), e);
}
@@ -350,7 +350,7 @@
}
}
-
+
public AnnotatedMethod<?> getRemoveMethod()
{
return removeMethod;
@@ -396,6 +396,10 @@
try
{
DependentContext.INSTANCE.setActive(true);
+ if (ejbDescriptor.isStateful())
+ {
+ checkProducedInjectionPoints();
+ }
bindDecorators();
bindInterceptors();
injectEjbAndCommonFields();
@@ -406,12 +410,26 @@
{
DependentContext.INSTANCE.setActive(false);
}
-
+
}
public void preDestroy(Object target)
{
-
+
}
+ @Override
+ public boolean isSerializable()
+ {
+ if (ejbDescriptor.isStateful())
+ {
+ checkInjectionPoints();
+ return true;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -24,19 +24,20 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.jlr.AnnotatedFieldImpl;
import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
/**
* Represents a producer field bean
*
* @author Pete Muir
- *
+ *
* @param <T>
*/
public class ProducerFieldBean<T> extends AbstractProducerBean<T, Field>
{
// The underlying field
private AnnotatedField<T> field;
-
+
/**
* Constructor
*
@@ -48,7 +49,7 @@
{
this(new AnnotatedFieldImpl<T>(field, declaringBean.getAnnotatedItem()), declaringBean, manager);
}
-
+
/**
* Constructor
*
@@ -83,7 +84,7 @@
DependentContext.INSTANCE.setActive(false);
}
}
-
+
@Override
public void destroy(T instance)
{
@@ -119,12 +120,12 @@
{
return field.getPropertyName();
}
-
+
/**
* Gets a string representation
*
* @return The string representation
- */
+ */
@Override
public String toString()
{
@@ -141,7 +142,7 @@
buffer.append(" [" + getType().getName() + "]\n");
buffer.append(" API types " + getTypes() + ", binding types " + getBindingTypes() + "\n");
return buffer.toString();
- }
+ }
public String toDetailedString()
{
@@ -150,7 +151,13 @@
buffer.append(super.toString() + "\n");
buffer.append("Declaring bean: " + declaringBean.toString() + "\n");
buffer.append("Field: " + field.toString() + "\n");
- return buffer.toString();
+ return buffer.toString();
}
+ @Override
+ public boolean isSerializable()
+ {
+ return Reflections.isSerializable(field.getAnnotatedField().getClass());
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -32,19 +32,20 @@
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
/**
* Represents a producer method bean
*
* @author Pete Muir
- *
+ *
* @param <T>
*/
public class ProducerMethodBean<T> extends AbstractProducerBean<T, Method>
{
// The underlying method
private AnnotatedMethod<T> method;
-
+
private AnnotatedMethod<?> disposalMethod;
/**
@@ -58,7 +59,7 @@
{
this(new AnnotatedMethodImpl<T>(method, declaringBean.getAnnotatedItem()), declaringBean, manager);
}
-
+
/**
* Constructor
*
@@ -93,7 +94,7 @@
DependentContext.INSTANCE.setActive(false);
}
}
-
+
@Override
public void destroy(T instance)
{
@@ -119,10 +120,10 @@
initDisposalMethod();
initInjectionPoints();
}
-
+
/**
* Initializes the injection points
- */
+ */
@Override
protected void initInjectionPoints()
{
@@ -139,7 +140,7 @@
}
}
}
-
+
/**
* Validates the producer method
*/
@@ -158,7 +159,7 @@
throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
}
}
-
+
/**
* Initializes the remove method
*/
@@ -172,10 +173,9 @@
else if (disposalMethods.size() > 1)
{
// TODO List out found disposal methods
- throw new DefinitionException ("Cannot declare multiple disposal methods for this producer method");
+ throw new DefinitionException("Cannot declare multiple disposal methods for this producer method");
}
}
-
/**
* Gets the annotated item representing the method
@@ -230,7 +230,7 @@
buffer.append(" [" + getType().getName() + "]\n");
buffer.append(" API types " + getTypes() + ", binding types " + getBindingTypes() + "\n");
return buffer.toString();
- }
+ }
public String toDetailedString()
{
@@ -239,7 +239,12 @@
buffer.append(super.toString() + "\n");
buffer.append("Declaring bean: " + declaringBean.toString() + "\n");
buffer.append("Method: " + method.toString() + "\n");
- return buffer.toString();
+ return buffer.toString();
}
+ @Override
+ public boolean isSerializable()
+ {
+ return Reflections.isSerializable(method.getAnnotatedMethod().getReturnType());
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -28,6 +28,7 @@
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.MetaDataCache;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedField;
@@ -57,7 +58,7 @@
private AnnotatedMethod<Object> postConstruct;
// The pre-destroy method
private AnnotatedMethod<Object> preDestroy;
-
+
/**
* Constructor
*
@@ -81,6 +82,11 @@
try
{
DependentContext.INSTANCE.setActive(true);
+ boolean passivating = MetaDataCache.instance().getScopeModel(scopeType).isPassivating();
+ if (passivating)
+ {
+ checkProducedInjectionPoints();
+ }
T instance = constructor.newInstance(manager);
bindDecorators();
bindInterceptors();
@@ -109,7 +115,7 @@
DependentContext.INSTANCE.setActive(true);
callPreDestroy(instance);
}
- catch (Exception e)
+ catch (Exception e)
{
log.error("Error destroying " + toString(), e);
}
@@ -131,7 +137,7 @@
{
try
{
- //note: RI supports injection into @PreDestroy
+ // note: RI supports injection into @PreDestroy
preDestroy.invoke(instance, manager);
}
catch (Exception e)
@@ -153,7 +159,7 @@
{
try
{
- //note: RI supports injection into @PostConstruct
+ // note: RI supports injection into @PostConstruct
postConstruct.invoke(instance, manager);
}
catch (Exception e)
@@ -206,7 +212,7 @@
{
super.init();
initConstructor();
- checkType(getType());
+ checkType();
initInjectionPoints();
initPostConstruct();
initPreDestroy();
@@ -224,14 +230,19 @@
{
injectionPoints.add(parameter);
}
+ for (AnnotatedMethod<Object> initializer : getInitializerMethods())
+ {
+ for (AnnotatedParameter<Object> parameter : initializer.getParameters())
+ {
+ injectionPoints.add(parameter);
+ }
+ }
}
/**
* Validates the type
- *
- * @param type The type to validate
*/
- public static void checkType(Class<?> type)
+ private void checkType()
{
if (Reflections.isNonStaticInnerClass(type))
{
@@ -241,6 +252,11 @@
{
throw new DefinitionException("Simple Web Bean " + type + " cannot be a parameterized type");
}
+ boolean passivating = MetaDataCache.instance().getScopeModel(scopeType).isPassivating();
+ if (passivating && !Reflections.isSerializable(type))
+ {
+ throw new DefinitionException("Simple Web Beans declaring a passivating scope must have a serializable implementation class");
+ }
}
/**
@@ -284,7 +300,9 @@
log.trace("Found " + postConstructMethods + " constructors annotated with @Initializer for " + getType());
if (postConstructMethods.size() > 1)
{
- // TODO actually this is wrong, in EJB you can have @PostConstruct methods on the superclass, though the Web Beans spec is silent on the issue
+ // TODO actually this is wrong, in EJB you can have @PostConstruct
+ // methods on the superclass, though the Web Beans spec is silent on
+ // the issue
throw new DefinitionException("Cannot have more than one post construct method annotated with @PostConstruct for " + getType());
}
else if (postConstructMethods.size() == 1)
@@ -304,7 +322,8 @@
log.trace("Found " + preDestroyMethods + " constructors annotated with @Initializer for " + getType());
if (preDestroyMethods.size() > 1)
{
- // TODO actually this is wrong, in EJB you can have @PreDestroy methods on the superclass, though the Web Beans spec is silent on the issue
+ // TODO actually this is wrong, in EJB you can have @PreDestroy methods
+ // on the superclass, though the Web Beans spec is silent on the issue
throw new DefinitionException("Cannot have more than one pre destroy method annotated with @PreDestroy for " + getType());
}
else if (preDestroyMethods.size() == 1)
@@ -400,4 +419,39 @@
return buffer.toString();
}
+ /**
+ * Indicates if the bean is serializable
+ *
+ * Beans declaring normal scopes are serializable themselves because they are
+ * accessed through a proxy but we still need to check that the dependencies
+ * are serializable (through the super.isSerializable).
+ *
+ * Beans declaring pseudo-scopes are serializable if the implementation class
+ * is serializable.
+ *
+ * @return true If serializable, false otherwise
+ */
+ @Override
+ public boolean isSerializable()
+ {
+ boolean normalScoped = MetaDataCache.instance().getScopeModel(scopeType).isNormal();
+ if (normalScoped)
+ {
+ boolean passivatingScoped = MetaDataCache.instance().getScopeModel(scopeType).isPassivating();
+ if (passivatingScoped)
+ {
+ checkInjectionPoints();
+ return true;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return Reflections.isSerializable(getType());
+ }
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -19,6 +19,7 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
@@ -82,7 +83,7 @@
private static TypeInfo getTypeInfo(Set<Class<?>> types)
{
TypeInfo typeInfo = new TypeInfo();
- List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ Set<Class<?>> interfaces = new HashSet<Class<?>>();
Class<?> superclass = null;
for (Class<?> type : types)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -58,7 +58,6 @@
* @param bean The bean to create
* @param create Should a new one be created
*/
- //@Override
public <T> T get(Contextual<T> bean, boolean create)
{
if (!isActive())
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedField.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -75,4 +75,6 @@
*/
public String getPropertyName();
+ public boolean isTransient();
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -128,4 +128,6 @@
*/
public boolean isEquivalent(Method method);
+ public Method getAnnotatedMethod();
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -29,7 +29,6 @@
*/
public interface AnnotatedParameter<T> extends AnnotatedItem<T, Object>
{
-
/**
* Gets the actual value of the parameter from the manager
*
@@ -37,5 +36,4 @@
* @return The value
*/
public T getValue(Manager manager);
-
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -129,6 +129,11 @@
return Reflections.isFinal(getDelegate());
}
+ public boolean isTransient()
+ {
+ return Reflections.isTransient(getDelegate());
+ }
+
/**
* Gets the current value of the member
*
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -27,6 +27,7 @@
import java.util.List;
import javax.webbeans.ExecutionException;
+import javax.webbeans.IllegalProductException;
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
@@ -34,6 +35,7 @@
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
/**
@@ -266,7 +268,7 @@
}
toString = "Annotated method " + Names.constructor2String(constructor);
return toString;
- }
+ }
public String toDetailedString()
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/UTTransaction.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/UTTransaction.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/transaction/UTTransaction.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -11,7 +11,7 @@
import org.jboss.webbeans.log.Logging;
/**
- * Wraps JTA transaction management in a Seam UserTransaction
+ * Wraps JTA transaction management in a Web Beans UserTransaction
* interface.
*
* @author Mike Youngstrom
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-01-02 05:14:31 UTC (rev 749)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-01-02 11:25:07 UTC (rev 750)
@@ -18,6 +18,7 @@
package org.jboss.webbeans.util;
import java.beans.Introspector;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -147,6 +148,11 @@
return Modifier.isStatic(member.getModifiers());
}
+ public static boolean isTransient(Member member)
+ {
+ return Modifier.isTransient(member.getModifiers());
+ }
+
/**
* Checks if clazz is abstract
*
@@ -423,7 +429,7 @@
throw new ExecutionException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
}
}
-
+
/**
* Invokes a method and wraps exceptions
*
@@ -483,7 +489,7 @@
throw new ExecutionException("Error setting field " + field.getName() + " on " + field.getDeclaringClass(), e);
}
}
-
+
/**
* Sets value of a field and wraps exceptions
*
@@ -619,4 +625,9 @@
}
return isBindingAnnotation;
}
+
+ public static boolean isSerializable(Class<?> clazz)
+ {
+ return getTypeHierachy(clazz).contains(Serializable.class);
+ }
}
16 years
[webbeans-commits] Webbeans SVN: r749 - ri/trunk/webbeans-api/src/main/java/javax/webbeans/manager.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2009-01-02 00:14:31 -0500 (Fri, 02 Jan 2009)
New Revision: 749
Modified:
ri/trunk/webbeans-api/src/main/java/javax/webbeans/manager/Contextual.java
Log:
minor
Modified: ri/trunk/webbeans-api/src/main/java/javax/webbeans/manager/Contextual.java
===================================================================
--- ri/trunk/webbeans-api/src/main/java/javax/webbeans/manager/Contextual.java 2009-01-01 04:35:45 UTC (rev 748)
+++ ri/trunk/webbeans-api/src/main/java/javax/webbeans/manager/Contextual.java 2009-01-02 05:14:31 UTC (rev 749)
@@ -25,7 +25,7 @@
*/
public interface Contextual<T>
{
- public abstract T create();
+ public T create();
- public abstract void destroy(T instance);
+ public void destroy(T instance);
}
16 years
[webbeans-commits] Webbeans SVN: r748 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean.
by webbeans-commits@lists.jboss.org
Author: gavin.king(a)jboss.com
Date: 2008-12-31 23:35:45 -0500 (Wed, 31 Dec 2008)
New Revision: 748
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java
Log:
fix build breakage
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java 2008-12-31 23:24:08 UTC (rev 747)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InjectionPointBean.java 2009-01-01 04:35:45 UTC (rev 748)
@@ -55,49 +55,49 @@
this.beanInstance = beanInstance;
}
- @Override
+ //@Override
public <T extends Annotation> T getAnnotation(Class<T> annotationType)
{
return this.memberInjectionPoint.getAnnotation(annotationType);
}
- @Override
+ //@Override
public Annotation[] getAnnotations()
{
return this.memberInjectionPoint.getAnnotations().toArray(new Annotation[0]);
}
- @Override
+ //@Override
public Bean<?> getBean()
{
return this.bean;
}
- @Override
+ //@Override
public Set<Annotation> getBindingTypes()
{
return this.memberInjectionPoint.getBindingTypes();
}
- @Override
+ //@Override
public Object getInstance()
{
return this.beanInstance;
}
- @Override
+ //@Override
public Member getMember()
{
return this.memberInjectionPoint.getDelegate();
}
- @Override
+ //@Override
public Type getType()
{
return this.memberInjectionPoint.getType();
}
- @Override
+ //@Override
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
{
return this.memberInjectionPoint.isAnnotationPresent(annotationType);
16 years