@SuppressWarnings({ "rawtypes", "unchecked" }) private static void doDefineNewManagedBean(BeanManagerImpl beanManager, String bdaId, Class<?> beanClass) { try { ClassTransformer classTransformer = getClassTransformer(); SlimAnnotatedType<?> annotatedType = classTransformer.getBackedAnnotatedType(beanClass, bdaId); boolean managedBeanOrDecorator = Beans.isTypeManagedBeanOrDecoratorOrInterceptor(annotatedType); if (managedBeanOrDecorator) { EnhancedAnnotatedType eat = EnhancedAnnotatedTypeImpl.of(annotatedType, classTransformer); BeanAttributes attributes = BeanAttributesFactory.forBean(eat, beanManager); ManagedBean<?> bean = ManagedBean.of(attributes, eat, beanManager); ReflectionHelper.set(beanManager, beanManager.getClass(), "beanSet", Collections.synchronizedSet(new HashSet<Bean<?>>())); beanManager.addBean(bean); beanManager.getBeanResolver().clear(); bean.initializeAfterBeanDiscovery(); LOGGER.debug("Bean defined '{}'", beanClass.getName()); } else { // TODO : define session bean LOGGER.warning("Bean NOT? defined '{}', session bean?", beanClass.getName()); } } catch (Exception e) { LOGGER.debug("Bean definition failed.", e); } }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
/** * Creates new {@link BeanAttributes} to represent a managed bean. */ public static <T> BeanAttributes<T> forBean(EnhancedAnnotated<T, ?> annotated, BeanManagerImpl manager) { return new BeanAttributesBuilder<T>(annotated, manager).build(); }
public BeanAttributesBuilder(EnhancedAnnotated<T, ?> annotated, Set<Type> types, BeanManagerImpl manager) { this.manager = manager; this.annotated = annotated; initStereotypes(annotated, manager); initAlternative(annotated); initName(annotated); initQualifiers(annotated); initScope(annotated); this.types = types; }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
private static void validateBeanType(Type type, BeanAttributes<?> attributes) { checkBeanTypeNotATypeVariable(type, type, attributes); checkBeanTypeForWildcardsAndTypeVariables(type, type, attributes); }
public BeanAttributesBuilder(EnhancedAnnotated<T, ?> annotated, Set<Type> types, BeanManagerImpl manager) { this.manager = manager; this.annotated = annotated; initStereotypes(annotated, manager); initAlternative(annotated); initName(annotated); initQualifiers(annotated); initScope(annotated); this.types = types; }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
/** * Creates new {@link BeanAttributes} to represent a managed bean. */ public static <T> BeanAttributes<T> forBean(EnhancedAnnotated<T, ?> annotated, BeanManagerImpl manager) { return new BeanAttributesBuilder<T>(annotated, manager).build(); }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
public BeanAttributesBuilder(EnhancedAnnotated<T, ?> annotated, Set<Type> types, BeanManagerImpl manager) { this.manager = manager; this.annotated = annotated; initStereotypes(annotated, manager); initAlternative(annotated); initName(annotated); initQualifiers(annotated); initScope(annotated); this.types = types; }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
/** * Creates new {@link BeanAttributes} to represent a managed bean. */ public static <T> BeanAttributes<T> forBean(EnhancedAnnotated<T, ?> annotated, BeanManagerImpl manager) { return new BeanAttributesBuilder<T>(annotated, manager).build(); }
/** * @param source source {@link BeanAttributes}. * @return a safe copy of source {@link BeanAttributes}. */ public static <T> BeanAttributes<T> of(BeanAttributes<T> source, BeanManager manager) { validateBeanAttributes(source, manager); BeanAttributes<T> attributes = new ImmutableBeanAttributes<T>(defensiveCopy(source.getStereotypes()), source.isAlternative(), source.getName(), defensiveCopy(source.getQualifiers()), defensiveCopy(source.getTypes()), source.getScope()); return attributes; }
public BeanAttributesBuilder(EnhancedAnnotated<T, ?> annotated, Set<Type> types, BeanManagerImpl manager) { this.manager = manager; this.annotated = annotated; initStereotypes(annotated, manager); initAlternative(annotated); initName(annotated); initQualifiers(annotated); initScope(annotated); this.types = types; }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
/** * Creates new {@link BeanAttributes} to represent a managed bean. */ public static <T> BeanAttributes<T> forBean(EnhancedAnnotated<T, ?> annotated, BeanManagerImpl manager) { return new BeanAttributesBuilder<T>(annotated, null, manager).build(); }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }
/** * Creates new {@link BeanAttributes} to represent a managed bean. */ public static <T> BeanAttributes<T> forBean(EnhancedAnnotated<T, ?> annotated, BeanManagerImpl manager) { return new BeanAttributesBuilder<T>(annotated, manager).build(); }
/** * Validates {@link BeanAttributes}. * @param attributes {@link BeanAttributes} to validate */ public static void validateBeanAttributes(BeanAttributes<?> attributes, BeanManager manager) { validateStereotypes(attributes, manager); validateQualifiers(attributes, manager); validateTypes(attributes, manager); validateScope(attributes, manager); }