@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()); }
public BeanAttributes<T> getBeanAttributes() { // make sure we always have an @Any Qualifier as well. qualifiers.add(AnyLiteral.INSTANCE); return new BeanAttributesImpl<>(types, qualifiers, scope, name, false, stereotypes, alternative); } }
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; }
(!beanAttributes.isAlternative() || isEnabledAlternative(at, beanAttributes.getStereotypes())))
return new JmsBean<>(webBeansContext, model, new BeanAttributesImpl<>(apiTypes, qualifiers));
protected BuiltInOwbBean( WebBeansContext webBeansContext, WebBeansType webBeansType, BeanAttributesImpl<T> beanAttributes, Class<T> returnType, boolean nullable, ProducerFactory<T> producerFactory) { super(webBeansContext, webBeansType, beanAttributes, returnType, nullable); Asserts.assertNotNull(producerFactory, "ProducerFactory"); producer = producerFactory.createProducer(this); }
public InjectionPointBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.INJECTIONPOINT, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(InjectionPoint.class, Object.class)), InjectionPoint.class, false, new SimpleProducerFactory<>(new InjectionPointProducer())); }
public EventMetadataBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.METADATA, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(EventMetadata.class, Object.class)), EventMetadata.class, false, new SimpleProducerFactory<>(new EventMetadataProducer())); }
public BeanManagerBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.MANAGER, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(BeanManager.class, Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET), BeanManager.class, false, new SimpleProducerFactory<>(new BeanManagerProducer(webBeansContext))); }
public InterceptionFactoryBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.INTERCEPTIONFACTORY, new BeanAttributesImpl<>( CollectionUtil.<Type>unmodifiableSet(InterceptionFactory.class, Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET), InterceptionFactory.class, false, new SimpleProducerFactory<>(new InterceptionFactoryProducer(webBeansContext))); }
public RequestContextControllerBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.MANAGER, new BeanAttributesImpl<>(CollectionUtil.unmodifiableSet(RequestContextController.class, Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET), RequestContextController.class, false, new SimpleProducerFactory<>(new RequestContextControllerProducer(webBeansContext))); }
@SuppressWarnings("serial") public InterceptorMetadataBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.METADATA, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(Interceptor.class, Object.class)), new TypeLiteral<Interceptor<T>>(){}.getRawType(), false, new SimpleProducerFactory<>(new MetadataProducer<Interceptor<T>>())); }
@SuppressWarnings("serial") public InstanceBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.INSTANCE, new BeanAttributesImpl(CollectionUtil.unmodifiableSet(Instance.class, Provider.class, Object.class)), new TypeLiteral<Instance<T>>(){}.getRawType(), false, new SimpleProducerFactory(new InstanceProducer(webBeansContext))); }
@SuppressWarnings("serial") public BeanMetadataBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.METADATA, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(Bean.class, Contextual.class, Object.class)), new TypeLiteral<Bean<T>>(){}.getRawType(), false, new SimpleProducerFactory<>(new MetadataProducer<Bean<T>>())); }
@SuppressWarnings("serial") public DecoratorMetadataBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.METADATA, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(Decorator.class, Object.class)), new TypeLiteral<Decorator<T>>(){}.getRawType(), false, new SimpleProducerFactory<>(new MetadataProducer<Decorator<T>>())); }
@SuppressWarnings("serial") public InterceptedOrDecoratedBeanMetadataBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.METADATA, new BeanAttributesImpl<>( CollectionUtil.<Type>unmodifiableSet(Bean.class, Contextual.class, Object.class), CollectionUtil.<Annotation>unmodifiableSet(new AnnotationLiteral<Intercepted>() { }, new AnnotationLiteral<Decorated>() { })), new TypeLiteral<Bean<T>>(){}.getRawType(), false, new SimpleProducerFactory<>(new BeanMetadataProducer<Bean<T>>())); }
/** * Default constructor. * @param webBeansContext */ public ConversationBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.CONVERSATION, new BeanAttributesImpl<>( CollectionUtil.<Type>unmodifiableSet(Conversation.class, ConversationImpl.class, Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET, RequestScoped.class, "javax.enterprise.context.conversation", false, Collections.<Class<? extends Annotation>>emptySet(), false), ConversationImpl.class, false, new SimpleProducerFactory<>( new ConversationProducer(webBeansContext.getAnnotatedElementFactory().newAnnotatedType(ConversationImpl.class), webBeansContext))); setEnabled(true); }
/** * New WebBeans component class. * * @return the new component */ public <T> NewManagedBean<T> createNewComponent(OwbBean<T> bean, Class<T> type) { Asserts.assertNotNull(bean, "bean"); if (!EnumSet.of(WebBeansType.MANAGED, WebBeansType.ENTERPRISE, WebBeansType.PRODUCERMETHOD, WebBeansType.PRODUCERFIELD).contains(bean.getWebBeansType())) { throw new WebBeansConfigurationException("@New annotation on type : " + bean.getBeanClass() + " must defined as a simple or an enterprise web bean"); } AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type); BeanAttributesImpl<T> newBeanAttributes = new BeanAttributesImpl<>(bean.getTypes(), Collections.<Annotation>singleton(new NewLiteral(type))); NewManagedBean<T> newBean = new NewManagedBean<>(bean.getWebBeansContext(), bean.getWebBeansType(), annotatedType, newBeanAttributes, type, bean.getInjectionPoints()); //TODO XXX set producer return newBean; }
/** * Creates a new extesion bean. * * @param returnType return type * @param webBeansContext */ public ExtensionBean(WebBeansContext webBeansContext, Class<T> returnType) { super(webBeansContext, WebBeansType.EXTENSION, new BeanAttributesImpl<>( webBeansContext.getAnnotatedElementFactory().getAnnotatedType(returnType).getTypeClosure(), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION_SET, ApplicationScoped.class), returnType, false, new ExtensionProducerFactory<>(webBeansContext.getAnnotatedElementFactory().getAnnotatedType(returnType), webBeansContext)); }
/** * Creates a new instance of event bean. * @param webBeansContext */ @SuppressWarnings("serial") public EventBean(WebBeansContext webBeansContext) { super(webBeansContext, WebBeansType.OBSERVABLE, new BeanAttributesImpl<>(CollectionUtil.<Type>unmodifiableSet(new TypeLiteral<Event<T>>() { }.getRawType(), Object.class)), new TypeLiteral<Event<T>>(){}.getRawType(), false, new SimpleProducerFactory<>(new EventProducer<T>(webBeansContext))); }