@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); } }
if (Beans.getBeanConstructor(type) == null) {
@SuppressWarnings("unchecked") public void forEach(Consumer<? super E> action) { Preconditions.checkNotNull(action); for (Object object : elements) { action.accept((E) object); } }
public static <T> List<Set<MethodInjectionPoint<?, ?>>> getInitializerMethods(Bean<?> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) { return getMethods(type, new InitializerMethodListBuilder<T>(type, declaringBean, manager)); }
@Override public WeldBeanConfigurator<T> beanClass(Class<?> beanClass) { checkArgumentNotNull(beanClass); this.beanClass = beanClass; return this; }
/** * Indicates if a set of types are all proxyable * * @param declaringBean with types to test * @return True if proxyable, false otherwise */ public static boolean isTypesProxyable(Bean<?> declaringBean, ServiceRegistry services) { return getUnproxyableTypesException(declaringBean, services) == null; }
/** * * @param type * @return */ public static Type getCanonicalType(Type type) { if (type instanceof Class<?>) { Class<?> clazz = (Class<?>) type; return getCanonicalType(clazz); } return type; }
@Override public Object apply(Bean<Object> from) { if (Proxies.isTypesProxyable(from, services())) { return createClientProxy(from); } else { return BEAN_NOT_PROXYABLE_MARKER; } } };
public T get() { T valueCopy = value; if (valueCopy != null) { return valueCopy; } synchronized (this) { if (value == null) { value = computeValue(); } return value; } }
/** * @param contextual * @param serviceRegistry * @return the identifier for the given contextual * @see #getIdentifier(Contextual, ContextualStore, ServiceRegistry) */ public static BeanIdentifier getIdentifier(Contextual<?> contextual, ServiceRegistry serviceRegistry) { return getIdentifier(contextual, null, serviceRegistry); }
private static String getTypeId(Type type) { if (type == null || type instanceof Class<?>) { return null; } return Types.getTypeId(type); }
@Override public void proceed() { Beans.injectFieldsAndInitializers(instance, ctx, manager, injectableFields, initializerMethods); } }.run();
public static <T> List<Set<MethodInjectionPoint<?, ?>>> getInitializerMethods(Bean<?> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) { return getMethods(type, new InitializerMethodListBuilder<T>(type, declaringBean, manager)); }
@Override public BeanAttributesConfigurator<T> scope(Class<? extends Annotation> scope) { checkArgumentNotNull(scope); this.scope = scope; return this; }
/** * Indicates if a set of types are all proxyable * * @param types The types to test * @return True if proxyable, false otherwise */ public static boolean isTypesProxyable(Iterable<? extends Type> types, ServiceRegistry services) { return getUnproxyableTypesException(types, services) == null; }
public static <T> List<Set<MethodInjectionPoint<?, ?>>> getInitializerMethods(Bean<?> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) { return getMethods(type, new InitializerMethodListBuilder<T>(type, declaringBean, manager)); }
public static <T> List<Set<MethodInjectionPoint<?, ?>>> getInitializerMethods(Bean<?> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) { return getMethods(type, new InitializerMethodListBuilder<T>(type, declaringBean, manager)); }
public static <T> List<Set<MethodInjectionPoint<?, ?>>> getInitializerMethods(Bean<?> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) { return getMethods(type, new InitializerMethodListBuilder<T>(type, declaringBean, manager)); }
public static <T> List<Set<MethodInjectionPoint<?, ?>>> getInitializerMethods(Bean<?> declaringBean, EnhancedAnnotatedType<T> type, BeanManagerImpl manager) { return getMethods(type, new InitializerMethodListBuilder<T>(type, declaringBean, manager)); }