mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Optimize] Common 整理代码;
[Optimize] CacheStoreBuilder 整理代码格式;
This commit is contained in:
parent
3a918fe3ee
commit
c94f3d83e7
@ -97,7 +97,8 @@ public class CacheStoreBuilder {
|
|||||||
* 获取一个当前可用的高优先级 Factory 对象.
|
* 获取一个当前可用的高优先级 Factory 对象.
|
||||||
* @return 返回可用的高优先级 Factory 对象.
|
* @return 返回可用的高优先级 Factory 对象.
|
||||||
*/
|
*/
|
||||||
private static <R extends CacheStore<?>> R getFactory(CacheStoreSource storeSource, Function<CacheStoreFactory, R> function)
|
private static <R extends CacheStore<?>> R getFactory(CacheStoreSource storeSource,
|
||||||
|
Function<CacheStoreFactory, R> function)
|
||||||
throws NoSuchFactoryException {
|
throws NoSuchFactoryException {
|
||||||
if (FACTORY_LIST.size() == 0) {
|
if (FACTORY_LIST.size() == 0) {
|
||||||
loadFactory();
|
loadFactory();
|
||||||
@ -130,8 +131,9 @@ public class CacheStoreBuilder {
|
|||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!iterator.hasNext()) {
|
if (!iterator.hasNext()) {
|
||||||
throw new NoSuchFactoryException(new GetCacheStoreException("CacheStoreFactory " + info.getFactoryName() +
|
throw new NoSuchFactoryException(new GetCacheStoreException("CacheStoreFactory " +
|
||||||
" (" + factory.getClass().getName() + ") 创建 CacheStore 时发生异常.", e));
|
info.getFactoryName() + " (" + factory.getClass().getName() +
|
||||||
|
") 创建 CacheStore 时发生异常.", e));
|
||||||
} else {
|
} else {
|
||||||
if (e instanceof GetCacheStoreException) {
|
if (e instanceof GetCacheStoreException) {
|
||||||
log.warn("CacheStoreFactory '{} ({})' 无法提供相应 CacheStore. 原因: {}",
|
log.warn("CacheStoreFactory '{} ({})' 无法提供相应 CacheStore. 原因: {}",
|
||||||
@ -167,7 +169,8 @@ public class CacheStoreBuilder {
|
|||||||
* @return 返回新的存储容器, 与其他容器互不干扰.
|
* @return 返回新的存储容器, 与其他容器互不干扰.
|
||||||
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
||||||
*/
|
*/
|
||||||
public static <V> SingleCacheStore<V> newSingleCacheStore(CacheStoreSource storeSource, String identify, StringConverter<V> converter) {
|
public static <V> SingleCacheStore<V> newSingleCacheStore(CacheStoreSource storeSource, String identify,
|
||||||
|
StringConverter<V> converter) {
|
||||||
try {
|
try {
|
||||||
return getFactory(storeSource, factory -> {
|
return getFactory(storeSource, factory -> {
|
||||||
SingleCacheStore<V> singleCacheStoreInstance = factory.newSingleCacheStore(identify, converter);
|
SingleCacheStore<V> singleCacheStoreInstance = factory.newSingleCacheStore(identify, converter);
|
||||||
@ -202,7 +205,8 @@ public class CacheStoreBuilder {
|
|||||||
* @return 返回新的存储容器, 与其他容器互不干扰.
|
* @return 返回新的存储容器, 与其他容器互不干扰.
|
||||||
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
||||||
*/
|
*/
|
||||||
public static <E> ListCacheStore<E> newListCacheStore(CacheStoreSource storeSource, String identify, StringConverter<E> converter) {
|
public static <E> ListCacheStore<E> newListCacheStore(CacheStoreSource storeSource, String identify,
|
||||||
|
StringConverter<E> converter) {
|
||||||
try {
|
try {
|
||||||
return getFactory(storeSource, factory -> {
|
return getFactory(storeSource, factory -> {
|
||||||
ListCacheStore<E> listCacheStoreInstance = factory.newListCacheStore(identify, converter);
|
ListCacheStore<E> listCacheStoreInstance = factory.newListCacheStore(identify, converter);
|
||||||
@ -236,7 +240,8 @@ public class CacheStoreBuilder {
|
|||||||
* @return 返回新的存储容器, 与其他容器互不干扰.
|
* @return 返回新的存储容器, 与其他容器互不干扰.
|
||||||
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
||||||
*/
|
*/
|
||||||
public static <E> SetCacheStore<E> newSetCacheStore(CacheStoreSource storeSource, String identify, StringConverter<E> converter) {
|
public static <E> SetCacheStore<E> newSetCacheStore(CacheStoreSource storeSource, String identify,
|
||||||
|
StringConverter<E> converter) {
|
||||||
try {
|
try {
|
||||||
return getFactory(storeSource, factory -> {
|
return getFactory(storeSource, factory -> {
|
||||||
SetCacheStore<E> setCacheStoreInstance = factory.newSetCacheStore(identify, converter);
|
SetCacheStore<E> setCacheStoreInstance = factory.newSetCacheStore(identify, converter);
|
||||||
@ -271,7 +276,8 @@ public class CacheStoreBuilder {
|
|||||||
* @return 返回新的存储容器, 与其他容器互不干扰.
|
* @return 返回新的存储容器, 与其他容器互不干扰.
|
||||||
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
* @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出.
|
||||||
*/
|
*/
|
||||||
public static <V> MapCacheStore<V> newMapCacheStore(CacheStoreSource storeSource, String identify, StringConverter<V> converter) {
|
public static <V> MapCacheStore<V> newMapCacheStore(CacheStoreSource storeSource, String identify,
|
||||||
|
StringConverter<V> converter) {
|
||||||
try {
|
try {
|
||||||
return getFactory(storeSource, factory -> {
|
return getFactory(storeSource, factory -> {
|
||||||
MapCacheStore<V> mapCacheStoreInstance = factory.newMapCacheStore(identify, converter);
|
MapCacheStore<V> mapCacheStoreInstance = factory.newMapCacheStore(identify, converter);
|
||||||
|
Loading…
Reference in New Issue
Block a user