org.jboss.weld.environment.se.Weld.addAlternative()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(184)

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

Weld.addAlternative介绍

[英]Add an alternative class to the list of selected alternatives for a synthetic bean archive.

This method does not add any class to the set of bean classes for the synthetic bean archive. It's purpose is solely to compensate the absence of the beans.xml descriptor.
[中]向合成bean归档的选定备选方案列表中添加一个备选方案类。
此方法不会向合成bean归档的bean类集合添加任何类。它的目的只是为了弥补beans.xml描述符的缺失。

代码示例

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

@Override
public Weld selectAlternatives(Class<?>... alternativeClasses) {
  for (Class<?> alternativeClass : alternativeClasses) {
    addAlternative(alternativeClass);
  }
  return this;
}

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

@Override
public Weld selectAlternatives(Class<?>... alternativeClasses) {
  for (Class<?> alternativeClass : alternativeClasses) {
    addAlternative(alternativeClass);
  }
  return this;
}

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

@Override
public Weld selectAlternatives(Class<?>... alternativeClasses) {
  for (Class<?> alternativeClass : alternativeClasses) {
    addAlternative(alternativeClass);
  }
  return this;
}

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

/**
 * Add alternatives classes to the list of selected alternatives for the synthetic bean archive.
 * <p>
 * This method does not add any class to the set of bean classes of the synthetic bean archive.
 * </p>
 * @param alternativeClasses classes of the alternatives to select
 * @return self
 */
public Weld selectAlternatives(Class<?>... alternativeClasses) {
  for (Class<?> clazz : alternativeClasses) {
    addAlternative(clazz);
  }
  return this;
}

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

/**
 * Select alternatives for the synthetic bean archive, all previous values are removed.
 * <p>
 * This method does not add any class to the set of bean classes for the synthetic bean archive. It's purpose is solely to compensate the absence of the
 * <code>beans.xml</code> descriptor.
 *
 * @param alternativeClasses
 * @return self
 */
public Weld alternatives(Class<?>... alternativeClasses) {
  selectedAlternatives.clear();
  for (Class<?> alternativeClass : alternativeClasses) {
    addAlternative(alternativeClass);
  }
  return this;
}

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

MockBean<?> mockBean = (MockBean<?>) bean;
if (mockBean.isAlternative() && mockBean.isSelectForSyntheticBeanArchive()) {
  this.weld.addAlternative(mockBean.getBeanClass());

代码示例来源:origin: weld/weld-junit

MockBean<?> mockBean = (MockBean<?>) bean;
if (mockBean.isAlternative() && mockBean.isSelectForSyntheticBeanArchive()) {
  this.weld.addAlternative(mockBean.getBeanClass());

代码示例来源:origin: org.apache.camel/camel-test-cdi

CamelCdiDeployment(TestClass test, CamelCdiContext context) {
  this.context = context;
  weld = new Weld()
    // TODO: check parallel execution
    .containerId("camel-context-cdi")
    .property(ConfigurationKey.RELAXED_CONSTRUCTION.get(), true)
    .property(Weld.SHUTDOWN_HOOK_SYSTEM_PROPERTY, false)
    .enableDiscovery()
    .beanClasses(test.getJavaClass().getDeclaredClasses())
    .addBeanClass(test.getJavaClass())
    .addExtension(new CdiCamelExtension());
  // Apply deployment customization provided by the @Beans annotation
  // if present on the test class
  if (test.getJavaClass().isAnnotationPresent(Beans.class)) {
    Beans beans = test.getJavaClass().getAnnotation(Beans.class);
    weld.addExtension(new CamelCdiTestExtension(beans));
    for (Class<?> alternative : beans.alternatives()) {
      // It is not necessary to add the alternative class with WELD-2218
      // anymore, though it's kept for previous versions
      weld.addBeanClass(alternative)
        .addAlternative(alternative);
    }
    for (Class<?> clazz : beans.classes()) {
      weld.addBeanClass(clazz);
    }
    weld.addPackages(false, beans.packages());
  }
}

相关文章