Skip to content

Commit

Permalink
move producer checks one level up
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@765 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Jan 5, 2009
1 parent d048d70 commit 5d8128b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 67 deletions.
Expand Up @@ -30,16 +30,19 @@
import javax.webbeans.Dependent;
import javax.webbeans.DeploymentType;
import javax.webbeans.Event;
import javax.webbeans.IllegalProductException;
import javax.webbeans.Named;
import javax.webbeans.ScopeType;
import javax.webbeans.Specializes;
import javax.webbeans.Standard;
import javax.webbeans.Stereotype;
import javax.webbeans.UnserializableDependencyException;
import javax.webbeans.manager.Bean;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.binding.CurrentBinding;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedMember;
import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem.AnnotationMap;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
Expand Down Expand Up @@ -263,6 +266,40 @@ protected void initPrimitive()
this.primitive = Reflections.isPrimitive(getType());
}

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);
}
}
}

/**
* Initializes the scope type
*/
Expand Down
Expand Up @@ -338,37 +338,4 @@ protected Class<? extends Annotation> getDefaultDeploymentType()
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);
}
}
}
}
Expand Up @@ -176,19 +176,6 @@ protected Object getReceiver()
return getAnnotatedItem().isStatic() ? null : manager.getInstance(getDeclaringBean());
}

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);
}
}
}

/**
* Creates an instance of the bean
*
Expand Down Expand Up @@ -229,27 +216,6 @@ public void destroy(T instance)
}
}

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 abstract T produceInstance();

/**
Expand Down

0 comments on commit 5d8128b

Please sign in to comment.