You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "theodoretsai (via GitHub)" <gi...@apache.org> on 2023/06/13 08:35:53 UTC

[GitHub] [shardingsphere] theodoretsai opened a new issue, #26323: Question about SPISQLExecutionHook

theodoretsai opened a new issue, #26323:
URL: https://github.com/apache/shardingsphere/issues/26323

   ## Question
   
   
   
   ```
   package org.apache.shardingsphere.infra.executor.sql.hook;
   
   import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
   import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
   
   import java.util.Collection;
   import java.util.List;
   
   /**
    * SQL Execution hook for SPI.
    */
   public final class SPISQLExecutionHook implements SQLExecutionHook {
       
       private final Collection<SQLExecutionHook> SPISQLExecutionHook = ShardingSphereServiceLoader.getServiceInstances(SQLExecutionHook.class);
       
       @Override
       public void start(final String dataSourceName, final String sql, final List<Object> params, final DataSourceMetaData dataSourceMetaData, final boolean isTrunkThread) {
           for (SQLExecutionHook each : sqlExecutionHooks) {
               each.start(dataSourceName, sql, params, dataSourceMetaData, isTrunkThread);
           }
       }
       
       @Override
       public void finishSuccess() {
           for (SQLExecutionHook each : sqlExecutionHooks) {
               each.finishSuccess();
           }
       }
       
       @Override
       public void finishFailure(final Exception cause) {
           for (SQLExecutionHook each : sqlExecutionHooks) {
               each.finishFailure(cause);
           }
       }
   }
   
   ```
   
   In the class SPISQLExecutionHook there's a sqlExecutionHooks field which loads all providers from the SPI upon instatntiation, but there isn't a declared provider in the manifest except one from the test folder. I'd like to ask what's the purpose of this field and the purpose of looping through them in the start(), finishSuccess() and finishFailure() methods, and wouldn't there be a StackOverFlowError if any were any providers declared in a manifest and the sqlExecutionHooks field wasn't an empty list?
   
   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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] theodoretsai commented on issue #26323: Question about SPISQLExecutionHook

Posted by "theodoretsai (via GitHub)" <gi...@apache.org>.
theodoretsai commented on issue #26323:
URL: https://github.com/apache/shardingsphere/issues/26323#issuecomment-1590664145

   @jiangML I guess that my ClassPath did not contain SeataTransactionalSQLExecutionHook since I only had shardingsphere-jdbc-core dependency, that solves the question, Thank you very much.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] jiangML commented on issue #26323: Question about SPISQLExecutionHook

Posted by "jiangML (via GitHub)" <gi...@apache.org>.
jiangML commented on issue #26323:
URL: https://github.com/apache/shardingsphere/issues/26323#issuecomment-1589260770

   @theodoretsai SeataTransactionalSQLExecutionHook also implements SQLExecutionHook, which will not cause StackOverFlowError


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] theodoretsai closed issue #26323: Question about SPISQLExecutionHook

Posted by "theodoretsai (via GitHub)" <gi...@apache.org>.
theodoretsai closed issue #26323: Question about SPISQLExecutionHook
URL: https://github.com/apache/shardingsphere/issues/26323


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org