totalo commented on a change in pull request #15386:
URL: https://github.com/apache/shardingsphere/pull/15386#discussion_r805331151



##########
File path: 
examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/ExampleGeneratorFactory.java
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.generator;
+
+import freemarker.template.Configuration;
+import freemarker.template.TemplateException;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Objects;
+import java.util.ServiceLoader;
+
+/**
+ * Example generator factory.
+ */
+public final class ExampleGeneratorFactory {
+    
+    private static final String DATA_MODEL_PATH = 
"/data-model/data-model.yaml";
+    
+    private final Configuration templateConfig;
+    
+    public ExampleGeneratorFactory() throws IOException {
+        templateConfig = createTemplateConfiguration();
+    }
+    
+    private Configuration createTemplateConfiguration() throws IOException {
+        Configuration result = new Configuration(Configuration.VERSION_2_3_31);
+        result.setDirectoryForTemplateLoading(new 
File(Objects.requireNonNull(ExampleGeneratorFactory.class.getClassLoader().getResource("template")).getFile()));
+        result.setDefaultEncoding("UTF-8");
+        return result;
+    }
+    
+    /**
+     * Generate directories and files by template.
+     * 
+     * @throws TemplateException Template Exception

Review comment:
       All right.done

##########
File path: 
examples/shardingsphere-sample/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/ExampleGeneratorFactory.java
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.generator;
+
+import freemarker.template.Configuration;
+import freemarker.template.TemplateException;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Objects;
+import java.util.ServiceLoader;
+
+/**
+ * Example generator factory.
+ */
+public final class ExampleGeneratorFactory {
+    
+    private static final String DATA_MODEL_PATH = 
"/data-model/data-model.yaml";
+    
+    private final Configuration templateConfig;
+    
+    public ExampleGeneratorFactory() throws IOException {
+        templateConfig = createTemplateConfiguration();
+    }
+    
+    private Configuration createTemplateConfiguration() throws IOException {
+        Configuration result = new Configuration(Configuration.VERSION_2_3_31);
+        result.setDirectoryForTemplateLoading(new 
File(Objects.requireNonNull(ExampleGeneratorFactory.class.getClassLoader().getResource("template")).getFile()));
+        result.setDefaultEncoding("UTF-8");
+        return result;
+    }
+    
+    /**
+     * Generate directories and files by template.
+     * 
+     * @throws TemplateException Template Exception
+     * @throws IOException IO Exception

Review comment:
       All right.thanks




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to