类 InstanceCache
java.lang.Object
spring.turbo.util.InstanceCache
实例缓存
- 从以下版本开始:
- 1.0.0
- 作者:
- 应卓
- 另请参阅:
-
方法概要
修饰符和类型方法说明用户初始化缓存<T> TfindOrCreate(Class<?> type) 查找或尝试创建对象<T> TfindOrCreate(Class<?> type, Supplier<? extends RuntimeException> exceptionIfCannotCreateInstance) 查找或尝试创建对象static InstanceCache创建实例缓存实例static InstanceCachenewInstance(org.springframework.beans.factory.BeanFactory beanFactory) 创建实例缓存实例static InstanceCachenewInstance(org.springframework.context.ApplicationContext applicationContext) 创建实例缓存实例
-
方法详细资料
-
newInstance
创建实例缓存实例- 返回:
- InstanceCache
-
newInstance
public static InstanceCache newInstance(@Nullable org.springframework.context.ApplicationContext applicationContext) 创建实例缓存实例- 参数:
applicationContext- Spring上下文,可为null- 返回:
- InstanceCache
-
newInstance
public static InstanceCache newInstance(@Nullable org.springframework.beans.factory.BeanFactory beanFactory) 创建实例缓存实例- 参数:
beanFactory- BeanFactory实例,可为null- 返回:
- InstanceCache
-
add
用户初始化缓存- 参数:
type- 要缓存的类型 (不可为null)instance- 实例 (不可为null)- 返回:
- InstanceCache本身
-
findOrCreate
查找或尝试创建对象- 类型参数:
T- 实例泛型- 参数:
type- 实例的类型- 返回:
- 实例值
-
findOrCreate
public <T> T findOrCreate(Class<?> type, Supplier<? extends RuntimeException> exceptionIfCannotCreateInstance) 查找或尝试创建对象- 类型参数:
T- 实例泛型- 参数:
type- 实例的类型exceptionIfCannotCreateInstance- 在尝试创建对象失败时异常提供器- 返回:
- 实例值
-