本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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();
}