Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb91d06b

Browse files
committed
sync source code from stone project
1 parent7e1ae59 commitb91d06b

File tree

49 files changed

+653
-676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+653
-676
lines changed

‎src/main/java/org/stone/beecp/BeeDataSource.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
importorg.stone.beecp.pool.exception.PoolCreateFailedException;
1616
importorg.stone.beecp.pool.exception.PoolNotCreatedException;
1717
importorg.stone.tools.BeanUtil;
18-
importorg.stone.tools.extension.InterruptionReentrantReadWriteLock;
18+
importorg.stone.tools.extension.InterruptableReentrantReadWriteLock;
1919

2020
importjavax.sql.CommonDataSource;
2121
importjavax.sql.DataSource;
@@ -46,8 +46,8 @@
4646
//fix BeeCP-Starter-#6 Chris-2020-09-01 start
4747
//public final class BeeDataSource extends BeeDataSourceConfig implements DataSource {
4848
publicclassBeeDataSourceextendsBeeDataSourceConfigimplementsDataSource,XADataSource,Closeable {
49-
privatefinalInterruptionReentrantReadWriteLocklock =newInterruptionReentrantReadWriteLock();
50-
privatefinalInterruptionReentrantReadWriteLock.ReadLockreadLock =lock.readLock();
49+
privatefinalInterruptableReentrantReadWriteLocklock =newInterruptableReentrantReadWriteLock();
50+
privatefinalInterruptableReentrantReadWriteLock.ReadLockreadLock =lock.readLock();
5151
privatelongmaxWaitNanos =8000L;//default vale same to config
5252
privateBeeConnectionPoolpool;
5353
privateCommonDataSourcesubDs;//used to set loginTimeout

‎src/main/java/org/stone/beecp/BeeDataSourceConfig.java‎

Lines changed: 61 additions & 62 deletions
Large diffs are not rendered by default.

‎src/main/java/org/stone/beecp/BeeDataSourceConfigException.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ public BeeDataSourceConfigException(String s) {
2121
super(s);
2222
}
2323

24+
publicBeeDataSourceConfigException(Throwablecause) {
25+
super(cause);
26+
}
27+
2428
publicBeeDataSourceConfigException(Stringmessage,Throwablecause) {
2529
super(message,cause);
2630
}
27-
2831
}

‎src/main/java/org/stone/beecp/BeeMethodExecutionListenerFactory.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ public interface BeeMethodExecutionListenerFactory {
1919
/**
2020
* Creates method execution listener.
2121
*
22+
* @param config is Bee data source configuration
2223
* @return created listener instance
2324
* @throws Exception when failed to create listener
2425
*/
25-
BeeMethodExecutionListenercreate()throwsException;
26+
BeeMethodExecutionListenercreate(BeeDataSourceConfigconfig)throwsException;
2627

2728
}

