use of com.mendmix.mybatis.plugin.cache.CacheHandler in project jeesuite-libs by vakinge.
the class JeesuiteMybatisInterceptor method setInterceptorHandlers.
private void setInterceptorHandlers(String[] hanlderNames) {
for (String name : hanlderNames) {
if (org.apache.commons.lang3.StringUtils.isBlank(name))
continue;
if (CacheHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new CacheHandler());
cacheEnabled = true;
} else if (RwRouteHandler.NAME.equals(name)) {
this.interceptorHandlers.add(new RwRouteHandler());
rwRouteEnabled = true;
} else {
// 自定义的拦截器
try {
Class<?> clazz = Class.forName(name);
InterceptorHandler handler = (InterceptorHandler) clazz.newInstance();
this.interceptorHandlers.add(handler);
logger.info("registered cumstom InterceptorHandler:{}", name);
} catch (Exception e) {
logger.error("registered cumstom InterceptorHandler error", e);
}
}
}
// 排序 分页和数据权限会重写sql,所以不走缓存,所以放在缓存之前
Collections.sort(this.interceptorHandlers, new Comparator<InterceptorHandler>() {
@Override
public int compare(InterceptorHandler o1, InterceptorHandler o2) {
return Integer.compare(o1.interceptorOrder(), o2.interceptorOrder());
}
});
}
Aggregations