@@ -0,0 +1,2950 @@
+/*%0A * Copyright 2016-2018 shardingsphere.io.%0A * %3Cp%3E%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %3C/p%3E%0A */%0A%0Apackage io.shardingsphere.transaction.manager.base.executor;%0A%0Aimport com.google.common.eventbus.EventBus;%0Aimport io.shardingsphere.core.constant.SQLType;%0Aimport io.shardingsphere.core.constant.transaction.TransactionType;%0Aimport io.shardingsphere.core.event.ShardingEventBusInstance;%0Aimport io.shardingsphere.core.executor.sql.SQLExecuteCallback;%0Aimport io.shardingsphere.core.executor.sql.StatementExecuteUnit;%0Aimport io.shardingsphere.transaction.event.base.SagaSQLExecutionEvent;%0Aimport io.shardingsphere.transaction.manager.ShardingTransactionManagerRegistry;%0Aimport io.shardingsphere.transaction.manager.base.BASETransactionManager;%0A%0Aimport java.sql.SQLException;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * Saga transaction sql exeucte callback.%0A *%0A * @author yangyi%0A */%0Apublic abstract class SagaSQLExeucteCallback%3CT%3E extends SQLExecuteCallback%3CT%3E %7B%0A    %0A    private final String transactionId;%0A    %0A    private final EventBus shardingEventBus = ShardingEventBusInstance.getInstance();%0A    %0A    public SagaSQLExeucteCallback(final SQLType sqlType, final boolean isExceptionThrown, final Map%3CString, Object%3E dataMap) %7B%0A        super(sqlType, isExceptionThrown, dataMap);%0A        this.transactionId = ((BASETransactionManager) ShardingTransactionManagerRegistry.getInstance().getShardingTransactionManager(TransactionType.BASE)).getTransactionId();%0A        shardingEventBus.post(new SagaSQLExecutionEvent(null, null, null, transactionId));%0A    %7D%0A    %0A    /**%0A     * Saga transaction don't execute sql immediately, but send event to listener.%0A     *%0A     * @param executeUnit exeucte unit%0A     * @return return true if T is Boolean, 0 if T is Integer%0A     * @throws SQLException sql exception%0A     */%0A    @Override%0A    protected T executeSQL(final StatementExecuteUnit executeUnit) throws SQLException %7B%0A        List%3CList%3CObject%3E%3E params = executeUnit.getSqlExecutionUnit().getSqlUnit().getParameterSets();%0A        for (List%3CObject%3E each : params) %7B%0A            SagaSQLExecutionEvent event = new SagaSQLExecutionEvent(executeUnit.getSqlExecutionUnit().getDataSource(), executeUnit.getSqlExecutionUnit().getSqlUnit(), each, transactionId);%0A            event.setExecuteSuccess();%0A            shardingEventBus.post(event);%0A        %7D%0A        return exeucteResult();%0A    %7D%0A    %0A    protected abstract T exeucteResult();%0A%7D%0A

add SagaSQLExecuteCallback