Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
yuankui committed Jan 15, 2020
1 parent fb7c371 commit dc7e358
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
import java.util.List;

public interface ProviderContext {
<T> Provider<T> getProvider();

List<Provider> getAllProviders();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@

@Slf4j
public class GenericExecutionPlan implements ExecutionPlan {
private final List<Provider<?>> providers;
private Callable callable;

public GenericExecutionPlan(List<Provider<?>> providerList) {
this.providers = providerList;
}


@Override
public void init(Method method, ProviderContext providerContext) {

List<Provider> providerList = providerContext.getAllProviders();
// 按照resource分组,并且排好优先级,优先级低的,在前面
Map<String, PriorityQueue<Provider>> resourceProvidersMap = this.providers.stream()
Map<String, PriorityQueue<Provider>> resourceProvidersMap = providerList.stream()
.collect(Collectors.groupingBy(
p -> p.resourceName(),
Collectors.toCollection(() -> {
Expand All @@ -39,7 +36,7 @@ public void init(Method method, ProviderContext providerContext) {
Map<Provider, Result> initResult = new LinkedHashMap<>();

// 循环provider次,就算每次只选出一个,是驴是马,也该得出结论了把?
for (int i = 0; i < this.providers.size(); i++) {
for (int i = 0; i < providerList.size(); i++) {
for (Map.Entry<String, PriorityQueue<Provider>> entry : resourceProvidersMap.entrySet()) {
String resourceName = entry.getKey();
PriorityQueue<Provider> list = entry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


public class GenericRunner implements Runner {
Expand All @@ -30,8 +31,12 @@ public void addProvider(Provider<?> provider) {

@Override
public ExecutionPlan create(Method method) {
GenericExecutionPlan plan = new GenericExecutionPlan(this.providerList);
plan.init(method, null);
GenericExecutionPlan plan = new GenericExecutionPlan();
plan.init(method, () -> {
return this.providerList
.stream()
.collect(Collectors.toList());
});
return plan;
}
}

0 comments on commit dc7e358

Please sign in to comment.