Druid的Filter机制
之前的这篇文章介绍了Druid的连接池管理实现,但除了基本的连接管理,Druid还支持监控,代理等功能,便于开发人员分析数据库操作的一些性能指标等。其主要使用Filter机制来实现,本文将介绍下其中的Filter实现。
Filter接口定义从Filter接口中,可以看出,Filter主要重新定义了来自Connection,Statement,ResultSet等对象的接口,并且均通过对应的Proxy对象来替代,每个接口中还带有一个FilterChain参数,主要是为了支持Filter链,如:
public interface Filter extends Wrapper {/*** 初始化Filter*/void init(DataSourceProxy dataSource);/*** 销毁Filter*/void destroy();// Connection相关方法/*** 创建一个连接*/ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException;/**...阅读全文
Filter接口定义从Filter接口中,可以看出,Filter主要重新定义了来自Connection,Statement,ResultSet等对象的接口,并且均通过对应的Proxy对象来替代,每个接口中还带有一个FilterChain参数,主要是为了支持Filter链,如:
public interface Filter extends Wrapper {/*** 初始化Filter*/void init(DataSourceProxy dataSource);/*** 销毁Filter*/void destroy();// Connection相关方法/*** 创建一个连接*/ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException;/**...阅读全文