Пример #1
0
  public void validateDecorators(
      Collection<? extends Decorator<?>> beans,
      Collection<RIBean<?>> specializedBeans,
      BeanManagerImpl manager) {
    for (Bean<?> bean : beans) {
      if (bean instanceof RIBean<?>) {
        validateRIBean((RIBean<?>) bean, manager, specializedBeans);

        if (bean instanceof WeldDecorator<?>) {
          WeldClass<?> annotatated = ((WeldDecorator<?>) bean).getWeldAnnotated();
          while (annotatated != null && annotatated.getJavaClass() != Object.class) {
            if (!annotatated.getDeclaredWeldMethods(Produces.class).isEmpty()) {
              throw new DefinitionException(DECORATORS_CANNOT_HAVE_PRODUCER_METHODS, bean);
            }
            if (!annotatated.getDeclaredWeldFields(Produces.class).isEmpty()) {
              throw new DefinitionException(DECORATORS_CANNOT_HAVE_PRODUCER_FIELDS, bean);
            }
            if (!annotatated
                .getDeclaredWeldMethodsWithAnnotatedParameters(Disposes.class)
                .isEmpty()) {
              throw new DefinitionException(DECORATORS_CANNOT_HAVE_DISPOSER_METHODS, bean);
            }
            annotatated = annotatated.getWeldSuperclass();
          }
        }

      } else {
        validateBean(bean, manager);
      }
    }
  }
Пример #2
0
  public void validateBeans(
      Collection<? extends Bean<?>> beans,
      Collection<RIBean<?>> specializedBeans,
      BeanManagerImpl manager) {
    final List<RuntimeException> problems = new ArrayList<RuntimeException>();

    for (Bean<?> bean : beans) {
      try {
        if (bean instanceof RIBean<?>) {
          validateRIBean((RIBean<?>) bean, manager, specializedBeans);
        } else {
          validateBean(bean, manager);
        }
      } catch (RuntimeException e) {
        problems.add(e);
      }
    }
    if (!problems.isEmpty()) {
      if (problems.size() == 1) {
        throw problems.get(0);
      } else {
        throw new DeploymentException((List) problems);
      }
    }
  }