@SuppressWarnings("unchecked") <X> void processBean(@Observes ProcessBean<X> processBean) { Bean<X> bean = processBean.getBean(); for (Type type : bean.getTypes()) { if (type instanceof Class<?> && MongoOperations.class.isAssignableFrom((Class<?>) type)) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Discovered %s with qualifiers %s.", MongoOperations.class.getName(), bean.getQualifiers())); } // Store the EntityManager bean using its qualifiers. mongoOperations.put(new HashSet<Annotation>(bean.getQualifiers()), (Bean<MongoOperations>) bean); } } }
/** * Implementation of a an observer which checks for EntityManager beans and stores them in {@link #entityManagers} for * later association with corresponding repository beans. * * @param <X> The type. * @param processBean The annotated type as defined by CDI. */ @SuppressWarnings("unchecked") <X> void processBean(@Observes ProcessBean<X> processBean) { Bean<X> bean = processBean.getBean(); for (Type type : bean.getTypes()) { // Check if the bean is an EntityManager. if (type instanceof Class<?> && EntityManager.class.isAssignableFrom((Class<?>) type)) { Set<Annotation> qualifiers = new HashSet<Annotation>(bean.getQualifiers()); if (bean.isAlternative() || !entityManagers.containsKey(qualifiers)) { LOGGER.debug("Discovered '{}' with qualifiers {}.", EntityManager.class.getName(), qualifiers); entityManagers.put(qualifiers, (Bean<EntityManager>) bean); } } } }
<X> void processBean(@Observes ProcessBean<X> processBean) { Bean<X> bean = processBean.getBean();
Bean<T> bean = processBean.getBean(); for (Type type : bean.getTypes()) { if (!(type instanceof Class<?>)) {
@SuppressWarnings("unchecked") <X> void processBean(@Observes ProcessBean<X> processBean) { Bean<X> bean = processBean.getBean(); for (Type type : bean.getTypes()) { if (type instanceof Class<?> && Session.class.isAssignableFrom((Class<?>) type)) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Discovered %s with qualifiers %s.", Session.class.getName(), bean.getQualifiers())); } sessions.put(new HashSet<Annotation>(bean.getQualifiers()), (Bean<Session>) bean); } } }
@SuppressWarnings("unchecked") <X> void processBean(@Observes ProcessBean<X> processBean) { Bean<X> bean = processBean.getBean(); for (Type type : bean.getTypes()) { if (type instanceof Class<?> && MongoOperations.class.isAssignableFrom((Class<?>) type)) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Discovered %s with qualifiers %s.", MongoOperations.class.getName(), bean.getQualifiers())); } // Store the EntityManager bean using its qualifiers. mongoOperations.put(new HashSet<Annotation>(bean.getQualifiers()), (Bean<MongoOperations>) 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 observeProcessBean(@Observes ProcessBean<Cockatoo> event) { AfterBeanDiscoveryObserver.processBeanFiredForCockatooBean = true; assert event.getBean().getName().equals("cockatoo"); }
@SuppressWarnings("unchecked") <T> void processBean(@Observes ProcessBean<T> processBean) { Bean<T> bean = processBean.getBean(); for (Type type : bean.getTypes()) { if (type instanceof Class<?> && SolrOperations.class.isAssignableFrom((Class<?>) type)) { solrOperationsMap.put(bean.getQualifiers().toString(), ((Bean<SolrOperations>) bean)); } } }
@SuppressWarnings("unchecked") <X> void processBean(@Observes ProcessBean<X> processBean) { Bean<X> bean = processBean.getBean(); for (Type type : bean.getTypes()) { if (type instanceof Class<?> && Session.class.isAssignableFrom((Class<?>) type)) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Discovered %s with qualifiers %s.", Session.class.getName(), bean.getQualifiers())); } sessions.put(new HashSet<Annotation>(bean.getQualifiers()), (Bean<Session>) bean); } } }
void foundClientConfig(@Observes ProcessBean<?> processBean) { if (processBean.getBean().getTypes().contains(ArtemisClientConfiguration.class)) { ActiveMQCDILogger.LOGGER.discoveredConfiguration(processBean); foundConfiguration = true; } }
void foundEmbeddedConfig(@Observes ProcessBean<?> processBean) { if (processBean.getBean().getTypes().contains(Configuration.class)) { ActiveMQCDILogger.LOGGER.discoveredClientConfiguration(processBean); foundEmbeddedConfig = true; } }
public void observeProcessBean(@Observes ProcessBean<Foo> event, BeanManager beanManager) { this.fooBean = event.getBean(); testUnavailableMethodsBeforeABD(beanManager); testUnavailableMethodsBeforeADV(beanManager); }
<X> void processBean(@Observes ProcessBean<X> event) { if (!Endoscope.isEnabled()) { return; } if( event.getAnnotated().isAnnotationPresent(EndoscopeStartup.class) ){ startupBeans.add(event.getBean()); } }
public <T> void collect(@Observes ProcessBean<T> event) { if (event.getAnnotated().isAnnotationPresent(Eager.class) && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) { eagerBeansList.add(event.getBean()); } } public void load(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
public <T> void collect(@Observes ProcessBean<T> event) { if (event.getAnnotated().isAnnotationPresent(Eager.class) && event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) { eagerBeansList.add(event.getBean()); } } public void load(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
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); } }
public <T> Bean<T> processBean(Bean<T> bean, ProcessBean<T> processBean) { InjectManager cdi = _cdiManager; BaseType baseType = cdi.createTargetBaseType(processBean.getClass()); baseType = baseType.fill(cdi.createTargetBaseType(bean.getBeanClass())); _pendingEventList.add(new PendingEvent(processBean, baseType)); return processBean.getBean(); }