當前位置: 首頁>>代碼示例>>Java>>正文


Java Instance.get方法代碼示例

本文整理匯總了Java中javax.enterprise.inject.Instance.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Instance.get方法的具體用法?Java Instance.get怎麽用?Java Instance.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.enterprise.inject.Instance的用法示例。


在下文中一共展示了Instance.get方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PreferenceStoreImpl

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
@Inject
public PreferenceStoreImpl(final PreferenceStorage storage,
                           final PreferenceScopeFactory scopeFactory,
                           @Customizable final PreferenceScopeResolutionStrategy defaultScopeResolutionStrategy,
                           final Instance<PreferenceScopeResolutionStrategy> preferenceScopeResolutionStrategy,
                           final InjectionPoint ip) {
    this.storage = storage;
    this.scopeFactory = scopeFactory;

    if (preferenceScopeResolutionStrategy.isUnsatisfied()) {
        if (ip != null) {
            String componentKey = null;
            Annotation annotation = ip.getAnnotated().getAnnotation(ComponentKey.class);
            if (annotation != null) {
                componentKey = ((ComponentKey) annotation).value();
            }

            this.defaultScopeResolutionStrategy = new DefaultPreferenceScopeResolutionStrategy(scopeFactory,
                                                                                               componentKey);
        } else {
            this.defaultScopeResolutionStrategy = defaultScopeResolutionStrategy;
        }
    } else {
        this.defaultScopeResolutionStrategy = preferenceScopeResolutionStrategy.get();
    }
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:27,代碼來源:PreferenceStoreImpl.java

示例2: initialize

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
@PostConstruct
protected void initialize() {
    log.debug("initializing AuthenticationService");

    final String prov = configurationService.getStringConfiguration("user.auth.provider", DEFAULT_AUTH_PROVIDER_NAMED);

    Instance<AuthenticationProvider> selected = CDIUtils.selectNamed(providers, prov);
    if (selected.isAmbiguous()) {
        authenticationProvider = selected.iterator().next();
        log.error("multiple candidates for AuthenticationProvider '{}' found. Chose randomly!", prov);
    } else if (selected.isUnsatisfied()) {
        log.error("no candidate for AuthenticationProvider '{}' found, falling back to default", prov);
        authenticationProvider = CDIUtils.selectNamed(providers, DEFAULT_AUTH_PROVIDER_NAMED).iterator().next();
    } else {
        authenticationProvider = selected.get();
    }
}
 
開發者ID:apache,項目名稱:marmotta,代碼行數:18,代碼來源:AuthenticationServiceImpl.java

示例3: ESBMessageAdminServiceClient

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
/**
 * An {@literal @}{@link javax.inject.Inject}able constructor that allows injecting the service client via CDI. The
 * {@code esbMessageAdminContext} must be available as a String with the {@literal @}{@link javax.inject.Named} qualifier of
 * "esbMessageAdminContext".
 *
 * @param esbMessageAdminContext The context of the application or service. For example if an API call to this service
 *         is {@code "http://esbmessageadmin.esbtools.org/api/persist"} then you should pass {@code "http://esbmessageadmin.esbtools.org"}
 *         as the esbMessageAdminContext parameter.
 * @param mapper An parameterized {@link javax.enterprise.inject.Instance} so that a bean may be optionally bound
 *         to {@link com.fasterxml.jackson.databind.ObjectMapper}. If none is explicitly bound the default will be
 *         used: {@link #DEFAULT_OBJECT_MAPPER}.
 */
@Inject
public ESBMessageAdminServiceClient(CloseableHttpClient httpClient, @Named("esbMessageAdminContext") String esbMessageAdminContext,
                           Instance<ObjectMapper> mapper) {
    this.httpClient = httpClient;
    this.esbMessageAdminContext = esbMessageAdminContext.replaceAll("/+$", "");

    if (mapper.isUnsatisfied()) {
        this.mapper = DEFAULT_OBJECT_MAPPER;
    } else {
        this.mapper = mapper.get();
    }
}
 
開發者ID:esbtools,項目名稱:esb-message-admin,代碼行數:25,代碼來源:ESBMessageAdminServiceClient.java

示例4: loadFromCache

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
/**
 * Get CDI instance messageController from cache
 * @param topic
 * @return 
 */
public JsTopicMessageController loadFromCache(String topic) {
	if(null == topic) {
		return null;
	}
	if(messageControllers.containsKey(topic)) {
		Instance<? extends JsTopicMessageController> instances = getInstances(messageControllers.get(topic));
		if(!instances.isUnsatisfied()) {
			return instances.get();
		}
	}
	return null;
}
 
開發者ID:ocelotds,項目名稱:ocelot,代碼行數:18,代碼來源:MessageControllerCache.java

示例5: getJsTopicMessageControllerFromJsTopicControl

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
/**
 * Get jstopic message controller from JsTopicControl
 * @param topic
 * @return 
 */
JsTopicMessageController getJsTopicMessageControllerFromJsTopicControl(String topic) {
	logger.debug("Looking for messageController for topic '{}' from JsTopicControl annotation", topic);
	Instance<JsTopicMessageController<?>> select = topicMessageController.select(new JsTopicCtrlAnnotationLiteral(topic));
	if(!select.isUnsatisfied()) {
		logger.debug("Found messageController for topic '{}' from JsTopicControl annotation", topic);
		return select.get();
	}
	return null;
}
 
開發者ID:ocelotds,項目名稱:ocelot,代碼行數:15,代碼來源:MessageControllerManager.java

示例6: destroy

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
public static <T> T destroy(Class<T> p_clazz, String name) {
Instance<T> instance = instance(p_clazz, name);
if (instance.isResolvable()) {
	T obj = instance.get();
	instance.destroy(obj);
	
	return obj;
}

return null;
  }
 
開發者ID:GluuFederation,項目名稱:oxCore,代碼行數:12,代碼來源:CdiUtil.java

示例7: resolve

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
private QueryExecutor resolve(
        Instance<QueryExecutor> executorsByTechnology,
        String technology) throws RuntimeException {
    if (executorsByTechnology.isAmbiguous()) {
        throw new RuntimeException(
                "More then one executors defined for technology: "
                + technology);
    } else if (executorsByTechnology.isUnsatisfied()) {
        throw new RuntimeException(
                "No executor defined for technology: " + technology);
    } else {
        return executorsByTechnology.get();
    }
}
 
開發者ID:etecture,項目名稱:dynamic-repositories,代碼行數:15,代碼來源:QueryExecutors.java

示例8: getReference

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
private InstanceHolder getReference(CDI<Object> cdi, Class<?> type, Set<Annotation> annotations) {
    Annotation[] qualifiers = annotations.toArray(new Annotation[annotations.size()]);
    Instance<Object> handler = (Instance<Object>)cdi.select(type, qualifiers);
    Object instance = handler.get();
    return new InstanceHolder(instance, handler);
}
 
開發者ID:johnament,項目名稱:reactive-cdi-events,代碼行數:7,代碼來源:ReactorObserverRegistry.java

示例9: get

import javax.enterprise.inject.Instance; //導入方法依賴的package包/類
private <T> T get(Class<? extends T> type, Supplier<T> supplier) {
	Instance<? extends T> instance = CDI.current().select(type);

	return instance.isUnsatisfied() ? supplier.get() : instance.get();
}
 
開發者ID:ljtfreitas,項目名稱:java-restify,代碼行數:6,代碼來源:RestifyProxyCdiBeanFactory.java


注:本文中的javax.enterprise.inject.Instance.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。