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

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

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

Bean.isAlternative介绍

[英]Returns true if declares as policy
[中]如果声明为策略,则返回true

代码示例

代码示例来源: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

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);
if (bean.isAlternative() || !clientResources.containsKey(qualifiers)) {
  LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", ClientResources.class.getName(),
      qualifiers));

代码示例来源:origin: resteasy/Resteasy

@Override
public CompletionStage<Object> construct(boolean unwrapAsync)
{
 Set<Bean<?>> beans = manager.getBeans(type);
 if (beans.size() > 1)
 {
   Set<Bean<?>> modifiableBeans = new HashSet<Bean<?>>();
   modifiableBeans.addAll(beans);
   // Ambiguous dependency may occur if a resource has subclasses
   // Therefore we remove those beans
   for (Iterator<Bean<?>> iterator = modifiableBeans.iterator(); iterator.hasNext();)
   {
    Bean<?> bean = iterator.next();
    if (!bean.getBeanClass().equals(type) && !bean.isAlternative())
    {
      // remove Beans that have clazz in their type closure but not as a base class
      iterator.remove();
    }
   }
   beans = modifiableBeans;
 }
 if (LogMessages.LOGGER.isDebugEnabled()) //keep this check for performance reasons, as toString() is expensive on CDI Bean
 {
   LogMessages.LOGGER.debug(Messages.MESSAGES.beansFound(type, beans));
 }
 Bean<?> bean = manager.resolve(beans);
 CreationalContext<?> context = manager.createCreationalContext(bean);
 return CompletableFuture.completedFuture(manager.getReference(bean, type, context));
}

代码示例来源:origin: org.apache.openwebbeans/openwebbeans-impl

@Override
public boolean isAlternative()
{
  return bean.isAlternative();
}

代码示例来源:origin: org.apache.openwebbeans/openwebbeans-impl

@Override
public boolean isAlternative()
{
  return bean.isAlternative();
}

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

private boolean isAlternativeBean(Class<?> enabledClass, Multimap<Class<?>, Bean<?>> beansByClass) {
  // check that the class is a bean class of at least one alternative
  for (Bean<?> bean : beansByClass.get(enabledClass)) {
    if (bean.isAlternative()) {
      return true;
    }
  }
  return false;
}

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

private boolean isAlternativeBean(Class<?> enabledClass, Multimap<Class<?>, Bean<?>> beansByClass) {
  // check that the class is a bean class of at least one alternative
  for (Bean<?> bean : beansByClass.get(enabledClass)) {
    if (bean.isAlternative()) {
      return true;
    }
  }
  return false;
}

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

@Override
public boolean isAlternative()
{
 return getBean().isAlternative();
}

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

static Set<Bean<?>> findAlternativeStereotypeBeans(Class<? extends Annotation> stereotype, Probe probe) {
  Set<Bean<?>> beans = new HashSet<Bean<?>>();
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && bean.getStereotypes().contains(stereotype)) {
      beans.add(bean);
    }
  }
  return beans;
}

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

static Set<Bean<?>> findAlternativeStereotypeBeans(Class<? extends Annotation> stereotype, Probe probe) {
  Set<Bean<?>> beans = new HashSet<Bean<?>>();
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && bean.getStereotypes().contains(stereotype)) {
      beans.add(bean);
    }
  }
  return beans;
}

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

static Set<Bean<?>> findAlternativeStereotypeBeans(Class<? extends Annotation> stereotype, Probe probe) {
  Set<Bean<?>> beans = new HashSet<Bean<?>>();
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && bean.getStereotypes().contains(stereotype)) {
      beans.add(bean);
    }
  }
  return beans;
}

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

static Set<Bean<?>> findAlternativeStereotypeBeans(Class<? extends Annotation> stereotype, Probe probe) {
  Set<Bean<?>> beans = new HashSet<Bean<?>>();
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && bean.getStereotypes().contains(stereotype)) {
      beans.add(bean);
    }
  }
  return beans;
}

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

static Set<Bean<?>> findAlternativeStereotypeBeans(Class<? extends Annotation> stereotype, Probe probe) {
  Set<Bean<?>> beans = new HashSet<Bean<?>>();
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && bean.getStereotypes().contains(stereotype)) {
      beans.add(bean);
    }
  }
  return beans;
}

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

static Bean<?> findAlternativeBean(Class<?> beanClass, Probe probe) {
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && beanClass.equals(bean.getBeanClass())) {
      return bean;
    }
  }
  return null;
}

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

static Bean<?> findAlternativeBean(Class<?> beanClass, Probe probe) {
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && beanClass.equals(bean.getBeanClass())) {
      return bean;
    }
  }
  return null;
}

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

static Bean<?> findAlternativeBean(Class<?> beanClass, Probe probe) {
  for (Bean<?> bean : probe.getBeans()) {
    if (bean.isAlternative() && beanClass.equals(bean.getBeanClass())) {
      return bean;
    }
  }
  return null;
}

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

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

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

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

相关文章