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/11/13 08:20:05 UTC
[shardingsphere] branch master updated: Use SPI for SQLParseResultReporterCreator (#22137)
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 323a198fa47 Use SPI for SQLParseResultReporterCreator (#22137)
323a198fa47 is described below
commit 323a198fa472c852a8d6c9a907ad0d328244231c
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Nov 13 16:19:59 2022 +0800
Use SPI for SQLParseResultReporterCreator (#22137)
---
.../parser/engine/SQLParserParameterizedIT.java | 15 +++--
.../engine/dialect/MySQLParserParameterizedIT.java | 5 +-
.../dialect/PostgreSQLParserParameterizedIT.java | 5 +-
.../sql/parser/result/SQLParseResultReporter.java | 7 ---
...ter.java => SQLParseResultReporterCreator.java} | 22 +++----
...a => SQLParseResultReporterCreatorFactory.java} | 30 ++++++----
.../result/SQLParseResultReporterManager.java | 69 ----------------------
.../csv}/CsvSQLParseResultReporter.java | 6 +-
.../csv/CsvSQLParseResultReporterCreator.java} | 23 +++-----
.../log}/LogSQLParseResultReporter.java | 10 +---
.../log/LogSQLParseResultReporterCreator.java} | 23 +++-----
...sql.parser.result.SQLParseResultReporterCreator | 19 ++++++
12 files changed, 80 insertions(+), 154 deletions(-)
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java
index 6ec0a378f6c..83b791beacb 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.test.integration.sql.parser.engine;
-import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.util.exception.external.ShardingSphereExternalException;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
@@ -25,11 +24,11 @@ import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
import org.apache.shardingsphere.sql.parser.api.SQLVisitorEngine;
import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporter;
+import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterCreatorFactory;
import org.junit.Test;
import java.util.Properties;
-@RequiredArgsConstructor
@Slf4j
public abstract class SQLParserParameterizedIT {
@@ -39,8 +38,14 @@ public abstract class SQLParserParameterizedIT {
private final String databaseType;
- // TODO this will refactor as an abstract
- private final SQLParseResultReporter resultGenerator;
+ private final SQLParseResultReporter resultReporter;
+
+ public SQLParserParameterizedIT(final String sqlCaseId, final String sql, final String databaseType, final String reportType) {
+ this.sqlCaseId = sqlCaseId;
+ this.sql = sql;
+ this.databaseType = databaseType;
+ resultReporter = SQLParseResultReporterCreatorFactory.newInstance(reportType).create(databaseType);
+ }
@Test
public final void assertParseSQL() {
@@ -52,6 +57,6 @@ public abstract class SQLParserParameterizedIT {
result = "failed";
log.warn("ParserError: " + sqlCaseId + " value: " + sql + " db-type: " + databaseType);
}
- resultGenerator.printResult(sqlCaseId, databaseType, result, sql);
+ resultReporter.printResult(sqlCaseId, databaseType, result, sql);
}
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/MySQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/MySQLParserParameterizedIT.java
index 0a915ccd006..3ee72bcc84c 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/MySQLParserParameterizedIT.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/MySQLParserParameterizedIT.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.test.integration.sql.parser.engine.dialect;
import org.apache.shardingsphere.test.integration.sql.parser.engine.SQLParserParameterizedIT;
import org.apache.shardingsphere.test.integration.sql.parser.loader.SQLCaseLoader;
import org.apache.shardingsphere.test.integration.sql.parser.loader.strategy.impl.GitHubSQLCaseLoadStrategy;
-import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterManager;
import org.apache.shardingsphere.test.runner.ShardingSphereParallelTestParameterized;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
@@ -31,8 +30,8 @@ import java.util.Collection;
@RunWith(ShardingSphereParallelTestParameterized.class)
public final class MySQLParserParameterizedIT extends SQLParserParameterizedIT {
- public MySQLParserParameterizedIT(final String sqlCaseId, final String sqlCaseValue) {
- super(sqlCaseId, sqlCaseValue, "MySQL", SQLParseResultReporterManager.getProcessor("MySQL"));
+ public MySQLParserParameterizedIT(final String sqlCaseId, final String sql) {
+ super(sqlCaseId, sql, "MySQL", "CSV");
}
@Parameters(name = "{0} (MySQL) -> {1}")
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/PostgreSQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/PostgreSQLParserParameterizedIT.java
index 644c3ed507b..618125074e5 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/PostgreSQLParserParameterizedIT.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/dialect/PostgreSQLParserParameterizedIT.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.test.integration.sql.parser.engine.dialect;
import org.apache.shardingsphere.test.integration.sql.parser.engine.SQLParserParameterizedIT;
import org.apache.shardingsphere.test.integration.sql.parser.loader.SQLCaseLoader;
import org.apache.shardingsphere.test.integration.sql.parser.loader.strategy.impl.GitHubSQLCaseLoadStrategy;
-import org.apache.shardingsphere.test.integration.sql.parser.result.impl.CsvSQLParseResultReporter;
import org.apache.shardingsphere.test.runner.ShardingSphereParallelTestParameterized;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
@@ -31,8 +30,8 @@ import java.util.Collection;
@RunWith(ShardingSphereParallelTestParameterized.class)
public final class PostgreSQLParserParameterizedIT extends SQLParserParameterizedIT {
- public PostgreSQLParserParameterizedIT(final String sqlCaseId, final String sqlCaseValue) {
- super(sqlCaseId, sqlCaseValue, "PostgreSQL", new CsvSQLParseResultReporter("PostgreSQL"));
+ public PostgreSQLParserParameterizedIT(final String sqlCaseId, final String sql) {
+ super(sqlCaseId, sql, "PostgreSQL", "CSV");
}
@Parameters(name = "{0} (PostgreSQL) -> {1}")
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
index 79feaa2fece..f52af3d3720 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
@@ -28,11 +28,4 @@ public interface SQLParseResultReporter {
* @param recordValues record values
*/
void printResult(Object... recordValues);
-
- /**
- * Get the generator type.
- *
- * @return type
- */
- String getType();
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreator.java
similarity index 71%
copy from test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
copy to test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreator.java
index 79feaa2fece..8ad47d995fe 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreator.java
@@ -17,22 +17,18 @@
package org.apache.shardingsphere.test.integration.sql.parser.result;
+import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
+
/**
- * SQL parse result reporter.
+ * SQL parse result reporter creator.
*/
-public interface SQLParseResultReporter {
-
- /**
- * Print result.
- *
- * @param recordValues record values
- */
- void printResult(Object... recordValues);
+public interface SQLParseResultReporterCreator extends TypedSPI {
/**
- * Get the generator type.
- *
- * @return type
+ * Create SQL parse result reporter.
+ *
+ * @param databaseType database type
+ * @return created SQL parse result reporter
*/
- String getType();
+ SQLParseResultReporter create(String databaseType);
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java
similarity index 52%
copy from test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
copy to test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java
index 79feaa2fece..38786ad5ee8 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java
@@ -17,22 +17,28 @@
package org.apache.shardingsphere.test.integration.sql.parser.result;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry;
+
/**
- * SQL parse result reporter.
+ * SQL parse result reporter creator factory.
*/
-public interface SQLParseResultReporter {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class SQLParseResultReporterCreatorFactory {
- /**
- * Print result.
- *
- * @param recordValues record values
- */
- void printResult(Object... recordValues);
+ static {
+ ShardingSphereServiceLoader.register(SQLParseResultReporterCreator.class);
+ }
/**
- * Get the generator type.
- *
- * @return type
+ * Create new instance of SQL parse result reporter creator.
+ *
+ * @param type type
+ * @return new instance of SQL parse result reporter creator
*/
- String getType();
+ public static SQLParseResultReporterCreator newInstance(String type) {
+ return TypedSPIRegistry.getRegisteredService(SQLParseResultReporterCreator.class, type);
+ }
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterManager.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterManager.java
deleted file mode 100644
index 1eb1cc1d245..00000000000
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.test.integration.sql.parser.result;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.test.integration.sql.parser.env.SQLParserExternalITEnvironment;
-
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.util.Objects;
-
-/**
- * SQL parse result reporter manager.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-@Slf4j
-public final class SQLParseResultReporterManager {
-
- /**
- * Get the SQL parser result processor.
- *
- * @param databaseType database type
- * @return the implementation of SQLParserResultProcessor
- */
- public static SQLParseResultReporter getProcessor(final String databaseType) {
- String type = SQLParserExternalITEnvironment.getInstance().getResultProcessorType();
- try {
- Class<?> interfaceClazz = Class.forName(SQLParseResultReporter.class.getPackage().getName() + "." + SQLParseResultReporter.class.getSimpleName());
- String packageName = interfaceClazz.getPackage().getName();
- URL packagePath = Thread.currentThread().getContextClassLoader().getResource(packageName.replace(".", "/"));
- File[] classFiles = new File(Objects.requireNonNull(packagePath).getFile()).listFiles((dir, name) -> name.endsWith(".class"));
- for (File file : Objects.requireNonNull(classFiles)) {
- String className = file.getName().replaceAll(".class$", "");
- Class<?> clazz = Class.forName(packageName + "." + className);
- if (SQLParseResultReporter.class.isAssignableFrom(clazz)) {
- Field typeField = clazz.getDeclaredField("type");
- typeField.setAccessible(true);
- Constructor<?> constructor = clazz.getConstructor(String.class);
- SQLParseResultReporter result = (SQLParseResultReporter) constructor.newInstance(databaseType);
- if (type.equalsIgnoreCase(typeField.get(result).toString())) {
- return result;
- }
- }
- }
- } catch (final ReflectiveOperationException ex) {
- log.error("encounter exception when get SQLParserResultProcessor by reflection", ex);
- }
- throw new IllegalArgumentException("The processor type does not supported: " + type);
- }
-}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/CsvSQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java
similarity index 96%
rename from test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/CsvSQLParseResultReporter.java
rename to test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java
index 7da6a22a9c5..2148c524ad8 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/CsvSQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.sql.parser.result.impl;
+package org.apache.shardingsphere.test.integration.sql.parser.result.type.csv;
-import lombok.Getter;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.shardingsphere.test.integration.sql.parser.env.SQLParserExternalITEnvironment;
@@ -34,9 +33,6 @@ public final class CsvSQLParseResultReporter implements SQLParseResultReporter {
private final CSVPrinter printer;
- @Getter
- private final String type = "CSV";
-
public CsvSQLParseResultReporter(final String databaseType) {
try {
File csvFile = new File(SQLParserExternalITEnvironment.getInstance().getResultPath() + databaseType + "-result.csv");
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporterCreator.java
similarity index 67%
copy from test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java
copy to test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporterCreator.java
index e53b68cfa4c..51c7b1a3455 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporterCreator.java
@@ -15,28 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.sql.parser.result.impl;
+package org.apache.shardingsphere.test.integration.sql.parser.result.type.csv;
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporter;
+import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterCreator;
/**
- * SQL parse result reporter for log.
+ * SQL parse result reporter creator for CSV.
*/
-@Slf4j
-public final class LogSQLParseResultReporter implements SQLParseResultReporter {
+public final class CsvSQLParseResultReporterCreator implements SQLParseResultReporterCreator {
- @Getter
- private final String type = "LOG";
-
- public LogSQLParseResultReporter(final String databaseType) {
-
+ @Override
+ public SQLParseResultReporter create(final String databaseType) {
+ return new CsvSQLParseResultReporter(databaseType);
}
@Override
- public void printResult(final Object... recordValues) {
- // TODO set up the log format
- log.info("Printing the SQL parser process result");
+ public String getType() {
+ return "CSV";
}
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java
similarity index 88%
copy from test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java
copy to test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java
index e53b68cfa4c..38e33087884 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java
@@ -15,9 +15,8 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.sql.parser.result.impl;
+package org.apache.shardingsphere.test.integration.sql.parser.result.type.log;
-import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporter;
@@ -27,13 +26,6 @@ import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResu
@Slf4j
public final class LogSQLParseResultReporter implements SQLParseResultReporter {
- @Getter
- private final String type = "LOG";
-
- public LogSQLParseResultReporter(final String databaseType) {
-
- }
-
@Override
public void printResult(final Object... recordValues) {
// TODO set up the log format
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporterCreator.java
similarity index 67%
rename from test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java
rename to test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporterCreator.java
index e53b68cfa4c..37ad9fdeb93 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/impl/LogSQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporterCreator.java
@@ -15,28 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.sql.parser.result.impl;
+package org.apache.shardingsphere.test.integration.sql.parser.result.type.log;
-import lombok.Getter;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporter;
+import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterCreator;
/**
- * SQL parse result reporter for log.
+ * SQL parse result reporter creator for log.
*/
-@Slf4j
-public final class LogSQLParseResultReporter implements SQLParseResultReporter {
+public final class LogSQLParseResultReporterCreator implements SQLParseResultReporterCreator {
- @Getter
- private final String type = "LOG";
-
- public LogSQLParseResultReporter(final String databaseType) {
-
+ @Override
+ public SQLParseResultReporter create(final String databaseType) {
+ return new LogSQLParseResultReporter();
}
@Override
- public void printResult(final Object... recordValues) {
- // TODO set up the log format
- log.info("Printing the SQL parser process result");
+ public String getType() {
+ return "LOG";
}
}
diff --git a/test/integration-test/sql-parser/src/test/resources/META-INF/services/org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterCreator b/test/integration-test/sql-parser/src/test/resources/META-INF/services/org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterCreator
new file mode 100644
index 00000000000..61046543150
--- /dev/null
+++ b/test/integration-test/sql-parser/src/test/resources/META-INF/services/org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResultReporterCreator
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.test.integration.sql.parser.result.type.log.LogSQLParseResultReporterCreator
+org.apache.shardingsphere.test.integration.sql.parser.result.type.csv.CsvSQLParseResultReporterCreator