format code

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@527 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-08-01 19:45:46 +00:00
parent a803236cfa
commit c270d3f308
161 changed files with 3709 additions and 2349 deletions
@@ -45,8 +45,9 @@ import com.alibaba.druid.util.JdbcUtils;
* @author wenshao<szujobs@hotmail.com>
*/
public class DruidDriver implements Driver, DruidDriverMBean {
private final static Log LOG = LogFactory.getLog(DruidDriver.class);
private final static Log LOG = LogFactory.getLog(DruidDriver.class);
private final static DruidDriver instance = new DruidDriver();
private final static ConcurrentMap<String, DataSourceProxyImpl> proxyDataSources = new ConcurrentHashMap<String, DataSourceProxyImpl>();
@@ -51,7 +51,8 @@ public class DruidFilterConfigLoader {
private static final String CONFIG_CLAZZ_TAG = "configClass";
public static void loadConfig(String config, List<AbstractDruidFilterConfig> druidFilterConfigList) throws SQLException {
public static void loadConfig(String config, List<AbstractDruidFilterConfig> druidFilterConfigList)
throws SQLException {
URL url = findResource(config);
if (url != null) {
try {
@@ -76,7 +77,8 @@ public class DruidFilterConfigLoader {
NodeList filterNodeList = filtersNode.getChildNodes();
for (int i = 0; i < filterNodeList.getLength(); i++) {
Node filterNode = filterNodeList.item(i);
if (filterNode != null && filterNode.getNodeType() == Node.ELEMENT_NODE && filterNode.getAttributes().getNamedItem(NAME_TAG) != null) {
if (filterNode != null && filterNode.getNodeType() == Node.ELEMENT_NODE
&& filterNode.getAttributes().getNamedItem(NAME_TAG) != null) {
Node configClassNode = filterNode.getAttributes().getNamedItem(CONFIG_CLAZZ_TAG);
if (configClassNode != null && !"".equalsIgnoreCase(configClassNode.getNodeValue())) {
Class<?> configClass = DruidLoaderUtils.loadClass(configClassNode.getNodeValue());
@@ -118,7 +118,7 @@ public class ClobProxyImpl implements ClobProxy {
public void truncate(long len) throws SQLException {
createChain().clob_truncate(this, len);
}
public String toString() {
return clob.toString();
}
@@ -129,7 +129,8 @@ public class ConnectionProxyImpl extends WrapperProxyImpl implements ConnectionP
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
return createChain().connection_createStatement(this, resultSetType, resultSetType, resultSetHoldability);
}
@@ -214,8 +215,10 @@ public class ConnectionProxyImpl extends WrapperProxyImpl implements ConnectionP
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
return createChain().connection_prepareCall(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
return createChain().connection_prepareCall(this, sql, resultSetType, resultSetConcurrency,
resultSetHoldability);
}
@Override
@@ -239,13 +242,16 @@ public class ConnectionProxyImpl extends WrapperProxyImpl implements ConnectionP
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
return createChain().connection_prepareStatement(this, sql, resultSetType, resultSetConcurrency);
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
return createChain().connection_prepareStatement(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
return createChain().connection_prepareStatement(this, sql, resultSetType, resultSetConcurrency,
resultSetHoldability);
}
@Override
@@ -48,7 +48,7 @@ public class DataSourceProxyConfig {
public void setJmxOption(boolean jmx) {
this.jmx = jmx;
}
public void setJmxOption(String jmx) {
this.jmx = Boolean.parseBoolean(jmx);
}
@@ -255,7 +255,7 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
map.put("ResultSetOpenningMax", stat.getResultSetStat().getOpenningMax());
map.put("ResultSetFetchRowCount", stat.getResultSetStat().getFetchRowCount());
map.put("ResultSetLastOpenTime", stat.getResultSetStat().getLastOpenTime());
map.put("ResultSetErrorCount", stat.getResultSetStat().getErrorCount());
map.put("ResultSetOpenningMillisTotal", stat.getResultSetStat().getAliveMillisTotal());
map.put("ResultSetLastErrorTime", stat.getResultSetStat().getLastErrorTime());
@@ -267,7 +267,7 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
map.put("ResultSetLastErrorMessage", null);
map.put("ResultSetLastErrorStackTrace", null);
}
map.put("ConnectionConnectCount", stat.getConnectionStat().getConnectCount());
Throwable lastConnectionError = stat.getConnectionStat().getErrorLast();
if (lastConnectionError != null) {
@@ -279,48 +279,48 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
}
map.put("ConnectionConnectMillisTotal", stat.getConnectionStat().getConnectMillis());
map.put("ConnectionConnectingCountMax", stat.getConnectionStat().getConnectingMax());
map.put("ConnectionConnectMillisMax", stat.getConnectionStat().getConnectMillisMax());
map.put("ConnectionErrorLastTime", stat.getConnectionStat().getErrorLastTime());
map.put("ConnectionAliveMillisMax", stat.getConnectionConnectAliveMillisMax());
map.put("ConnectionAliveMillisMin", stat.getConnectionConnectAliveMillisMin());
map.put("ConnectionCount_Alive_0_1_Seconds", stat.getConnectionCount_Alive_0_1_Seconds());
map.put("ConnectionCount_Alive_1_5_Seconds", stat.getConnectionCount_Alive_1_5_Seconds());
map.put("ConnectionCount_Alive_5_10_Seconds", stat.getConnectionCount_Alive_5_10_Seconds());
map.put("ConnectionCount_Alive_10_30_Seconds", stat.getConnectionCount_Alive_10_30_Seconds());
map.put("ConnectionCount_Alive_30_60_Seconds", stat.getConnectionCount_Alive_30_60_Seconds());
map.put("ConnectionCount_Alive_1_5_Minutes", stat.getConnectionCount_Alive_1_5_Minutes());
map.put("ConnectionCount_Alive_5_10_Minutes", stat.getConnectionCount_Alive_5_10_Minutes());
map.put("ConnectionCount_Alive_10_30_Minutes", stat.getConnectionCount_Alive_10_30_Minutes());
map.put("ConnectionCount_Alive_30_60_Minutes", stat.getConnectionCount_Alive_30_60_Minutes());
map.put("ConnectionCount_Alive_1_6_Hours", stat.getConnectionCount_Alive_1_6_Hours());
map.put("ConnectionCount_Alive_6_24_Hours", stat.getConnectionCount_Alive_6_24_Hours());
map.put("ConnectionCount_Alive_1_7_Day", stat.getConnectionCount_Alive_1_7_day());
map.put("ConnectionCount_Alive_7_30_Day", stat.getConnectionCount_Alive_7_30_Day());
map.put("ConnectionCount_Alive_30_90_Day", stat.getConnectionCount_Alive_30_90_Day());
map.put("ConnectionCount_Alive_90_more_Day", stat.getConnectionCount_Alive_90_more_Day());
map.put("StatementExecuteCount_0_1_Millis", stat.getStatementStat().getCount_0_1_Millis());
map.put("StatementExecuteCount_1_2_Millis", stat.getStatementStat().getCount_1_2_Millis());
map.put("StatementExecuteCount_2_5_Millis", stat.getStatementStat().getCount_2_5_Millis());
map.put("StatementExecuteCount_5_10_Millis", stat.getStatementStat().getCount_5_10_Millis());
map.put("StatementExecuteCount_10_20_Millis", stat.getStatementStat().getCount_10_20_Millis());
map.put("StatementExecuteCount_20_50_Millis", stat.getStatementStat().getCount_20_50_Millis());
map.put("StatementExecuteCount_50_100_Millis", stat.getStatementStat().getCount_50_100_Millis());
map.put("StatementExecuteCount_100_200_Millis", stat.getStatementStat().getCount_100_200_Millis());
map.put("StatementExecuteCount_200_500_Millis", stat.getStatementStat().getCount_200_500_Millis());
map.put("StatementExecuteCount_500_1000_Millis", stat.getStatementStat().getCount_500_1000_Millis());
map.put("StatementExecuteCount_1_2_Seconds", stat.getStatementStat().getCount_1_2_Seconds());
map.put("StatementExecuteCount_2_5_Seconds", stat.getStatementStat().getCount_2_5_Seconds());
map.put("StatementExecuteCount_5_10_Seconds", stat.getStatementStat().getCount_5_10_Seconds());
map.put("StatementExecuteCount_10_30_Seconds", stat.getStatementStat().getCount_10_30_Seconds());
map.put("StatementExecuteCount_30_60_Seconds", stat.getStatementStat().getCount_30_60_Seconds());
map.put("StatementExecuteCount_1_2_Minutes", stat.getStatementStat().getCount_1_2_minutes());
map.put("StatementExecuteCount_2_5_Minutes", stat.getStatementStat().getCount_2_5_minutes());
map.put("StatementExecuteCount_5_10_Minutes", stat.getStatementStat().getCount_5_10_minutes());
@@ -362,61 +362,60 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
map.put("ResultSetOpenningMax", null);
map.put("ResultSetFetchRowCount", null);
map.put("ResultSetLastOpenTime", null);
map.put("ResultSetLastErrorCount", null);
map.put("ResultSetOpenningMillisTotal", null);
map.put("ResultSetLastErrorTime", null);
map.put("ResultSetLastErrorMessage", null);
map.put("ResultSetLastErrorStackTrace", null);
map.put("ConnectionConnectCount", null);
map.put("ConnectionErrorLastMessage", null);
map.put("ConnectionErrorLastStackTrace", null);
map.put("ConnectionConnectMillisTotal", null);
map.put("ConnectionConnectingCountMax", null);
map.put("ConnectionConnectMillisMax", null);
map.put("ConnectionErrorLastTime", null);
map.put("ConnectionAliveMillisMax", null);
map.put("ConnectionAliveMillisMin", null);
map.put("ConnectionCount_Alive_0_1_Seconds", null);
map.put("ConnectionCount_Alive_1_5_Seconds", null);
map.put("ConnectionCount_Alive_5_10_Seconds", null);
map.put("ConnectionCount_Alive_10_30_Seconds", null);
map.put("ConnectionCount_Alive_30_60_Seconds", null);
map.put("ConnectionCount_Alive_1_5_Minutes", null);
map.put("ConnectionCount_Alive_5_10_Minutes", null);
map.put("ConnectionCount_Alive_10_30_Minutes", null);
map.put("ConnectionCount_Alive_30_60_Minutes", null);
map.put("ConnectionCount_Alive_1_6_Hours", null);
map.put("ConnectionCount_Alive_6_24_Hours", null);
map.put("ConnectionCount_Alive_1_7_Day", null);
map.put("ConnectionCount_Alive_7_30_Day", null);
map.put("ConnectionCount_Alive_30_90_Day", null);
map.put("ConnectionCount_Alive_90_more_Day", null);
map.put("StatementExecuteCount_0_1_Millis", null);
map.put("StatementExecuteCount_1_2_Millis", null);
map.put("StatementExecuteCount_2_5_Millis", null);
map.put("StatementExecuteCount_5_10_Millis", null);
map.put("StatementExecuteCount_10_20_Millis", null);
map.put("StatementExecuteCount_20_50_Millis", null);
map.put("StatementExecuteCount_50_100_Millis", null);
map.put("StatementExecuteCount_100_200_Millis", null);
map.put("StatementExecuteCount_200_500_Millis", null);
map.put("StatementExecuteCount_500_1000_Millis", null);
map.put("StatementExecuteCount_1_2_Seconds", null);
map.put("StatementExecuteCount_2_5_Seconds", null);
map.put("StatementExecuteCount_5_10_Seconds", null);
map.put("StatementExecuteCount_10_30_Seconds", null);
map.put("StatementExecuteCount_30_60_Seconds", null);
map.put("StatementExecuteCount_1_2_Minutes", null);
map.put("StatementExecuteCount_2_5_Minutes", null);
map.put("StatementExecuteCount_5_10_Minutes", null);