‎src/main/java/org/stone/beecp/BeeTransactionIsolationNames.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public final class BeeTransactionIsolationNames {
4141
privatestaticfinalMap<String,Integer>IsolationNameToCodeMap =newHashMap<>(5);
4242

4343
static {
44-
IsolationNameToCodeMap.put(TRANSACTION_NONE,Connection.TRANSACTION_NONE);
45-
IsolationNameToCodeMap.put(TRANSACTION_READ_COMMITTED,Connection.TRANSACTION_READ_COMMITTED);
46-
IsolationNameToCodeMap.put(TRANSACTION_READ_UNCOMMITTED,Connection.TRANSACTION_READ_UNCOMMITTED);
47-
IsolationNameToCodeMap.put(TRANSACTION_REPEATABLE_READ,Connection.TRANSACTION_REPEATABLE_READ);
48-
IsolationNameToCodeMap.put(TRANSACTION_SERIALIZABLE,Connection.TRANSACTION_SERIALIZABLE);
44+
IsolationNameToCodeMap.put(TRANSACTION_NONE,Integer.valueOf(Connection.TRANSACTION_NONE));
45+
IsolationNameToCodeMap.put(TRANSACTION_READ_COMMITTED,Integer.valueOf(Connection.TRANSACTION_READ_COMMITTED));
46+
IsolationNameToCodeMap.put(TRANSACTION_READ_UNCOMMITTED,Integer.valueOf(Connection.TRANSACTION_READ_UNCOMMITTED));
47+
IsolationNameToCodeMap.put(TRANSACTION_REPEATABLE_READ,Integer.valueOf(Connection.TRANSACTION_REPEATABLE_READ));
48+
IsolationNameToCodeMap.put(TRANSACTION_SERIALIZABLE,Integer.valueOf(Connection.TRANSACTION_SERIALIZABLE));
4949
}
5050

5151
privateBeeTransactionIsolationNames() {

‎src/main/java/org/stone/beecp/pool/FastConnectionPool.java‎

Lines changed: 90 additions & 95 deletions
Large diffs are not rendered by default.

‎src/main/java/org/stone/beecp/pool/MethodExecutionLogCache.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
publicclassMethodExecutionLogCache {
3030
privatefinalintmaxSize;
3131
//slow threshold value of connection get,time unit:milliseconds,refer to {@code BeeDataSourceConfig.slowConnectionGetThreshold}
32-
privatefinallongslowConnectionGetThreshold;
32+
privatefinallongslowConnectionThreshold;
3333
//slow threshold of sql execution,time unit:milliseconds,refer to {@code BeeDataSourceConfig.slowSQLExecutionThreshold}
34-
privatefinallongslowSQLExecutionThreshold;
34+
privatefinallongslowSQLThreshold;
3535

3636
//logs queue of connection get
3737
privatefinalLinkedBlockingQueue<MethodExecutionLog>conLogQueue;
@@ -44,7 +44,7 @@ public class MethodExecutionLogCache {
4444
//***************************************************************************************************************//
4545

4646
/**
47-
* initialize logmanager.
47+
* initialize logcache.
4848
*
4949
* @param cacheSize is capacity of logs cache
5050
* @param slowGet is slow threshold value of connection get,time unit:milliseconds
@@ -53,8 +53,8 @@ public class MethodExecutionLogCache {
5353
*/
5454
MethodExecutionLogCache(intcacheSize,longslowGet,longslowExec,BeeMethodExecutionListenerlistener) {
5555
this.listener =listener;
56-
this.slowConnectionGetThreshold =slowGet;
57-
this.slowSQLExecutionThreshold =slowExec;
56+
this.slowConnectionThreshold =slowGet;
57+
this.slowSQLThreshold =slowExec;
5858

5959
this.maxSize =cacheSize;
6060
this.conLogQueue =newLinkedBlockingQueue<>(cacheSize);
@@ -113,8 +113,8 @@ public void afterCall(Object callResult, long preparationTookTime, Object[] prep
113113
offerQueue(defaultTypeLog,log.getType(),log.getParameters(),log.getSql());
114114
}
115115

116-
if (((Type_Connection_Get ==log.getType() &&log.getEndTime() -log.getStartTime() -slowConnectionGetThreshold >=0L)
117-
|| (Type_SQL_Execution ==log.getType() &&log.getEndTime() -log.getStartTime() -slowSQLExecutionThreshold >=0L))) {
116+
if (((Type_Connection_Get ==log.getType() &&log.getEndTime() -log.getStartTime() -slowConnectionThreshold >=0L)
117+
|| (Type_SQL_Execution ==log.getType() &&log.getEndTime() -log.getStartTime() -slowSQLThreshold >=0L))) {
118118
defaultTypeLog.setAsSlow();
119119
}
120120

@@ -180,7 +180,7 @@ public void clearTimeout(long timeout) {
180180
conPendingRemovalLogList.add(log);
181181
}
182182

183-
if (log.getEndTime() ==0 &&currentTime -log.getStartTime() >=slowConnectionGetThreshold) {
183+
if (log.getEndTime() ==0 &&currentTime -log.getStartTime() >=slowConnectionThreshold) {
184184
log.setAsSlow();
185185
longRunningLogList.add(log);
186186
}
@@ -192,7 +192,7 @@ public void clearTimeout(long timeout) {
192192
sqlPendingRemovalLogList.add(log);
193193
}
194194

195-
if (log.getEndTime() ==0 &&currentTime -log.getStartTime() >=slowSQLExecutionThreshold) {
195+
if (log.getEndTime() ==0 &&currentTime -log.getStartTime() >=slowSQLThreshold) {
196196
log.setAsSlow();
197197
longRunningLogList.add(log);
198198
}

‎src/main/java/org/stone/beecp/pool/PooledConnection.java‎

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @version 1.0
3030
*/
3131
finalclassPooledConnection {
32-
privatestaticfinalboolean[]FALSE =newboolean[6];
32+
privatestaticfinalboolean[]Default_Reset_Flags =newboolean[6];
3333
privatefinalFastConnectionPoolpool;
3434

3535
//***************************************************************************************************************//
@@ -41,8 +41,8 @@ final class PooledConnection {
4141
StringdefaultCatalog;
4242
StringdefaultSchema;
4343
intdefaultNetworkTimeout;
44-
booleanforceDirtyOnSchemaAfterSet;
45-
booleanforceDirtyOnCatalogAfterSet;
44+
booleanforceDirtyWhenSetSchema;
45+
booleanforceDirtyWhenSetCatalog;
4646
//***************************************************************************************************************//
4747
// section-B: runtime change fields // //
4848
//***************************************************************************************************************//
@@ -64,11 +64,11 @@ final class PooledConnection {
6464
//***************************************************************************************************************//
6565
// section-C: some switch fields and others // //
6666
//***************************************************************************************************************//
67-
privatebooleanuseDefaultOnCatalog;
68-
privatebooleanenableDefaultOnSchema;
69-
privatebooleanuseDefaultOnReadOnly;
70-
privatebooleanuseDefaultOnAutoCommit;
71-
privatebooleanuseDefaultOnTransactionIsolation;
67+
privatebooleanenableDefaultCatalog;
68+
privatebooleanenableDefaultSchema;
69+
privatebooleanenableDefaultReadOnly;
70+
privatebooleanenableDefaultAutoCommit;
71+
privatebooleanenableDefaultTransactionIsolation;
7272
privatebooleansupportNetworkTimeoutInd;
7373
privateThreadPoolExecutornetworkTimeoutExecutor;
7474
privateList<Integer>sqlExceptionCodeList;
@@ -85,49 +85,50 @@ final class PooledConnection {
8585
//***************************************************************************************************************//
8686
// 2: init method // //
8787
//***************************************************************************************************************//
88-
voidinit(//1:defaultAutoCommit
89-
booleanuseDefaultOnAutoCommit,
90-
booleandefaultAutoCommit,
91-
//2:defaultTransactionIsolation
92-
booleanuseDefaultOnTransactionIsolation,
93-
intdefaultTransactionIsolation,
94-
//3:defaultReadOnly
95-
booleanuseDefaultOnReadOnly,
96-
booleandefaultReadOnly,
97-
//4:defaultCatalog
98-
booleanuseDefaultOnCatalog,
99-
StringdefaultCatalog,
100-
booleanforceDirtyOnCatalogAfterSet,
101-
//5:defaultSchema
102-
booleanuseDefaultOnSchema,
103-
StringdefaultSchema,
104-
booleanforceDirtyOnSchemaAfterSet,
105-
//6:defaultNetworkTimeout
106-
booleansupportNetworkTimeoutInd,
107-
intdefaultNetworkTimeout,
108-
ThreadPoolExecutornetworkTimeoutExecutor,
109-
//7:others
110-
List<Integer>sqlExceptionCodeList,
111-
List<String>sqlExceptionStateList,
112-
BeeConnectionPredicatepredicate) {
88+
voidinit(
89+
//1:defaultAutoCommit
90+
booleanuseDefaultAutoCommit,
91+
booleandefaultAutoCommit,
92+
//2:defaultTransactionIsolation
93+
booleanuseDefaultTransactionIsolation,
94+
intdefaultTransactionIsolation,
95+
//3:defaultReadOnly
96+
booleanuseDefaultReadOnly,
97+
booleandefaultReadOnly,
98+
//4:defaultCatalog
99+
booleanuseDefaultCatalog,
100+
StringdefaultCatalog,
101+
booleanforceDirtyWhenSetCatalog,
102+
//5:defaultSchema
103+
booleanuseDefaultSchema,
104+
StringdefaultSchema,
105+
booleanforceDirtyWhenSetSchema,
106+
//6:defaultNetworkTimeout
107+
booleansupportNetworkTimeoutInd,
108+
intdefaultNetworkTimeout,
109+
ThreadPoolExecutornetworkTimeoutExecutor,
110+
//7:others
111+
List<Integer>sqlExceptionCodeList,
112+
List<String>sqlExceptionStateList,
113+
BeeConnectionPredicatepredicate) {
113114

114115
//1:defaultAutoCommit
115-
this.useDefaultOnAutoCommit =useDefaultOnAutoCommit;
116+
this.enableDefaultAutoCommit =useDefaultAutoCommit;
116117
this.defaultAutoCommit =defaultAutoCommit;
117118
//2:defaultTransactionIsolation
118-
this.useDefaultOnTransactionIsolation =useDefaultOnTransactionIsolation;
119+
this.enableDefaultTransactionIsolation =useDefaultTransactionIsolation;
119120
this.defaultTransactionIsolation =defaultTransactionIsolation;
120121
//3:defaultReadOnly
121-
this.useDefaultOnReadOnly =useDefaultOnReadOnly;
122+
this.enableDefaultReadOnly =useDefaultReadOnly;
122123
this.defaultReadOnly =defaultReadOnly;
123124
//4:defaultCatalog
124-
this.useDefaultOnCatalog =useDefaultOnCatalog;
125+
this.enableDefaultCatalog =useDefaultCatalog;
125126
this.defaultCatalog =defaultCatalog;
126-
this.forceDirtyOnCatalogAfterSet =forceDirtyOnCatalogAfterSet;
127+
this.forceDirtyWhenSetCatalog =forceDirtyWhenSetCatalog;
127128
//5:defaultSchema
128-
this.enableDefaultOnSchema =useDefaultOnSchema;
129+
this.enableDefaultSchema =useDefaultSchema;
129130
this.defaultSchema =defaultSchema;
130-
this.forceDirtyOnSchemaAfterSet =forceDirtyOnSchemaAfterSet;
131+
this.forceDirtyWhenSetSchema =forceDirtyWhenSetSchema;
131132
//6:defaultNetworkTimeout
132133
this.supportNetworkTimeoutInd =supportNetworkTimeoutInd;
133134
this.defaultNetworkTimeout =defaultNetworkTimeout;
@@ -142,23 +143,20 @@ void init(//1:defaultAutoCommit
142143
// 3: set a created connection and set default on it // //
143144
//***************************************************************************************************************//
144145
voidsetRawConnection(intstate,ConnectionrawConn,XAResourcerawXaRes)throwsSQLException {
145-
if (useDefaultOnAutoCommit &&defaultAutoCommit !=rawConn.getAutoCommit())
146+
if (enableDefaultAutoCommit &&defaultAutoCommit !=rawConn.getAutoCommit())
146147
rawConn.setAutoCommit(defaultAutoCommit);
147-
if (useDefaultOnTransactionIsolation &&defaultTransactionIsolation -rawConn.getTransactionIsolation() !=0)
148+
if (enableDefaultTransactionIsolation &&defaultTransactionIsolation -rawConn.getTransactionIsolation() !=0)
148149
rawConn.setTransactionIsolation(defaultTransactionIsolation);
149-
if (useDefaultOnReadOnly &&defaultReadOnly !=rawConn.isReadOnly())
150+
if (enableDefaultReadOnly &&defaultReadOnly !=rawConn.isReadOnly())
150151
rawConn.setReadOnly(defaultReadOnly);
151-
if (useDefaultOnCatalog && !Objects.equals(defaultCatalog,rawConn.getCatalog()))
152+
if (enableDefaultCatalog && !Objects.equals(defaultCatalog,rawConn.getCatalog()))
152153
rawConn.setCatalog(defaultCatalog);
153-
if (enableDefaultOnSchema && !Objects.equals(defaultSchema,rawConn.getSchema()))
154+
if (enableDefaultSchema && !Objects.equals(defaultSchema,rawConn.getSchema()))
154155
rawConn.setSchema(defaultSchema);
155156

156-
setRawConnection2(state,rawConn,rawXaRes);
157+
this.setRawConnection2(state,rawConn,rawXaRes);
157158
}
158159

159-
//***************************************************************************************************************//
160-
// 4: set a created connection without setting default // //
161-
//***************************************************************************************************************//
162160
voidsetRawConnection2(intstate,ConnectionrawConn,XAResourcerawXaRes) {
163161
this.rawConn =rawConn;
164162
this.rawXaRes =rawXaRes;
@@ -331,7 +329,7 @@ private void resetRawConn() throws SQLException {
331329
this.rawConn.setNetworkTimeout(this.networkTimeoutExecutor,this.defaultNetworkTimeout);
332330
//for JDK1.7 end
333331
this.resetCnt =0;
334-
System.arraycopy(PooledConnection.FALSE,0,this.resetFlags,0,6);
332+
System.arraycopy(PooledConnection.Default_Reset_Flags,0,this.resetFlags,0,6);
335333
}//reset end
336334
//clear warnings
337335
this.rawConn.clearWarnings();

‎src/main/java/org/stone/beecp/pool/ProxyClassesGenerator.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,15 @@ private static void addMethodsToProxyStatementClass(ClassPool classPool, CtClass
574574

575575
//1: add start log
576576
if (methodParameterSize ==0) {
577-
methodBuffer.append("BeeMethodExecutionLog log = logCache.beforeCall(BeeMethodExecutionLog.Type_SQL_Execution,").append(methodSignature).append(",null,sql,this);");
577+
methodBuffer.append("BeeMethodExecutionLog log = logCache.beforeCall(BeeMethodExecutionLog.Type_SQL_Execution,").append(methodSignature).append(",null,preparedSql,this);");
578578
}else {
579579
methodBuffer.append("Object[]parameters = new Object[]{");
580580
for (inti =0;i <methodParameterSize;i++) {
581581
if (i >0)methodBuffer.append(",");
582582
methodBuffer.append(getConvertType("$" + (i +1),parameterTypes[i]));
583583
}
584584
methodBuffer.append("};");
585-
methodBuffer.append("BeeMethodExecutionLog log = logCache.beforeCall(BeeMethodExecutionLog.Type_SQL_Execution,").append(methodSignature).append(",parameters,sql,this);");
585+
methodBuffer.append("BeeMethodExecutionLog log = logCache.beforeCall(BeeMethodExecutionLog.Type_SQL_Execution,").append(methodSignature).append(",parameters,preparedSql,this);");
586586
}
587587

588588
//2: add 'try' code snippet

‎src/main/java/org/stone/beecp/pool/ProxyConnectionBase.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ public abstract class ProxyConnectionBase extends ProxyBaseWrapper implements Co
3333
}
3434

3535
ProxyConnectionBase(PooledConnectionp,MethodExecutionLogCachelogCache) {
36-
super(p);
37-
raw =p.rawConn;
38-
p.proxyInUsing =this;
39-
36+
this(p);
4037
this.logCache =logCache;
4138
}
4239

@@ -112,13 +109,13 @@ public void setReadOnly(boolean readOnly) throws SQLException {
112109

113110
publicvoidsetCatalog(Stringcatalog)throwsSQLException {
114111
this.raw.setCatalog(catalog);
115-
this.p.setResetInd(PS_CATALOG,p.forceDirtyOnCatalogAfterSet || !Objects.equals(catalog,this.p.defaultCatalog));
112+
this.p.setResetInd(PS_CATALOG,p.forceDirtyWhenSetCatalog || !Objects.equals(catalog,this.p.defaultCatalog));
116113
}
117114

118115
//--------------------------JDBC 4.1 -----------------------------
119116
publicvoidsetSchema(Stringschema)throwsSQLException {
120117
this.raw.setSchema(schema);
121-
this.p.setResetInd(PS_SCHEMA,p.forceDirtyOnSchemaAfterSet || !Objects.equals(schema,this.p.defaultSchema));
118+
this.p.setResetInd(PS_SCHEMA,p.forceDirtyWhenSetSchema || !Objects.equals(schema,this.p.defaultSchema));
122119
}
123120

124121
publicvoidsetNetworkTimeout(Executorexecutor,intmilliseconds)throwsSQLException {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp