当前位置: 首页>>代码示例>>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;未经允许,请勿转载。