<X> void processBean(@Observes ProcessBean<X> event, BeanManager manager) { if (!beanDiscoveryOver) { Annotation genericConfiguration = getGenericConfiguration(event.getAnnotated()); if (genericConfiguration != null) { // Ensure that this generic configuration hasn't been registered // yet! if (genericConfigurationPoints.containsKey(genericConfiguration)) { throw new IllegalStateException( "Generic configuration " + genericConfiguration + " is defined twice [" + event.getAnnotated() + ", " + genericConfigurationPoints.get(genericConfiguration).getAnnotated() + "]"); } // Register the bean for use later Set<Annotation> qualifiers = event.getBean().getQualifiers(); Iterator<Annotation> iterator = qualifiers.iterator(); while (iterator.hasNext()) { Annotation qualifier = iterator.next(); if (qualifier.annotationType().equals(Synthetic.class)) { iterator.remove(); } } GenericIdentifier identifier = new GenericIdentifier(qualifiers, genericConfiguration); genericConfigurationPoints.put( identifier, new GenericConfigurationHolder(event.getAnnotated(), event.getBean().getBeanClass())); } } }
public void processBean(@Observes ProcessBean<?> event) { FlowScoped flowScoped = event.getAnnotated().getAnnotation(FlowScoped.class); if (null != flowScoped) { FlowCDIContext.FlowBeanInfo fbi = new FlowCDIContext.FlowBeanInfo(); fbi.definingDocumentId = flowScoped.definingDocumentId(); fbi.id = flowScoped.value(); flowScopedBeanFlowIds.put(event.getBean(), fbi); } }
private void beans(@Observes ProcessBean<?> pb, BeanManager manager) { cdiBeans.add(pb.getBean()); // Lookup for CDI event endpoint injection points pb.getBean() .getInjectionPoints() .stream() .filter(ip -> CdiEventEndpoint.class.equals(getRawType(ip.getType()))) .forEach( ip -> { Type type = ip.getType() instanceof ParameterizedType ? ((ParameterizedType) ip.getType()).getActualTypeArguments()[0] : Object.class; String uri = eventEndpointUri(type, ip.getQualifiers()); cdiEventEndpoints.put( uri, new CdiEventEndpoint<>(uri, type, ip.getQualifiers(), manager)); }); }
void processBean(@Observes ProcessBean event, BeanManager beanManager) { Bean bean = event.getBean(); context.beans.add(bean); // if (bean.getScope() == Singleton.class) { singletons.add(bean); } }
/** * Implementation of a an observer which checks for RedisURI beans and stores them in {@link * #redisUris} for later association with corresponding repository beans. * * @param <T> The type. * @param processBean The annotated type as defined by CDI. */ @SuppressWarnings("unchecked") <T> void processBean(@Observes ProcessBean<T> processBean) { Bean<T> bean = processBean.getBean(); for (Type type : bean.getTypes()) { // Check if the bean is an RedisURI. if (type instanceof Class<?> && RedisURI.class.isAssignableFrom((Class<?>) type)) { Set<Annotation> qualifiers = new HashSet<Annotation>(bean.getQualifiers()); if (bean.isAlternative() || !redisUris.containsKey(qualifiers)) { LOGGER.debug( String.format( "Discovered '%s' with qualifiers %s.", RedisURI.class.getName(), qualifiers)); redisUris.put(qualifiers, (Bean<RedisURI>) bean); } } } }
/** * Watches the {@code ProcessBean} event in order to determine whether beans for {@code * ValidatorFactory} and {@code Validator} already have been registered by some other component. * * @param processBeanEvent event fired for each enabled bean. */ public void processBean(@Observes ProcessBean<?> processBeanEvent) { Contracts.assertNotNull(processBeanEvent, "The ProcessBean event cannot be null"); Bean<?> bean = processBeanEvent.getBean(); if (bean.getTypes().contains(ValidatorFactory.class) || bean instanceof ValidatorFactoryBean) { if (bean.getQualifiers().contains(defaultQualifier)) { defaultValidatorFactoryBean = bean; } if (bean.getQualifiers().contains(hibernateValidatorQualifier)) { hibernateValidatorFactoryBean = bean; } } else if (bean.getTypes().contains(Validator.class) || bean instanceof ValidatorBean) { if (bean.getQualifiers().contains(defaultQualifier)) { defaultValidatorBean = bean; } if (bean.getQualifiers().contains(hibernateValidatorQualifier)) { hibernateValidatorBean = bean; } } }
public void processBean(@Observes ProcessBean<?> event) { if (event.getAnnotated().getBaseType() instanceof Class) { pbFiredValues.add(((Class<?>) event.getAnnotated().getBaseType())); } }
public <T> void collect(@Observes ProcessBean<T> event) { if (event.getAnnotated().isAnnotationPresent(Eager.class) && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) { eagerBeansList.add(event.getBean()); } }