예제 #1
0
 protected InterceptorImpl(
     BeanAttributes<T> attributes, EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager) {
   super(attributes, type, new StringBeanIdentifier(forInterceptor(type)), beanManager);
   this.interceptorMetadata = initInterceptorMetadata();
   this.serializable = type.isSerializable();
   this.interceptorBindingTypes =
       Interceptors.mergeBeanInterceptorBindings(
               beanManager, getEnhancedAnnotated(), getStereotypes())
           .uniqueValues();
 }
예제 #2
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);
  }
예제 #3
0
 public SessionBeanProxyInstantiator(EnhancedAnnotatedType<T> type, SessionBean<T> bean) {
   this.bean = bean;
   this.proxyClass = new EnterpriseProxyFactory<T>(type.getJavaClass(), bean).getProxyClass();
 }
예제 #4
0
 public static String forNewManagedBean(EnhancedAnnotatedType<?> type) {
   return getPrefix(NewManagedBean.class)
       .append(type.slim().getIdentifier().asString())
       .toString();
 }
예제 #5
0
 public static String forInterceptor(EnhancedAnnotatedType<?> type) {
   return getPrefix(InterceptorImpl.class)
       .append(type.slim().getIdentifier().asString())
       .toString();
 }
예제 #6
0
 public static String forManagedBean(EnhancedAnnotatedType<?> type) {
   return forManagedBean(type.slim().getIdentifier());
 }
예제 #7
0
 public static String forExtension(EnhancedAnnotatedType<?> type) {
   return getPrefix(Extension.class).append(type.slim().getIdentifier().asString()).toString();
 }
예제 #8
0
 public <T> ConstructorInjectionPoint<T> createConstructorInjectionPoint(
     Bean<T> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) {
   EnhancedAnnotatedConstructor<T> constructor = Beans.getBeanConstructorStrict(type);
   return createConstructorInjectionPoint(
       declaringBean, type.getJavaClass(), constructor, manager);
 }