Skip to content

Commit

Permalink
sort out package names a bit, add validation of decorators
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3433 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Aug 11, 2009
1 parent 794a0fd commit 458fa1a
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions impl/src/main/java/org/jboss/webbeans/Validator.java
Expand Up @@ -91,7 +91,7 @@ private void validateBean(Bean<?> bean, BeanManagerImpl beanManager)
* @param beanManager the current manager
* @param specializedBeans the existing specialized beans
*/
private void validateRIBean(RIBean<?> bean, BeanManagerImpl beanManager, List<RIBean<?>> specializedBeans)
private void validateRIBean(RIBean<?> bean, BeanManagerImpl beanManager, Collection<RIBean<?>> specializedBeans)
{
validateBean(bean, beanManager);
if (!(bean instanceof NewSimpleBean<?>) && !(bean instanceof NewEnterpriseBean<?>))
Expand All @@ -116,12 +116,16 @@ private void validateRIBean(RIBean<?> bean, BeanManagerImpl beanManager, List<RI
{
throw new UnserializableDependencyException("The bean " + bean + " declares a passivating scope but has non-serializable decorator: " + decorator);
}
for (InjectionPoint ij : decorator.getInjectionPoints())
{
Bean<?> resolvedBean = beanManager.resolve(beanManager.getInjectableBeans(ij));
validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
}
}
}

}
}

}

/**
Expand Down Expand Up @@ -183,6 +187,14 @@ public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManage
throw new NullableDependencyException("The injection point " + ij + " has nullable dependencies");
}
if (Beans.isPassivatingScope(ij.getBean(), beanManager) && (!ij.isTransient()) && !Beans.isPassivationCapableBean(resolvedBean))
{
validateInjectionPointPassivationCapable(ij, resolvedBean, beanManager);
}
}

public void validateInjectionPointPassivationCapable(InjectionPoint ij, Bean<?> resolvedBean, BeanManagerImpl beanManager)
{
if (!ij.isTransient() && !Beans.isPassivationCapableBean(resolvedBean))
{
if (resolvedBean.getScopeType().equals(Dependent.class) && resolvedBean instanceof AbstractProducerBean<?,?>)
{
Expand All @@ -194,8 +206,17 @@ public void validateInjectionPoint(InjectionPoint ij, BeanManagerImpl beanManage

public void validateDeployment(BeanManagerImpl manager, BeanDeployerEnvironment environment)
{
List<RIBean<?>> specializedBeans = new ArrayList<RIBean<?>>();
for (Bean<?> bean : manager.getBeans())
validateBeans(manager.getDecorators(), new ArrayList<RIBean<?>>(), manager);
validateBeans(manager.getBeans(), new ArrayList<RIBean<?>>(), manager);
validateEnabledDecoratorClasses(manager);
validateEnabledPolicies(manager);
validateDisposalMethods(environment);
validateBeanNames(manager);
}

public void validateBeans(Collection<? extends Bean<?>> beans, Collection<RIBean<?>> specializedBeans, BeanManagerImpl manager)
{
for (Bean<?> bean : beans)
{
if (bean instanceof RIBean<?>)
{
Expand All @@ -206,10 +227,6 @@ public void validateDeployment(BeanManagerImpl manager, BeanDeployerEnvironment
validateBean(bean, manager);
}
}
validateEnabledDecoratorClasses(manager);
validateEnabledPolicies(manager);
validateDisposalMethods(environment);
validateBeanNames(manager);
}

public void validateBeanNames(BeanManagerImpl beanManager)
Expand Down

0 comments on commit 458fa1a

Please sign in to comment.