RaigorJiang commented on a change in pull request #15415:
URL: https://github.com/apache/shardingsphere/pull/15415#discussion_r806707736



##########
File path: 
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
##########
@@ -50,18 +70,39 @@
      * @throws SQLException SQL exception
      */
     public static TextProtocolBackendHandler newInstance(final DatabaseType 
databaseType, final RALStatement sqlStatement, final ConnectionSession 
connectionSession) throws SQLException {
+        TextProtocolBackendHandler result = null;
         if (sqlStatement instanceof QueryableRALStatement) {
-            return 
QueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement) 
sqlStatement, connectionSession);
+            result = 
ScalingQueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement) 
sqlStatement, connectionSession);
         }
         if (sqlStatement instanceof UpdatableRALStatement) {
-            return 
UpdatableRALBackendHandlerFactory.newInstance((UpdatableRALStatement) 
sqlStatement);
+            result = 
ScalingUpdatableRALBackendHandlerFactory.newInstance((UpdatableRALStatement) 
sqlStatement);
         }
         if (sqlStatement instanceof CommonDistSQLStatement) {
-            return 
CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) 
sqlStatement, connectionSession);
+            result = 
CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) 
sqlStatement, connectionSession);
         }
         if (sqlStatement instanceof AdvancedDistSQLStatement) {
-            return 
AdvancedDistSQLBackendHandlerFactory.newInstance(databaseType, 
(AdvancedDistSQLStatement) sqlStatement, connectionSession);
+            result = 
AdvancedDistSQLBackendHandlerFactory.newInstance(databaseType, 
(AdvancedDistSQLStatement) sqlStatement, connectionSession);
+        }
+        if (result == null) {
+            HandlerParameter parameter = new 
HandlerParameter().setStatement(sqlStatement).setConnectionSession(connectionSession).setDatabaseType(databaseType);
+            result = getHandler(sqlStatement, parameter);
+        }
+        return result;
+    }
+    
+    private static RALBackendHandler newInstance(final Class<? extends 
RALBackendHandler> clazz) {
+        try {
+            return clazz.newInstance();
+        } catch (final InstantiationException | IllegalAccessException ex) {
+            throw new UnsupportedOperationException(String.format("Can not 
find public constructor for class `%s`", clazz.getName()));
+        }
+    }
+    
+    private static RALBackendHandler getHandler(final RALStatement 
sqlStatement, final HandlerParameter<RALStatement> parameter) {
+        Class<? extends RALBackendHandler> clz = 
handlerClz.get(sqlStatement.getClass().getName());
+        if (null == clz) {

Review comment:
       `clazz` may be a more common name




-- 
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