Skip to content

Commit

Permalink
move ip validation logic to validator to apply to all beans
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3261 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jul 26, 2009
1 parent c7ce014 commit dbeb26f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
15 changes: 15 additions & 0 deletions impl/src/main/java/org/jboss/webbeans/Validator.java
Expand Up @@ -117,12 +117,27 @@ private void validateRIBean(RIBean<?> bean, BeanManagerImpl beanManager, List<RI

}

/**
* 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 beanManager
*/
public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManager)
{
if (ij.getAnnotated().getAnnotation(New.class) != null && ij.getBindings().size() > 1)
{
throw new DefinitionException("The injection point " + ij + " is annotated with @New which cannot be combined with other binding types");
}
if (!Dependent.class.equals(ij.getBean().getScopeType()) && ij.getType().equals(InjectionPoint.class))
{
throw new DefinitionException("Cannot inject an InjectionPoint into a non @Dependent scoped bean " + ij);
}
if (ij.getType() instanceof TypeVariable<?>)
{
throw new DefinitionException("Cannot declare an injection point with a type variable " + ij);
}
if (ij.getType() instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) ij.getType();
Expand Down
20 changes: 0 additions & 20 deletions impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
Expand Up @@ -18,7 +18,6 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
Expand All @@ -33,7 +32,6 @@
import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.deployment.Standard;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.stereotype.Stereotype;

import org.jboss.webbeans.BeanManagerImpl;
Expand Down Expand Up @@ -159,7 +157,6 @@ public void initialize(BeanDeployerEnvironment environment)
initSerializable();
initProxyable();
initInjectionPoints();
checkInjectionPoints();
initDecorates();
checkDecorates();
}
Expand Down Expand Up @@ -296,23 +293,6 @@ private boolean checkInjectionPointsAreSerializable()
}
return true;
}

protected boolean checkInjectionPoints()
{
// TODO Merge serializable check in here
for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
{
if (!Dependent.class.equals(getScopeType()) && injectionPoint.getType().equals(InjectionPoint.class))
{
throw new DefinitionException("Cannot inject an InjectionPoint into a non @Dependent scoped bean " + injectionPoint);
}
if (injectionPoint.getType() instanceof TypeVariable<?>)
{
throw new DefinitionException("Cannot declare an injection point with a type variable " + injectionPoint);
}
}
return true;
}

/**
* Initializes the scope type
Expand Down

0 comments on commit dbeb26f

Please sign in to comment.