]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
9fe1d18c72bf79c95854065d389bf78bf90a3779
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2  *  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; version 2 of the License.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16  */
17
18 package com.mysql.clusterj.jdbc;
19
20 import com.mysql.jdbc.Connection;
21 import com.mysql.jdbc.ResultSetInternalMethods;
22 import com.mysql.jdbc.Statement;
23
24 import java.sql.SQLException;
25 import java.util.Properties;
26
27 /** This interceptor is called for execution of each statement of the associated connection.
28  * It is registered with the connection via the connection URL parameter
29  * statementInterceptors=com.mysql.clusterj.jdbc.StatementInterceptor.
30  * It must be used in conjunction with the ConnectionLifecycleInterceptor.
31  */
32 public class StatementInterceptor
33         implements com.mysql.jdbc.StatementInterceptorV2 {
34
35     /** The delegate for all methods. */
36     private InterceptorImpl interceptorImpl;
37
38     public void init(Connection connection, Properties properties) throws SQLException {
39         // find the interceptor if it's already registered; otherwise create it
40         this.interceptorImpl = InterceptorImpl.getInterceptorImpl(this, connection, properties);
41     }
42
43     public void destroy() {
44         interceptorImpl.destroy(this);
45         interceptorImpl = null;
46     }
47
48     public boolean executeTopLevelOnly() {
49         return interceptorImpl.executeTopLevelOnly();
50     }
51
52     public ResultSetInternalMethods postProcess(String sql, Statement statement,
53             ResultSetInternalMethods result, Connection connection, int arg4,
54             boolean arg5, boolean arg6, SQLException sqlException) throws SQLException {
55         return interceptorImpl.postProcess(sql, statement,
56                 result, connection, arg4,
57                 arg5, arg6, sqlException);
58     }
59
60     public ResultSetInternalMethods preProcess(String sql, Statement statement,
61             Connection connection) throws SQLException {
62         return interceptorImpl.preProcess(sql, statement, connection);
63     }
64
65 }