You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/01/20 13:40:04 UTC
[shardingsphere] branch master updated: Recover to support mix feature scenario (#14960)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new d9108a8 Recover to support mix feature scenario (#14960)
d9108a8 is described below
commit d9108a8f4974108545080b4a875356eb28ab2557
Author: Liang Zhang <te...@163.com>
AuthorDate: Thu Jan 20 21:38:36 2022 +0800
Recover to support mix feature scenario (#14960)
---
.../generator/scenario/ExampleScenarioFactory.java | 23 ++++++++++++++--------
.../src/main/resources/data-model/data-model.yaml | 3 +--
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/ExampleScenarioFactory.java b/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/ExampleScenarioFactory.java
index 4a98f30..709f65f 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/ExampleScenarioFactory.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/scenario/ExampleScenarioFactory.java
@@ -20,7 +20,9 @@ package org.apache.shardingsphere.example.generator.scenario;
import org.apache.shardingsphere.example.generator.scenario.feature.FeatureExampleScenario;
import org.apache.shardingsphere.example.generator.scenario.framework.FrameworkExampleScenario;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.ServiceLoader;
@@ -29,22 +31,23 @@ import java.util.ServiceLoader;
*/
public final class ExampleScenarioFactory {
- private final FeatureExampleScenario featureScenario;
+ private final Collection<FeatureExampleScenario> featureScenarios;
private final FrameworkExampleScenario frameworkScenario;
public ExampleScenarioFactory(final String feature, final String framework) {
- featureScenario = getFeatureScenario(feature);
+ featureScenarios = getFeatureScenarios(feature);
frameworkScenario = getFrameworkScenario(framework);
}
- private FeatureExampleScenario getFeatureScenario(final String feature) {
+ private Collection<FeatureExampleScenario> getFeatureScenarios(final String feature) {
+ Collection<FeatureExampleScenario> result = new LinkedList<>();
for (FeatureExampleScenario each : ServiceLoader.load(FeatureExampleScenario.class)) {
- if (each.getType().equals(feature)) {
- return each;
+ if (each.getType().contains(feature)) {
+ result.add(each);
}
}
- throw new UnsupportedOperationException(String.format("Can not support example scenario with feature `%s`.", feature));
+ return result;
}
private FrameworkExampleScenario getFrameworkScenario(final String framework) {
@@ -68,7 +71,9 @@ public final class ExampleScenarioFactory {
result.put("java/entity/Order.ftl", "entity/Order.java");
result.put("java/entity/OrderItem.ftl", "entity/OrderItem.java");
result.put("java/entity/Address.ftl", "entity/Address.java");
- result.putAll(featureScenario.getJavaClassTemplateMap());
+ for (FeatureExampleScenario each : featureScenarios) {
+ result.putAll(each.getJavaClassTemplateMap());
+ }
result.putAll(frameworkScenario.getJavaClassTemplateMap());
return result;
}
@@ -80,7 +85,9 @@ public final class ExampleScenarioFactory {
*/
public Map<String, String> getResourceTemplateMap() {
Map<String, String> result = new HashMap<>();
- result.putAll(featureScenario.getResourceTemplateMap());
+ for (FeatureExampleScenario each : featureScenarios) {
+ result.putAll(each.getJavaClassTemplateMap());
+ }
result.putAll(frameworkScenario.getResourceTemplateMap());
result.put("resources/logback.ftl", "logback.xml");
return result;
diff --git a/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/resources/data-model/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/resources/data-model/data-model.yaml
index b270ac7..232792c 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/resources/data-model/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-generator/src/main/resources/data-model/data-model.yaml
@@ -17,8 +17,7 @@
mode: memory
transaction: local
-#feature: sharding,readwrite-splitting,encrypt
-feature: readwrite-splitting
+feature: sharding,readwrite-splitting,encrypt
framework: jdbc
host: localhost