当前位置: 首页>>代码示例>>Java>>正文


Java BeanManager.getExtension方法代码示例

本文整理汇总了Java中javax.enterprise.inject.spi.BeanManager.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java BeanManager.getExtension方法的具体用法?Java BeanManager.getExtension怎么用?Java BeanManager.getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.enterprise.inject.spi.BeanManager的用法示例。


在下文中一共展示了BeanManager.getExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: produce

import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
public JsonDataProvider produce(BeanManager beanManager) {
    ProbeExtension extension = beanManager.getExtension(ProbeExtension.class);
    if (extension == null) {
        throw new IllegalStateException("ProbeExtension not available");
    }
    try {
        // Unfortunately, getJsonDataProvider() is package-private
        Method getProviderMethod = SecurityActions.getDeclaredMethod(ProbeExtension.class, "getJsonDataProvider");
        if (getProviderMethod == null) {
            throw new IllegalStateException("ProbeExtension.getJsonDataProvider() method not found or inaccessible");
        }
        SecurityActions.ensureAccessible(getProviderMethod);
        return (JsonDataProvider) getProviderMethod.invoke(extension);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new IllegalStateException("Unable to get JsonDataProvider", e);
    }
}
 
开发者ID:weld,项目名称:weld-vertx,代码行数:20,代码来源:JsonDataProviderProducer.java

示例2: HystrixCommandInterceptor

import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Inject
public HystrixCommandInterceptor(@ConfigProperty(name = "MP_Fault_Tolerance_NonFallback_Enabled", defaultValue = "true") Boolean nonFallBackEnable,  @ConfigProperty(name = SYNC_CIRCUIT_BREAKER_KEY, defaultValue = "true") Boolean syncCircuitBreakerEnabled, BeanManager beanManager) {
    this.nonFallBackEnable = nonFallBackEnable;
    this.syncCircuitBreakerEnabled = syncCircuitBreakerEnabled;
    this.beanManager = beanManager;
    this.extension = beanManager.getExtension(HystrixExtension.class);
    this.commandMetadataMap = new ConcurrentHashMap<>();
    // WORKAROUND: Hystrix does not allow to use custom HystrixCircuitBreaker impl
    // See also https://github.com/Netflix/Hystrix/issues/9
    try {
        Field field = SecurityActions.getDeclaredField(com.netflix.hystrix.HystrixCircuitBreaker.Factory.class, "circuitBreakersByCommand");
        SecurityActions.setAccessible(field);
        this.circuitBreakers = (ConcurrentHashMap<String, HystrixCircuitBreaker>) field.get(null);
    } catch (Exception e) {
        throw new IllegalStateException("Could not obtain reference to com.netflix.hystrix.HystrixCircuitBreaker.Factory.circuitBreakersByCommand");
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:19,代码来源:HystrixCommandInterceptor.java


注:本文中的javax.enterprise.inject.spi.BeanManager.getExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。