當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。