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

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

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

Weld.addExtension介绍

[英]Add an extension to the set of extensions.
[中]向扩展集添加扩展。

代码示例

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

@Override
public Weld addExtensions(Extension... extensions) {
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

@Override
public Weld addExtensions(Extension... extensions) {
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

@Override
public Weld addExtensions(Extension... extensions) {
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

/**
 * Define the set of extensions.
 *
 * @param extensions
 * @return self
 */
public Weld extensions(Extension... extensions) {
  this.extensions.clear();
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

/**
 * Define the set of extensions.
 *
 * @param extensions
 * @return self
 */
public Weld extensions(Extension... extensions) {
  this.extensions.clear();
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

/**
 * Define the set of extensions.
 *
 * @param extensions
 * @return self
 */
public Weld extensions(Extension... extensions) {
  this.extensions.clear();
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

/**
 * Define the set of extensions.
 *
 * @param extensions
 * @return self
 */
public Weld extensions(Extension... extensions) {
  this.extensions.clear();
  for (Extension extension : extensions) {
    addExtension(extension);
  }
  return this;
}

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

@Override
protected void configureWeld(Weld weld) {
  weld.addExtension(new RouteExtension());
}

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

@Override
protected void configureWeld(Weld weld) {
  weld.addExtension(new RouteExtension());
}

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

@SuppressWarnings("unchecked")
@Override
public Weld addExtensions(Class<? extends Extension>... extensionClasses) {
  for (Class<? extends Extension> extensionClass : extensionClasses) {
    try {
      Extension extension = SecurityActions.newInstance(extensionClass);
      addExtension(extension);
    } catch (Exception ex) {
      CommonLogger.LOG.unableToInstantiate(extensionClass, new Object[] {}, ex);
    }
  }
  return this;
}

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

@SuppressWarnings("unchecked")
@Override
public Weld addExtensions(Class<? extends Extension>... extensionClasses) {
  for (Class<? extends Extension> extensionClass : extensionClasses) {
    try {
      Extension extension = SecurityActions.newInstance(extensionClass);
      addExtension(extension);
    } catch (Exception ex) {
      CommonLogger.LOG.unableToInstantiate(extensionClass, new Object[] {}, ex);
    }
  }
  return this;
}

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

@SuppressWarnings("unchecked")
@Override
public Weld addExtensions(Class<? extends Extension>... extensionClasses) {
  for (Class<? extends Extension> extensionClass : extensionClasses) {
    try {
      Extension extension = SecurityActions.newInstance(extensionClass);
      addExtension(extension);
    } catch (Exception ex) {
      CommonLogger.LOG.unableToInstantiate(extensionClass, new Object[] {}, ex);
    }
  }
  return this;
}

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

/**
 * Attempts to initialize the classes as extensions and add them to the set of extensions.
 *
 * @param extensionClasses Classes to be initialized as extensions and added to the set of extensions
 * @return self
 */
@SuppressWarnings("unchecked")
public Weld addExtensions(Class<? extends Extension>... extensionClasses) {
  for (Class<? extends Extension> extensionClass : extensionClasses) {
    try {
      Extension extension = SecurityActions.newInstance(extensionClass);
      addExtension(extension);
    } catch (Exception ex) {
      CommonLogger.LOG.unableToInstantiate(extensionClass, new Object[] {}, ex);
    }
  }
  return this;
}

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

@Override
protected void weldInit(Object testInstance, ExtensionContext context, Weld weld, WeldInitiator.Builder weldInitiatorBuilder) {
  Class<?> testClass = testInstance.getClass();
  weld.addAlternativeStereotype(OverrideBean.class);
  ClassScanning.scanForRequiredBeanClass(testClass, weld, getExplicitInjectionInfoFromStore(context));
  weld.addBeanClass(testClass);
  weld.addExtension(new TestInstanceInjectionExtension(testClass, testInstance));
  AnnotationSupport.findRepeatableAnnotations(testClass, ActivateScopes.class)
      .forEach(ann -> weldInitiatorBuilder.activate(ann.value()));
}

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

@Override
protected void weldInit(Object testInstance, ExtensionContext context, Weld weld, WeldInitiator.Builder weldInitiatorBuilder) {
  Class<?> testClass = testInstance.getClass();
  weld.addAlternativeStereotype(OverrideBean.class);
  ClassScanning.scanForRequiredBeanClass(testClass, weld, getExplicitInjectionInfoFromStore(context));
  weld.addBeanClass(testClass);
  weld.addExtension(new TestInstanceInjectionExtension(testClass, testInstance));
  AnnotationSupport.findRepeatableAnnotations(testClass, ActivateScopes.class)
      .forEach(ann -> weldInitiatorBuilder.activate(ann.value()));
}

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

@Override
public void start(Future<Void> startFuture) throws Exception {
  Weld weld = this.weld != null ? this.weld : createDefaultWeld();
  if (weld.getContainerId() == null) {
    weld.containerId(deploymentID());
  }
  weld.addExtension(new VertxExtension(vertx, context));
  configureWeld(weld);
  // Bootstrap can take some time to complete
  vertx.executeBlocking(future -> {
    try {
      this.weldContainer = weld.initialize();
      future.complete();
    } catch (Exception e) {
      future.fail(e);
    }
  }, result -> {
    if (result.succeeded()) {
      LOGGER.info("Weld verticle started for deployment {0}", deploymentID());
      startFuture.complete();
    } else {
      startFuture.fail(result.cause());
    }
  });
}

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

@Override
public void start(Future<Void> startFuture) throws Exception {
  Weld weld = this.weld != null ? this.weld : createDefaultWeld();
  if (weld.getContainerId() == null) {
    weld.containerId(deploymentID());
  }
  weld.addExtension(new VertxExtension(vertx, context));
  configureWeld(weld);
  // Bootstrap can take some time to complete
  vertx.executeBlocking(future -> {
    try {
      this.weldContainer = weld.initialize();
      future.complete();
    } catch (Exception e) {
      future.fail(e);
    }
  }, result -> {
    if (result.succeeded()) {
      LOGGER.info("Weld verticle started for deployment {0}", deploymentID());
      startFuture.complete();
    } else {
      startFuture.fail(result.cause());
    }
  });
}

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

this.weld.addInterceptor(MockInterceptor.class);
  this.weld.addExtension(this.extension);
} else {
  this.extension = null;

代码示例来源: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());
  }
}

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

@Test
public void testConsumers() throws InterruptedException {
  try (WeldContainer weld = new Weld().disableDiscovery().addExtension(new VertxExtension()).addPackage(false, RegisterConsumersAfterBootstrapTest.class)
      .initialize()) {
    Vertx vertx = Vertx.vertx();
    try {
      weld.select(VertxExtension.class).get().registerConsumers(vertx, weld.event());
      vertx.eventBus().send(HelloObserver.HELLO_ADDRESS, "hello");
      assertEquals("hello", SYNCHRONIZER.poll(Timeouts.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
    } finally {
      vertx.close();
    }
  }
}

相关文章