本文整理汇总了Java中com.google.common.cache.LoadingCache.getUnchecked方法的典型用法代码示例。如果您正苦于以下问题:Java LoadingCache.getUnchecked方法的具体用法?Java LoadingCache.getUnchecked怎么用?Java LoadingCache.getUnchecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.cache.LoadingCache
的用法示例。
在下文中一共展示了LoadingCache.getUnchecked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.google.common.cache.LoadingCache; //导入方法依赖的package包/类
@Override
public synchronized Optional<V> get(@NonNull String key)
{
checkNotNull(key);
LoadingCache<String, Optional<ExpiringValue<V>>> c = cache.getIfPresent(CurrentInstitution.get());
if( c != null )
{
Optional<ExpiringValue<V>> op = c.getUnchecked(key);
if( op.isPresent() )
{
V ev = op.get().getValue();
return Optional.fromNullable(ev);
}
}
return Optional.absent();
}
示例2: createProxyConstructor
import com.google.common.cache.LoadingCache; //导入方法依赖的package包/类
private static <T> Constructor<T> createProxyConstructor(@Nullable LoadingCache<CacheKey, ClassLoader> cache, Class<T> interfaceClass,
Class<?>... otherInterfaceClasses) {
Class<?>[] interfaceClasses = new Class[1 + otherInterfaceClasses.length];
interfaceClasses[0] = interfaceClass;
ClassLoader classLoader;
if (otherInterfaceClasses.length == 0) {
classLoader = interfaceClass.getClassLoader();
} else {
System.arraycopy(otherInterfaceClasses, 0, interfaceClasses, 1, otherInterfaceClasses.length);
List<ClassLoader> classLoaders = extractClassloaderList(interfaceClasses);
if (classLoaders.size() == 1) {
classLoader = classLoaders.get(0);
} else if (cache != null) {
classLoader = cache.getUnchecked(new CacheKey(classLoaders));
} else {
classLoader = createClassLoader(classLoaders);
}
}
Class<?> uncheckedProxyClass = Proxy.getProxyClass(classLoader, interfaceClasses);
Class<T> proxyClass = interfaceClass.getClass().cast(uncheckedProxyClass);
try {
return proxyClass.getConstructor(InvocationHandler.class);
} catch (NoSuchMethodException e) {
throw new StoreException(e);
}
}