|
| 1 | +package org.apache.ibatis.plugin; |
| 2 | + |
| 3 | +import java.util.Arrays; |
| 4 | +import java.util.LinkedHashMap; |
| 5 | +import java.util.Map; |
| 6 | + |
| 7 | +import org.apache.ibatis.executor.Executor; |
| 8 | +import org.apache.ibatis.executor.parameter.ParameterHandler; |
| 9 | +import org.apache.ibatis.executor.resultset.ResultSetHandler; |
| 10 | +import org.apache.ibatis.executor.statement.StatementHandler; |
| 11 | + |
| 12 | +/** |
| 13 | + * @author furious 2024/4/18 |
| 14 | + */ |
| 15 | +public class PointcutRegistry { |
| 16 | + |
| 17 | + public static final String Executor_update_MappedStatement_Object = "Executor_update_MappedStatement_Object"; |
| 18 | + public static final String Executor_query_MappedStatement_Object = "Executor_query_MappedStatement_Object"; |
| 19 | + public static final String ParameterHandler_getParameterObject_ = "ParameterHandler_getParameterObject_"; |
| 20 | + public static final String ParameterHandler_setParameters_PreparedStatement = "ParameterHandler_setParameters_PreparedStatement"; |
| 21 | + public static final String ResultSetHandler_handleResultSets_Statement = "ResultSetHandler_handleResultSets_Statement"; |
| 22 | + public static final String StatementHandler_parameterize_Statement = "StatementHandler_parameterize_Statement"; |
| 23 | + public static final String StatementHandler_update_Statement = "StatementHandler_update_Statement"; |
| 24 | + public static final String StatementHandler_prepare_Connection_Integer = "StatementHandler_prepare_Connection_Integer"; |
| 25 | + public static final String StatementHandler_query_Statement = "StatementHandler_query_Statement"; |
| 26 | + public static final String StatementHandler_getBoundSql_ = "StatementHandler_getBoundSql_"; |
| 27 | + |
| 28 | + private final Map<String, PointcutDefinition> definitions = new LinkedHashMap<>(); |
| 29 | + |
| 30 | + public PointcutRegistry() { |
| 31 | + Arrays.stream(Executor.class.getMethods()).forEach(m -> new PointcutDefinition(m, this)); |
| 32 | + Arrays.stream(ParameterHandler.class.getMethods()).forEach(m -> new PointcutDefinition(m, this)); |
| 33 | + Arrays.stream(ResultSetHandler.class.getMethods()).forEach(m -> new PointcutDefinition(m, this)); |
| 34 | + Arrays.stream(StatementHandler.class.getMethods()).forEach(m -> new PointcutDefinition(m, this)); |
| 35 | + } |
| 36 | + |
| 37 | + public Map<String, PointcutDefinition> getDefinitions() { |
| 38 | + return definitions; |
| 39 | + } |
| 40 | + |
| 41 | + public PointcutDefinition getDefinition(String key) { |
| 42 | + return definitions.get(key); |
| 43 | + } |
| 44 | +} |
0 commit comments