Skip to content

Commit 3ba5613

Browse files
committed
optimize
1 parent 0533f72 commit 3ba5613

File tree

6 files changed

+47
-36
lines changed

6 files changed

+47
-36
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
55
* @since 2019/6/28 23:53
66
*/
7-
public interface AggregatorConstant
7+
public interface AggregationConstant
88
{
99
Object EMPTY_MODEL = new Object();
1010
int DEFAULT_INITIAL_CAPACITY = 8;

spring-boot-data-aggregator-core/src/main/java/io/github/lvyahui8/spring/aggregate/context/AggregateContext.java

Lines changed: 0 additions & 15 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.lvyahui8.spring.aggregate.context;
2+
3+
import io.github.lvyahui8.spring.aggregate.model.DataProvideDefinition;
4+
import lombok.Data;
5+
6+
import java.util.Map;
7+
8+
/**
9+
* @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
10+
* @since 2019/7/21 22:37
11+
*/
12+
@Data
13+
public class AggregationContext {
14+
/**
15+
* 发起一次递归查询的主调线程
16+
*/
17+
Thread rootThread;
18+
/**
19+
* 根provider
20+
*/
21+
DataProvideDefinition rootProvideDefinition;
22+
/**
23+
* 此次查询生命周期中的缓存
24+
*/
25+
Map<String,Object> cacheMap;
26+
}

spring-boot-data-aggregator-core/src/main/java/io/github/lvyahui8/spring/aggregate/facade/impl/DataBeanAggregateQueryFacadeImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.lvyahui8.spring.aggregate.facade.impl;
22

3-
import io.github.lvyahui8.spring.aggregate.consts.AggregatorConstant;
3+
import io.github.lvyahui8.spring.aggregate.consts.AggregationConstant;
44
import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
55
import io.github.lvyahui8.spring.aggregate.func.MultipleArgumentsFunction;
66
import io.github.lvyahui8.spring.aggregate.model.DataProvideDefinition;
@@ -36,7 +36,7 @@ public <T> T get(String id, Map<String,Object> invokeParams, Class<T> clazz) thr
3636
invokeParams = Collections.emptyMap();
3737
}
3838
return dataBeanAggregateQueryService.get(id,invokeParams,clazz,
39-
new ConcurrentHashMap<>(AggregatorConstant.DEFAULT_INITIAL_CAPACITY));
39+
new ConcurrentHashMap<>(AggregationConstant.DEFAULT_INITIAL_CAPACITY));
4040
}
4141

4242
@Override
@@ -75,7 +75,7 @@ public <T> T get(Map<String, Object> invokeParams, MultipleArgumentsFunction<T>
7575
try {
7676
@SuppressWarnings("unchecked")
7777
T ret = (T) dataBeanAggregateQueryService.get(provider, invokeParams, applyMethod.getReturnType(),
78-
new ConcurrentHashMap<>(AggregatorConstant.DEFAULT_INITIAL_CAPACITY));
78+
new ConcurrentHashMap<>(AggregationConstant.DEFAULT_INITIAL_CAPACITY));
7979

8080
return ret;
8181
} finally {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.lvyahui8.spring.aggregate.interceptor;
22

3-
import io.github.lvyahui8.spring.aggregate.context.AggregateContext;
3+
import io.github.lvyahui8.spring.aggregate.context.AggregationContext;
44
import io.github.lvyahui8.spring.aggregate.model.DataProvideDefinition;
55

66
/**
@@ -13,43 +13,43 @@ public interface AbstractAggregateQueryInterceptor {
1313
/**
1414
* 查询正常提交, Context已经创建
1515
*
16-
* @param aggregateContext 查询上下文
16+
* @param aggregationContext 查询上下文
1717
* @return 返回为true才继续执行
1818
*/
19-
boolean querySubmitted(AggregateContext aggregateContext) ;
19+
boolean querySubmitted(AggregationContext aggregationContext) ;
2020

2121
/**
22-
* 每个Provider方法执行前, 将调用此方法
22+
* 每个Provider方法执行前, 将调用此方法. 存在并发调用
2323
*
24-
* @param aggregateContext 查询上下文
24+
* @param aggregationContext 查询上下文
2525
* @param provideDefinition 将被执行的Provider
2626
* @return 返回为true才继续执行
2727
*/
28-
boolean queryBefore(AggregateContext aggregateContext, DataProvideDefinition provideDefinition);
28+
boolean queryBefore(AggregationContext aggregationContext, DataProvideDefinition provideDefinition);
2929

3030
/**
31-
* 每个Provider方法执行成功之后, 调用此方法
31+
* 每个Provider方法执行成功之后, 调用此方法. 存在并发调用
3232
*
33-
* @param aggregateContext 查询上下文
33+
* @param aggregationContext 查询上下文
3434
* @param provideDefinition 被执行的Provider
3535
* @param result 查询结果
3636
* @return 返回结果, 如不修改不, 请直接返回参数中的result
3737
*/
38-
Object queryAfter(AggregateContext aggregateContext,DataProvideDefinition provideDefinition,Object result);
38+
Object queryAfter(AggregationContext aggregationContext, DataProvideDefinition provideDefinition, Object result);
3939

4040
/**
41-
* 每个Provider执行时, 如果抛出异常, 将调用此方法
41+
* 每个Provider执行时, 如果抛出异常, 将调用此方法. 存在并发调用
4242
*
43-
* @param aggregateContext 查询上下文
43+
* @param aggregationContext 查询上下文
4444
* @param provideDefinition 被执行的Provider
4545
* @param e Provider抛出的异常
4646
*/
47-
void exceptionHandle(AggregateContext aggregateContext,DataProvideDefinition provideDefinition,Exception e);
47+
void exceptionHandle(AggregationContext aggregationContext, DataProvideDefinition provideDefinition, Exception e);
4848

4949
/**
5050
* 一次查询全部完成.
5151
*
52-
* @param aggregateContext 查询上下文
52+
* @param aggregationContext 查询上下文
5353
*/
54-
void queryFinished(AggregateContext aggregateContext);
54+
void queryFinished(AggregationContext aggregationContext);
5555
}

spring-boot-data-aggregator-core/src/main/java/io/github/lvyahui8/spring/aggregate/service/impl/DataBeanAggregateQueryServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.lvyahui8.spring.aggregate.service.impl;
22

33
import io.github.lvyahui8.spring.aggregate.config.RuntimeSettings;
4-
import io.github.lvyahui8.spring.aggregate.consts.AggregatorConstant;
4+
import io.github.lvyahui8.spring.aggregate.consts.AggregationConstant;
55
import io.github.lvyahui8.spring.aggregate.model.*;
66
import io.github.lvyahui8.spring.aggregate.repository.DataProviderRepository;
77
import io.github.lvyahui8.spring.aggregate.service.DataBeanAggregateQueryService;
@@ -87,11 +87,11 @@ public <T> T get(DataProvideDefinition provider, Map<String, Object> invokeParam
8787
: provider.getTarget(), args);
8888
if(provider.isIdempotent()) {
8989
/* Map 中可能不能放空value */
90-
queryCache.put(invokeSignature,resultModel != null ? resultModel : AggregatorConstant.EMPTY_MODEL);
90+
queryCache.put(invokeSignature,resultModel != null ? resultModel : AggregationConstant.EMPTY_MODEL);
9191
}
9292
}
9393

94-
return resultType.cast(resultModel != AggregatorConstant.EMPTY_MODEL ? resultModel : null);
94+
return resultType.cast(resultModel != AggregationConstant.EMPTY_MODEL ? resultModel : null);
9595
}
9696

9797
@Override

0 commit comments

Comments
 (0)