javax.enterprise.inject.spi.Bean.getQualifiers()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中javax.enterprise.inject.spi.Bean.getQualifiers()方法的一些代码示例,展示了Bean.getQualifiers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bean.getQualifiers()方法的具体详情如下:
包路径:javax.enterprise.inject.spi.Bean
类名称:Bean
方法名:getQualifiers

Bean.getQualifiers介绍

[英]Returns qualifiers of a bean.
[中]返回bean的限定符。

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

@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);
    }
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

if (LOG.isDebugEnabled()) {
  LOG.debug(String.format("Discovered %s with qualifiers %s.", RedisKeyValueTemplate.class.getName(),
      bean.getQualifiers()));
redisKeyValueTemplates.put(new HashSet<>(bean.getQualifiers()), (Bean<KeyValueOperations>) bean);
if (LOG.isDebugEnabled()) {
  LOG.debug(String.format("Discovered %s with qualifiers %s.", RedisKeyValueAdapter.class.getName(),
      bean.getQualifiers()));
redisKeyValueAdapters.put(new HashSet<>(bean.getQualifiers()), (Bean<RedisKeyValueAdapter>) bean);
if (LOG.isDebugEnabled()) {
  LOG.debug(String.format("Discovered %s with qualifiers %s.", RedisOperations.class.getName(),
      bean.getQualifiers()));
redisOperations.put(new HashSet<>(bean.getQualifiers()), (Bean<RedisOperations<?, ?>>) bean);

代码示例来源:origin: spring-projects/spring-data-jpa

/**
 * 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);
      }
    }
  }
}

代码示例来源:origin: lettuce-io/lettuce-core

Set<Annotation> qualifiers = LettuceSets.newHashSet(bean.getQualifiers());
if (bean.isAlternative() || !redisUris.containsKey(qualifiers)) {
  LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", RedisURI.class.getName(), qualifiers));
Set<Annotation> qualifiers = LettuceSets.newHashSet(bean.getQualifiers());
if (bean.isAlternative() || !clientResources.containsKey(qualifiers)) {
  LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", ClientResources.class.getName(),

代码示例来源:origin: jersey/jersey

decorators = beanManager.resolveDecorators(getBean().getTypes(), getBean().getQualifiers());

代码示例来源:origin: spring-projects/spring-data-neo4j

@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);
    }
  }
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@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);
    }
  }
}

代码示例来源:origin: hibernate/hibernate-validator

/**
 * 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;
    }
  }
}

代码示例来源:origin: org.jboss.seam.solder/seam-solder

public String getId()
{
 if (delegate instanceof PassivationCapable)
 {
   return DefaultBean.class.getName() + "-" + ((PassivationCapable) delegate).getId();
 }
 return DefaultBean.class.getName() + "-" + types.toString() + "-QUALIFIERS-" + delegate.getQualifiers().toString();
}

代码示例来源:origin: spring-projects/spring-data-solr

@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));
    }
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se

/**
 *
 * @param bean
 * @return the set of qualifier instances for the given bean, uses caches if possible
 */
public Set<QualifierInstance> getQualifierInstances(final Bean<?> bean) {
  if (bean instanceof RIBean) {
    return ((RIBean<?>) bean).getQualifierInstances();
  }
  return getQualifierInstances(bean.getQualifiers());
}

代码示例来源:origin: weld/core

/**
 *
 * @param bean
 * @return the set of qualifier instances for the given bean, uses caches if possible
 */
public Set<QualifierInstance> getQualifierInstances(final Bean<?> bean) {
  if (bean instanceof RIBean) {
    return ((RIBean<?>) bean).getQualifierInstances();
  }
  return getQualifierInstances(bean.getQualifiers());
}

代码示例来源:origin: weld/core

public static Set<QualifierInstance> of(Bean<?> bean, MetaAnnotationStore store) {
  if (bean instanceof RIBean<?>) {
    return ((RIBean<?>) bean).getQualifierInstances();
  }
  return of(bean.getQualifiers(), store);
}

代码示例来源:origin: weld/core

/**
 *
 * @param bean
 * @return the set of qualifier instances for the given bean, uses caches if possible
 */
public Set<QualifierInstance> getQualifierInstances(final Bean<?> bean) {
  if (bean instanceof RIBean) {
    return ((RIBean<?>) bean).getQualifierInstances();
  }
  return getQualifierInstances(bean.getQualifiers());
}

代码示例来源:origin: com.caucho/resin

private Object writeReplace()
{
 return new InjectionPointImplHandle(_bean.getBeanClass().getName(),
                   _bean.getQualifiers(),
                   getMember(), 
                   _qualifiers,
                    ((Class<?>) getType()).getName());
}

代码示例来源:origin: org.infinispan/infinispan-cdi

public void observeEmbeddedCacheManagerBean(ProcessBean<?> processBean) {
  if (processBean.getBean().getTypes().contains(EmbeddedCacheManager.class) && !processBean.getAnnotated().isAnnotationPresent(DefaultBean.class)) {
    // Install any non-default EmbeddedCacheManager producers. We handle default ones separately, to ensure we only pick them up if installed
    installedEmbeddedCacheManagers.add(processBean.getBean().getQualifiers());
  }
}

代码示例来源:origin: org.jboss.seam.solder/seam-solder

private <X, T> Bean<T> createGenericProducerMethod(ProducerMethodHolder<X, T> holder, GenericIdentifier identifier, BeanManager beanManager, Class<? extends Annotation> scopeOverride, boolean alternative, Class<?> javaClass)
{
 Set<Annotation> qualifiers = getQualifiers(beanManager, identifier, holder.getBean().getQualifiers());
 Set<Annotation> declaringBeanQualifiers = getQualifiers(beanManager, identifier, Collections.<Annotation> emptySet());
 return new GenericProducerMethod<T, X>(holder.getBean(), identifier, holder.getProducerMethod(), holder.getDisposerMethod(), qualifiers, declaringBeanQualifiers, scopeOverride, alternative, javaClass, beanManager);
}

代码示例来源:origin: weld/core

@Override
public boolean test(Bean<?> bean) {
  return testBda(bda, bean) && testEquals(kind, BeanKind.from(bean)) && testContainsIgnoreCase(beanClass, bean.getBeanClass())
      && testContainsIgnoreCase(scope, bean.getScope()) && testAnyContains(beanType, bean.getTypes())
      && testAnyContains(qualifier, bean.getQualifiers()) && testEquals(isAlternative, bean.isAlternative())
      && testAnyContains(stereotypes, bean.getStereotypes()) && testUnused(bean);
}

代码示例来源:origin: weld/core

@Override
public boolean test(Bean<?> bean) {
  return testBda(bda, bean) && testEquals(kind, BeanKind.from(bean)) && testContainsIgnoreCase(beanClass, bean.getBeanClass())
      && testContainsIgnoreCase(scope, bean.getScope()) && testAnyContains(beanType, bean.getTypes())
      && testAnyContains(qualifier, bean.getQualifiers()) && testEquals(isAlternative, bean.isAlternative())
      && testAnyContains(stereotypes, bean.getStereotypes()) && testUnused(bean);
}

代码示例来源:origin: weld/core

@Override
public boolean test(Bean<?> bean) {
  return testBda(bda, bean) && testEquals(kind, BeanKind.from(bean)) && testContainsIgnoreCase(beanClass, bean.getBeanClass())
      && testContainsIgnoreCase(scope, bean.getScope()) && testAnyContains(beanType, bean.getTypes())
      && testAnyContains(qualifier, bean.getQualifiers()) && testEquals(isAlternative, bean.isAlternative())
      && testAnyContains(stereotypes, bean.getStereotypes()) && testUnused(bean);
}

相关文章