Skip to content

Commit

Permalink
fix a few spelling errors and a function name typo in SQLEvalVisitorU…
Browse files Browse the repository at this point in the history
…tils#registerBaseFunctions
  • Loading branch information
lizhanhui committed Jul 5, 2014
1 parent 59ee520 commit 2f3fd8d
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 123 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
out/
*.ipr
*.iws
*.iml
/bin
/target
*.iml
/bin
24 changes: 12 additions & 12 deletions src/main/java/com/alibaba/druid/filter/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
*/
package com.alibaba.druid.filter;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
import com.alibaba.druid.proxy.jdbc.ClobProxy;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetMetaDataProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
import com.alibaba.druid.proxy.jdbc.StatementProxy;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
Expand Down Expand Up @@ -44,25 +55,14 @@
import java.util.Calendar;
import java.util.Properties;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
import com.alibaba.druid.proxy.jdbc.ClobProxy;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetMetaDataProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
import com.alibaba.druid.proxy.jdbc.StatementProxy;

/**
* @author wenshao<szujobs@hotmail.com>
*/
public interface Filter extends Wrapper {

void init(DataSourceProxy dataSource);

void destory();
void destroy();

void configFromProperties(Properties properties);

Expand Down
27 changes: 13 additions & 14 deletions src/main/java/com/alibaba/druid/filter/FilterAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
*/
package com.alibaba.druid.filter;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
import com.alibaba.druid.proxy.jdbc.ClobProxy;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetMetaDataProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
import com.alibaba.druid.proxy.jdbc.StatementProxy;

import javax.management.NotificationBroadcasterSupport;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
Expand All @@ -40,19 +52,6 @@
import java.util.Map;
import java.util.Properties;

import javax.management.NotificationBroadcasterSupport;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
import com.alibaba.druid.proxy.jdbc.ClobProxy;
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetMetaDataProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
import com.alibaba.druid.proxy.jdbc.StatementProxy;

/**
* 提供JdbcFilter的基本实现,使得实现一个JdbcFilter更容易。
*
Expand All @@ -65,7 +64,7 @@ public void init(DataSourceProxy dataSource) {
}

@Override
public void destory() {
public void destroy() {

}

Expand Down
115 changes: 57 additions & 58 deletions src/main/java/com/alibaba/druid/pool/DruidDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,6 @@
*/
package com.alibaba.druid.pool;

import static com.alibaba.druid.util.Utils.getBoolean;

import java.io.Closeable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import javax.management.JMException;
import javax.management.ObjectName;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;

import com.alibaba.druid.Constants;
import com.alibaba.druid.TransactionTimeoutException;
import com.alibaba.druid.VERSION;
Expand Down Expand Up @@ -90,6 +55,40 @@
import com.alibaba.druid.wall.WallFilter;
import com.alibaba.druid.wall.WallProviderStatValue;

import javax.management.JMException;
import javax.management.ObjectName;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;
import java.io.Closeable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import static com.alibaba.druid.util.Utils.getBoolean;

/**
* @author ljw<ljw2083@alibaba-inc.com>
* @author wenshao<szujobs@hotmail.com>
Expand Down Expand Up @@ -126,7 +125,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat

// threads
private CreateConnectionThread createConnectionThread;
private DestroyConnectionThread destoryConnectionThread;
private DestroyConnectionThread destroyConnectionThread;
private LogStatsThread logStatsThread;

private final CountDownLatch initedLatch = new CountDownLatch(2);
Expand All @@ -143,13 +142,13 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat

protected JdbcDataSourceStat dataSourceStat;

private boolean useGloalDataSourceStat = false;
private boolean useGlobalDataSourceStat = false;

private boolean mbeanRegistered = false;

public static ThreadLocal<Long> waitNanosLocal = new ThreadLocal<Long>();

private boolean logDiffrentThread = true;
private boolean logDifferentThread = true;

public DruidDataSource(){
this(false);
Expand Down Expand Up @@ -181,9 +180,9 @@ public void configFromPropety(Properties properties) {
}
}
{
Boolean value = getBoolean(properties, "druid.useGloalDataSourceStat");
Boolean value = getBoolean(properties, "druid.useGlobalDataSourceStat");
if (value != null) {
this.setUseGloalDataSourceStat(value);
this.setUseGlobalDataSourceStat(value);
}
}
{
Expand Down Expand Up @@ -235,12 +234,12 @@ public void configFromPropety(Properties properties) {
}
}

public boolean isUseGloalDataSourceStat() {
return useGloalDataSourceStat;
public boolean isUseGlobalDataSourceStat() {
return useGlobalDataSourceStat;
}

public void setUseGloalDataSourceStat(boolean useGloalDataSourceStat) {
this.useGloalDataSourceStat = useGloalDataSourceStat;
public void setUseGlobalDataSourceStat(boolean useGlobalDataSourceStat) {
this.useGlobalDataSourceStat = useGlobalDataSourceStat;
}

public String getInitStackTrace() {
Expand Down Expand Up @@ -544,8 +543,8 @@ public void init() throws SQLException {
+ maxActive);
}

if (timeBetweenLogStatsMillis > 0 && useGloalDataSourceStat) {
throw new IllegalArgumentException("timeBetweenLogStatsMillis not support useGloalDataSourceStat=true");
if (timeBetweenLogStatsMillis > 0 && useGlobalDataSourceStat) {
throw new IllegalArgumentException("timeBetweenLogStatsMillis not support useGlobalDataSourceStat=true");
}

if (this.driverClass != null) {
Expand Down Expand Up @@ -576,7 +575,7 @@ public void init() throws SQLException {
initValidConnectionChecker();
validationQueryCheck();

if (isUseGloalDataSourceStat()) {
if (isUseGlobalDataSourceStat()) {
dataSourceStat = JdbcDataSourceStat.getGlobal();
if (dataSourceStat == null) {
dataSourceStat = new JdbcDataSourceStat("Global", "Global", this.dbType);
Expand Down Expand Up @@ -651,9 +650,9 @@ private void createAndLogThread() {
}

private void createAndStartDestroyThread() {
String threadName = "Druid-ConnectionPool-Destory-" + System.identityHashCode(this);
destoryConnectionThread = new DestroyConnectionThread(threadName);
destoryConnectionThread.start();
String threadName = "Druid-ConnectionPool-Destroy-" + System.identityHashCode(this);
destroyConnectionThread = new DestroyConnectionThread(threadName);
destroyConnectionThread.start();
}

protected void createAndStartCreatorThread() {
Expand Down Expand Up @@ -1126,7 +1125,7 @@ protected void recycle(DruidPooledConnection pooledConnection) throws SQLExcepti
return;
}

if (logDiffrentThread && pooledConnection.getOwnerThread() != Thread.currentThread()) {
if (logDifferentThread && pooledConnection.getOwnerThread() != Thread.currentThread()) {
LOG.warn("get/close not same thread");
}

Expand Down Expand Up @@ -1244,8 +1243,8 @@ public void close() {
createConnectionThread.interrupt();
}

if (destoryConnectionThread != null) {
destoryConnectionThread.interrupt();
if (destroyConnectionThread != null) {
destroyConnectionThread.interrupt();
}

for (int i = 0; i < poolingCount; ++i) {
Expand Down Expand Up @@ -1276,7 +1275,7 @@ public void close() {
this.closeTimeMillis = System.currentTimeMillis();

for (Filter filter : filters) {
filter.destory();
filter.destroy();
}
} finally {
lock.unlock();
Expand Down Expand Up @@ -2395,12 +2394,12 @@ public <T> T unwrap(Class<T> iface) {
return super.unwrap(iface);
}

public boolean isLogDiffrentThread() {
return logDiffrentThread;
public boolean isLogDifferentThread() {
return logDifferentThread;
}

public void setLogDiffrentThread(boolean logDiffrentThread) {
this.logDiffrentThread = logDiffrentThread;
public void setLogDifferentThread(boolean logDifferentThread) {
this.logDifferentThread = logDifferentThread;
}

public DruidPooledConnection tryGetConnection() throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@
*/
package com.alibaba.druid.sql.visitor;

import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_ERROR;
import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_EXPR;
import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_VALUE;
import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_VALUE_NULL;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import com.alibaba.druid.DruidRuntimeException;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLExpr;
Expand Down Expand Up @@ -95,6 +78,23 @@
import com.alibaba.druid.wall.spi.WallVisitorUtils;
import com.alibaba.druid.wall.spi.WallVisitorUtils.WallConditionContext;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_ERROR;
import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_EXPR;
import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_VALUE;
import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_VALUE_NULL;

public class SQLEvalVisitorUtils {

private static Map<String, Function> functions = new HashMap<String, Function>();
Expand Down Expand Up @@ -209,7 +209,7 @@ static void registerBaseFunctions() {
functions.put("trim", Trim.instance);
functions.put("ucase", Ucase.instance);
functions.put("upper", Ucase.instance);
functions.put("ucase", Lcase.instance);
functions.put("lcase", Lcase.instance);
functions.put("lower", Lcase.instance);
functions.put("hex", Hex.instance);
functions.put("unhex", Unhex.instance);
Expand Down
Loading

0 comments on commit 2f3fd8d

Please sign in to comment.