mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
格式化并增加sandzhang提交后StatViewServlet缺失的方法。
This commit is contained in:
@@ -3,60 +3,73 @@ package com.alibaba.druid.stat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
import com.alibaba.druid.util.ReflectionUtils;
|
||||
|
||||
public class DruidDataSourceStatJNDIStatStrategy implements DruidDataSourceStatStrategy{
|
||||
private final static Log LOG = LogFactory.getLog(DruidDataSourceStatJNDIStatStrategy.class);
|
||||
public class DruidDataSourceStatJNDIStatStrategy implements DruidDataSourceStatStrategy {
|
||||
|
||||
private Object getStrategyB() {
|
||||
try {
|
||||
Class<?> clazz = ReflectionUtils.getClassFromWebContainerOrCurrentClassLoader("com.alibaba.druid.stat.DruidDataSourceStatDefaultStrategy");
|
||||
return clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private final static Log LOG = LogFactory.getLog(DruidDataSourceStatJNDIStatStrategy.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getSqlStatData(Integer id) {
|
||||
return (Map<String, Object>) ReflectionUtils.callObjectMethod(getStrategyB(), "getSqlStatData", id);
|
||||
}
|
||||
private Object getStatDefaultStrategy() {
|
||||
try {
|
||||
Class<?> clazz = ReflectionUtils.getClassFromWebContainerOrCurrentClassLoader("com.alibaba.druid.stat.DruidDataSourceStatDefaultStrategy");
|
||||
return clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Map<String, Object>> getSqlStatDataList() {
|
||||
return (List<Map<String, Object>>) ReflectionUtils.callObjectMethod(getStrategyB(), "getSqlStatDataList");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getSqlStatData(Integer id) {
|
||||
return (Map<String, Object>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "getSqlStatData", id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getActiveConnectionStackTraceByDataSourceId(Integer id) {
|
||||
return (List<String>) ReflectionUtils.callObjectMethod(getStrategyB(), "getActiveConnectionStackTraceByDataSourceId", id);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Map<String, Object>> getSqlStatDataList() {
|
||||
return (List<Map<String, Object>>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "getSqlStatDataList");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> returnJSONBasicStat() {
|
||||
return (Map<String, Object>) ReflectionUtils.callObjectMethod(getStrategyB(), "returnJSONBasicStat");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getActiveConnectionStackTraceByDataSourceId(Integer id) {
|
||||
return (List<String>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(),
|
||||
"getActiveConnectionStackTraceByDataSourceId", id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> getDataSourceStatList() {
|
||||
return (List<Object>) ReflectionUtils.callObjectMethod(getStrategyB(), "getDataSourceStatList");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> returnJSONBasicStat() {
|
||||
return (Map<String, Object>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "returnJSONBasicStat");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getDataSourceStatData(Integer id) {
|
||||
return (Map<String, Object>) ReflectionUtils.callObjectMethod(getStrategyB(), "getDataSourceStatData", id);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> getDataSourceStatList() {
|
||||
return (List<Object>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "getDataSourceStatList");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Map<String, Object>> getPoolingConnectionInfoByDataSourceId(Integer id) {
|
||||
return (List<Map<String, Object>>) ReflectionUtils.callObjectMethod(getStrategyB(), "getPoolingConnectionInfoByDataSourceId", id);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getDataSourceStatData(Integer id) {
|
||||
return (Map<String, Object>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "getDataSourceStatData", id);
|
||||
}
|
||||
|
||||
public void resetAll() {
|
||||
ReflectionUtils.callObjectMethod(getStrategyB(), "resetAll");
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Map<String, Object>> getPoolingConnectionInfoByDataSourceId(Integer id) {
|
||||
return (List<Map<String, Object>>) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(),
|
||||
"getPoolingConnectionInfoByDataSourceId",
|
||||
id);
|
||||
}
|
||||
|
||||
public void resetAll() {
|
||||
ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "resetAll");
|
||||
}
|
||||
|
||||
public DruidDataSource getDruidDataSourceById(Integer id) {
|
||||
return (DruidDataSource) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "getDruidDataSourceById");
|
||||
}
|
||||
|
||||
public JdbcSqlStat getSqlStatById(Integer id) {
|
||||
return (JdbcSqlStat) ReflectionUtils.callObjectMethod(getStatDefaultStrategy(), "getSqlStatById", id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user