BeanAttributesImpl<?> attributes = BeanAttributesBuilder.forContext(wbc).newBeanAttibutes(annotatedType).build(); Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> annotatedTypes = new HashMap<>();
ProcessBeanAttributesImpl<T> processBeanAttributes = webBeansContext.getWebBeansUtil().fireProcessBeanAttributes( annotatedMethod, annotatedMethod.getJavaMember().getReturnType(), BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(method).build()); if (processBeanAttributes != null)
BeanAttributesImpl beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at, onlyScopedBeans && !isEjb).build(); if (beanAttributes != null && (!beanAttributes.isAlternative() || isEnabledAlternative(at, beanAttributes.getStereotypes())))
/** * get the EJB-style Interceptor * @param interceptorClass * @param <T> * @return */ public <T> Interceptor<T> getEjbInterceptorForClass(Class<T> interceptorClass) { Interceptor<T> interceptor = (Interceptor<T>) ejbInterceptors.get(interceptorClass); if (interceptor == null) { AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(interceptorClass); if (annotatedType == null) { annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(interceptorClass); } BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build(); EjbInterceptorBeanBuilder<T> buildr = new EjbInterceptorBeanBuilder<>(webBeansContext, annotatedType, beanAttributes); buildr.defineEjbInterceptorRules(); Interceptor<T> i = buildr.getBean(); interceptor = (Interceptor<T>) ejbInterceptors.putIfAbsent(interceptorClass, i); if (interceptor == null) { interceptor = i; } } return interceptor; }
/** * This method will be used in {@link AfterBeanDiscovery#addBean(javax.enterprise.inject.spi.Bean)}} */ public <T> ManagedBean<T> defineManagedBeanWithoutFireEvents(AnnotatedType<T> type) { BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build(); ManagedBeanBuilder<T, ManagedBean<T>> managedBeanCreator = new ManagedBeanBuilder<>(webBeansContext, type, beanAttributes, false); //Check for Enabled via Alternative setInjectionTargetBeanEnableFlag(managedBeanCreator.getBean()); ManagedBean<T> managedBean = managedBeanCreator.getBean(); new ProducerMethodBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerMethods( managedBean, new ProducerFieldBeansBuilder(managedBean.getWebBeansContext(), managedBean.getAnnotatedType()).defineProducerFields(managedBean)); new ObserverMethodsBuilder<>(webBeansContext, managedBean.getAnnotatedType()).defineObserverMethods(managedBean); if (managedBean.getProducer() instanceof AbstractProducer) { AbstractProducer<T> producer = (AbstractProducer<T>)managedBean.getProducer(); producer.defineInterceptorStack(managedBean, managedBean.getAnnotatedType(), webBeansContext); } return managedBean; }
/** * Check whether this class has any method which intercepts the whole bean itself. * @return SelfInterceptorBean or <code>null</code> if this bean doesn't intercept itself */ private <T> SelfInterceptorBean<T> resolveSelfInterceptorBean(AnnotatedType<T> annotatedType) { BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build(); if (beanAttributes == null) { // might happen if a proxying rule eefines that this is not a valid bean type. return null; } SelfInterceptorBeanBuilder<T> sibb = new SelfInterceptorBeanBuilder<>(webBeansContext, annotatedType, beanAttributes); sibb.defineSelfInterceptorRules(); if (!sibb.isInterceptorEnabled()) { return null; } return sibb.getBean(); }
public <T> Bean<T> createNewComponent(Class<T> type) { Asserts.nullCheckForClass(type); OpenWebBeansEjbPlugin ejbPlugin = webBeansContext.getPluginLoader().getEjbPlugin(); if (ejbPlugin != null && ejbPlugin.isNewSessionBean(type)) { return ejbPlugin.defineNewSessionBean(type); } AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type); BeanAttributesImpl<T> defaultBeanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build(); BeanAttributesImpl<T> newBeanAttributes = new BeanAttributesImpl<>(defaultBeanAttributes.getTypes(), Collections.<Annotation>singleton(new NewLiteral(type))); // TODO replace this by InjectionPointBuilder ManagedBeanBuilder<T, ManagedBean<T>> beanBuilder = new ManagedBeanBuilder<>(webBeansContext, annotatedType, newBeanAttributes, false); NewManagedBean<T> newBean = new NewManagedBean<>(webBeansContext, WebBeansType.MANAGED, annotatedType, newBeanAttributes, type, beanBuilder.getBean().getInjectionPoints()); return newBean; }
/** * {@inheritDoc} */ public BeanAttributes<?> createBeanAttributes(AnnotatedMember<?> member) { if (member instanceof AnnotatedField) { return BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedField<?>)member).build(); } else if (member instanceof AnnotatedMethod) { return BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedMethod<?>)member).build(); } else { throw new IllegalArgumentException("Unsupported member type " + member.getClass().getName()); } }
public ConstructorInjectionBean(final WebBeansContext webBeansContext, final Class<T> returnType, final AnnotatedType<T> at, final Boolean passivationCapable) { super(webBeansContext, WebBeansType.DEPENDENT, at, BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at).build(), returnType); try { INJECTION_TARGET_FIELD.set(this, new ConstructorInjectionTarget<T>(getAnnotatedType(), getInjectionPoints(), getWebBeansContext())); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } if (passivationCapable != null) { this.passivationCapable = passivationCapable; } else { this.passivationCapable = super.isPassivationCapable(); } }
public OpenEJBBeanBuilder(final BeanContext bc, final WebBeansContext webBeansContext, final AnnotatedType<A> annotatedType) { super(webBeansContext, annotatedType, BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build()); this.beanContext = bc; }
public <T> BeanAttributesBuilder<T, AnnotatedType<T>> newBeanAttibutes(AnnotatedType<T> annotatedType) { return newBeanAttibutes(annotatedType, false); }
public <T> BeanAttributes<T> createBeanAttributes(final AnnotatedType<T> type) { return new CdiEjbBean.EJBBeanAttributesImpl( findBeanContext(webBeansContext, type.getJavaClass()), BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build()); }
private ProcessBeanAttributesImpl<T> fireProcessBeanAttributes(AnnotatedField<? super T> annotatedField) { return webBeansContext.getWebBeansUtil().fireProcessBeanAttributes( annotatedField, annotatedField.getJavaMember().getType(), BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedField<T>)annotatedField).build()); } }
/** * {@inheritDoc} */ public <T> BeanAttributes<T> createBeanAttributes(AnnotatedType<T> type) { OpenWebBeansEjbPlugin ejbPlugin = webBeansContext.getPluginLoader().getEjbPlugin(); if (ejbPlugin != null && ejbPlugin.isSessionBean(type.getJavaClass())) { return ejbPlugin.createBeanAttributes(type); } return BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build(); }
public static BeanAttributesBuilderFactory forContext(WebBeansContext webBeansContext) { return new BeanAttributesBuilderFactory(webBeansContext); }
public CdiEjbBean(final BeanContext beanContext, final WebBeansContext webBeansContext, final Class beanClass, final AnnotatedType<T> at, final InjectionTargetFactoryImpl<T> factory) { super(webBeansContext, toSessionType(beanContext.getComponentType()), at, new EJBBeanAttributesImpl<T>(beanContext, BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at).build()), beanClass, factory); this.beanContext = beanContext; beanContext.set(Bean.class, this); passivatingId = beanContext.getDeploymentID() + getReturnType().getName(); isDependentAndStateful = getScope().equals(Dependent.class) && BeanType.STATEFUL.equals(beanContext.getComponentType()); }
public ConstructorInjectionBean(final WebBeansContext webBeansContext, final Class<T> returnType, final AnnotatedType<T> at, final Boolean passivationCapable) { super(webBeansContext, WebBeansType.DEPENDENT, at, BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at).build(), returnType); try { INJECTION_TARGET_FIELD.set(this, new ConstructorInjectionTarget<T>(getAnnotatedType(), getInjectionPoints(), getWebBeansContext())); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } if (passivationCapable != null) { this.passivationCapable = passivationCapable; } else { this.passivationCapable = isPassivationCapable(); } }
@Override public <U extends T> BeanConfigurator<U> read(AnnotatedType<U> type) { read(BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build()); return (BeanConfigurator<U>) this; }
@SuppressWarnings({ "rawtypes", "unchecked" }) private static void createAnnotatedTypeForExistingBeanClass(BeanManagerImpl beanManager, InjectionTargetBean bean) { WebBeansContext wbc = beanManager.getWebBeansContext(); AnnotatedElementFactory annotatedElementFactory = wbc.getAnnotatedElementFactory(); // Clear AnnotatedElementFactory caches annotatedElementFactory.clear(); AnnotatedType annotatedType = annotatedElementFactory.newAnnotatedType(bean.getBeanClass()); ReflectionHelper.set(bean, InjectionTargetBean.class, "annotatedType", annotatedType); // Updated members that were set by bean attributes BeanAttributesImpl attributes = BeanAttributesBuilder.forContext(wbc).newBeanAttibutes(annotatedType).build(); ReflectionHelper.set(bean, BeanAttributesImpl.class, "types", attributes.getTypes()); ReflectionHelper.set(bean, BeanAttributesImpl.class, "qualifiers", attributes.getQualifiers()); ReflectionHelper.set(bean, BeanAttributesImpl.class, "scope", attributes.getScope()); ReflectionHelper.set(bean, BeanAttributesImpl.class, "name", attributes.getName()); ReflectionHelper.set(bean, BeanAttributesImpl.class, "stereotypes", attributes.getStereotypes()); ReflectionHelper.set(bean, BeanAttributesImpl.class, "alternative", attributes.isAlternative()); InjectionTargetFactory factory = new InjectionTargetFactoryImpl(annotatedType, bean.getWebBeansContext()); InjectionTarget injectionTarget = factory.createInjectionTarget(bean); ReflectionHelper.set(bean, InjectionTargetBean.class, "injectionTarget", injectionTarget); LOGGER.debug("New annotated type created for bean '{}'", bean.getBeanClass()); }