示例#1
0
 private BeansXml buildSyntheticBeansXml() {
   return new BeansXmlImpl(
       ImmutableList.copyOf(selectedAlternatives),
       ImmutableList.copyOf(selectedAlternativeStereotypes),
       ImmutableList.copyOf(enabledDecorators),
       ImmutableList.copyOf(enabledInterceptors),
       null,
       null,
       BeanDiscoveryMode.ALL,
       null);
 }
示例#2
0
  public <X> List<ParameterInjectionPoint<?, X>> getParameterInjectionPoints(
      EnhancedAnnotatedCallable<?, X, ?> callable,
      Bean<?> declaringBean,
      Class<?> declaringComponentClass,
      BeanManagerImpl manager,
      boolean observerOrDisposer) {
    List<ParameterInjectionPoint<?, X>> parameters = new ArrayList<ParameterInjectionPoint<?, X>>();

    /*
     * bean that the injection point belongs to this is null for observer and disposer methods
     */
    Bean<?> bean = null;
    if (!observerOrDisposer) {
      bean = declaringBean;
    }

    for (EnhancedAnnotatedParameter<?, X> parameter : callable.getEnhancedParameters()) {
      if (isSpecialParameter(parameter)) {
        parameters.add(
            SpecialParameterInjectionPoint.of(
                parameter, bean, declaringBean.getBeanClass(), manager));
      } else {
        parameters.add(
            createParameterInjectionPoint(parameter, bean, declaringComponentClass, manager));
      }
    }
    return ImmutableList.copyOf(parameters);
  }
示例#3
0
  /*
   * Utility methods for field InjectionPoints
   */
  public List<Set<FieldInjectionPoint<?, ?>>> getFieldInjectionPoints(
      Bean<?> declaringBean, EnhancedAnnotatedType<?> type, BeanManagerImpl manager) {
    List<Set<FieldInjectionPoint<?, ?>>> injectableFieldsList =
        new ArrayList<Set<FieldInjectionPoint<?, ?>>>();

    if (type.slim() instanceof UnbackedAnnotatedType<?>) {
      // external AnnotatedTypes require special treatment
      Collection<EnhancedAnnotatedField<?, ?>> allFields = type.getEnhancedFields(Inject.class);

      for (Class<?> clazz = type.getJavaClass();
          clazz != null && clazz != Object.class;
          clazz = clazz.getSuperclass()) {
        ImmutableSet.Builder<FieldInjectionPoint<?, ?>> fields = ImmutableSet.builder();
        for (EnhancedAnnotatedField<?, ?> field : allFields) {
          if (!field.isStatic() && field.getJavaMember().getDeclaringClass().equals(clazz)) {
            addFieldInjectionPoint(field, fields, declaringBean, type.getJavaClass(), manager);
          }
        }
        injectableFieldsList.add(0, fields.build());
      }
    } else {
      for (EnhancedAnnotatedType<?> t = type;
          t != null && !t.getJavaClass().equals(Object.class);
          t = t.getEnhancedSuperclass()) {
        ImmutableSet.Builder<FieldInjectionPoint<?, ?>> fields = ImmutableSet.builder();
        for (EnhancedAnnotatedField<?, ?> annotatedField :
            t.getDeclaredEnhancedFields(Inject.class)) {
          if (!annotatedField.isStatic()) {
            addFieldInjectionPoint(
                annotatedField, fields, declaringBean, t.getJavaClass(), manager);
          }
        }
        injectableFieldsList.add(0, fields.build());
      }
    }
    return ImmutableList.copyOf(injectableFieldsList);
  }
示例#4
0
 /** @return an immutable list of ids of running containers */
 public static List<String> getRunningContainerIds() {
   return ImmutableList.copyOf(RUNNING_CONTAINER_IDS);
 }