- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据HikariCP的源代码,我发现作者通过javaassist生成了HikariProxyConnection,但是该类除了调用父类(super class)方法之外什么也没做。
例如,HikariProxyConnection 的父类(super class)是 ProxyConnection:
public class HikariProxyConnection extends ProxyConnection implements AutoCloseable, Connection, Wrapper {
public Statement createStatement() throws SQLException {
try {
return super.createStatement();
} catch (SQLException var2) {
throw this.checkException(var2);
}
}
public PreparedStatement prepareStatement(String var1) throws SQLException {
try {
return super.prepareStatement(var1);
} catch (SQLException var3) {
throw this.checkException(var3);
}
} }
我发现ProxyConnection已经做了很多事情,HikariProxyConnection只是在每个方法中添加了一个try catch block 。
如果有人能给出解释就好了。
最佳答案
有一个Hikari issue关于 @brettwooldridge 回答的 HikariProxyConnection
的目的:
The proxies delegate to the real driver classes. Some proxies, like the one for ResultSet, only intercept a few methods. Without the code generation, the proxy would have to implement all 50+ methods which simply delegate to the wrapped instance.
Code generation, based on reflection, also means that nothing needs to be done when a new JDK version introduces new JDBC methods to existing interfaces.
关于java - 既然作者已经写了ProxyConnection,为什么要通过javaassist生成HikariProxyConnection呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52181840/
我是一名优秀的程序员,十分优秀!