Search in sources :

Example 1 with QueryInterceptor

use of com.mysql.cj.interceptors.QueryInterceptor in project ABC by RuiPinto96274.

the class NativeProtocol method invokeQueryInterceptorsPost.

/**
 * @param <M>
 *            extends {@link Message}
 * @param queryPacket
 *            {@link NativePacketPayload} containing query
 * @param originalResponsePacket
 *            {@link NativePacketPayload} containing response
 * @param forceExecute
 *            currently ignored
 * @return T instance
 */
public <M extends Message> M invokeQueryInterceptorsPost(M queryPacket, M originalResponsePacket, boolean forceExecute) {
    for (int i = 0, s = this.queryInterceptors.size(); i < s; i++) {
        QueryInterceptor interceptor = this.queryInterceptors.get(i);
        // TODO how to handle executeTopLevelOnly in such case ?
        // boolean executeTopLevelOnly = interceptor.executeTopLevelOnly();
        // boolean shouldExecute = (executeTopLevelOnly && (this.statementExecutionDepth == 1 || forceExecute)) || (!executeTopLevelOnly);
        // if (shouldExecute) {
        M interceptedPacketPayload = interceptor.postProcess(queryPacket, originalResponsePacket);
        if (interceptedPacketPayload != null) {
            originalResponsePacket = interceptedPacketPayload;
        }
    // }
    }
    return originalResponsePacket;
}
Also used : QueryInterceptor(com.mysql.cj.interceptors.QueryInterceptor)

Example 2 with QueryInterceptor

use of com.mysql.cj.interceptors.QueryInterceptor in project JavaSegundasQuintas by ecteruel.

the class LoadBalancedConnectionProxy method syncSessionState.

@Override
void syncSessionState(JdbcConnection source, JdbcConnection target, boolean readOnly) throws SQLException {
    LoadBalancedAutoCommitInterceptor lbAutoCommitStmtInterceptor = null;
    for (QueryInterceptor stmtInterceptor : target.getQueryInterceptorsInstances()) {
        if (stmtInterceptor instanceof LoadBalancedAutoCommitInterceptor) {
            lbAutoCommitStmtInterceptor = (LoadBalancedAutoCommitInterceptor) stmtInterceptor;
            lbAutoCommitStmtInterceptor.pauseCounters();
            break;
        }
    }
    super.syncSessionState(source, target, readOnly);
    if (lbAutoCommitStmtInterceptor != null) {
        lbAutoCommitStmtInterceptor.resumeCounters();
    }
}
Also used : QueryInterceptor(com.mysql.cj.interceptors.QueryInterceptor)

Example 3 with QueryInterceptor

use of com.mysql.cj.interceptors.QueryInterceptor in project JavaSegundasQuintas by ecteruel.

the class NativeProtocol method invokeQueryInterceptorsPre.

/**
 * @param <M>
 *            extends {@link Message}
 * @param queryPacket
 *            {@link NativePacketPayload} containing query
 * @param forceExecute
 *            currently ignored
 * @return M instance
 */
public <M extends Message> M invokeQueryInterceptorsPre(M queryPacket, boolean forceExecute) {
    M previousPacketPayload = null;
    for (int i = 0, s = this.queryInterceptors.size(); i < s; i++) {
        QueryInterceptor interceptor = this.queryInterceptors.get(i);
        // TODO how to handle executeTopLevelOnly in such case ?
        // boolean executeTopLevelOnly = interceptor.executeTopLevelOnly();
        // boolean shouldExecute = (executeTopLevelOnly && (this.statementExecutionDepth == 1 || forceExecute)) || (!executeTopLevelOnly);
        // if (shouldExecute) {
        M interceptedPacketPayload = interceptor.preProcess(queryPacket);
        if (interceptedPacketPayload != null) {
            previousPacketPayload = interceptedPacketPayload;
        }
    // }
    }
    return previousPacketPayload;
}
Also used : QueryInterceptor(com.mysql.cj.interceptors.QueryInterceptor)

Example 4 with QueryInterceptor

use of com.mysql.cj.interceptors.QueryInterceptor in project aws-mysql-jdbc by awslabs.

the class LoadBalancedConnectionProxy method syncSessionState.

@Override
void syncSessionState(JdbcConnection source, JdbcConnection target, boolean readOnly) throws SQLException {
    LoadBalancedAutoCommitInterceptor lbAutoCommitStmtInterceptor = null;
    for (QueryInterceptor stmtInterceptor : target.getQueryInterceptorsInstances()) {
        if (stmtInterceptor instanceof LoadBalancedAutoCommitInterceptor) {
            lbAutoCommitStmtInterceptor = (LoadBalancedAutoCommitInterceptor) stmtInterceptor;
            lbAutoCommitStmtInterceptor.pauseCounters();
            break;
        }
    }
    super.syncSessionState(source, target, readOnly);
    if (lbAutoCommitStmtInterceptor != null) {
        lbAutoCommitStmtInterceptor.resumeCounters();
    }
}
Also used : QueryInterceptor(com.mysql.cj.interceptors.QueryInterceptor)

Example 5 with QueryInterceptor

use of com.mysql.cj.interceptors.QueryInterceptor in project aws-mysql-jdbc by awslabs.

the class NativeProtocol method invokeQueryInterceptorsPre.

/**
 * @param <M>
 *            extends {@link Message}
 * @param queryPacket
 *            {@link NativePacketPayload} containing query
 * @param forceExecute
 *            currently ignored
 * @return M instance
 */
public <M extends Message> M invokeQueryInterceptorsPre(M queryPacket, boolean forceExecute) {
    M previousPacketPayload = null;
    for (int i = 0, s = this.queryInterceptors.size(); i < s; i++) {
        QueryInterceptor interceptor = this.queryInterceptors.get(i);
        // TODO how to handle executeTopLevelOnly in such case ?
        // boolean executeTopLevelOnly = interceptor.executeTopLevelOnly();
        // boolean shouldExecute = (executeTopLevelOnly && (this.statementExecutionDepth == 1 || forceExecute)) || (!executeTopLevelOnly);
        // if (shouldExecute) {
        M interceptedPacketPayload = interceptor.preProcess(queryPacket);
        if (interceptedPacketPayload != null) {
            previousPacketPayload = interceptedPacketPayload;
        }
    // }
    }
    return previousPacketPayload;
}
Also used : QueryInterceptor(com.mysql.cj.interceptors.QueryInterceptor)

Aggregations

QueryInterceptor (com.mysql.cj.interceptors.QueryInterceptor)18 ConnectionImpl (com.mysql.cj.jdbc.ConnectionImpl)3