Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
be04aca0
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be04aca0
编写于
10月 09, 2010
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
consistent handling of unwrap/isWrapperFor/isClosed in JDBC proxies
上级
153680a5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
13 deletion
+59
-13
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
...main/java/org/springframework/jdbc/core/JdbcTemplate.java
+19
-6
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
...mework/jdbc/datasource/LazyConnectionDataSourceProxy.java
+14
-4
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/SingleConnectionDataSource.java
...framework/jdbc/datasource/SingleConnectionDataSource.java
+14
-1
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java
...work/jdbc/datasource/TransactionAwareDataSourceProxy.java
+12
-2
未找到文件。
org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
浏览文件 @
be04aca0
...
...
@@ -1295,7 +1295,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
/**
* Invocation handler that suppresses close calls on JDBC C
O
nnections.
* Invocation handler that suppresses close calls on JDBC C
o
nnections.
* Also prepares returned Statement (Prepared/CallbackStatement) objects.
* @see java.sql.Connection#close()
*/
...
...
@@ -1310,11 +1310,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
// Invocation on ConnectionProxy interface coming in...
if
(
method
.
getName
().
equals
(
"getTargetConnection"
))
{
// Handle getTargetConnection method: return underlying Connection.
return
this
.
target
;
}
else
if
(
method
.
getName
().
equals
(
"equals"
))
{
if
(
method
.
getName
().
equals
(
"equals"
))
{
// Only consider equal when proxies are identical.
return
(
proxy
==
args
[
0
]);
}
...
...
@@ -1322,10 +1318,27 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
// Use hashCode of PersistenceManager proxy.
return
System
.
identityHashCode
(
proxy
);
}
else
if
(
method
.
getName
().
equals
(
"unwrap"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
proxy
;
}
}
else
if
(
method
.
getName
().
equals
(
"isWrapperFor"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
true
;
}
}
else
if
(
method
.
getName
().
equals
(
"close"
))
{
// Handle close method: suppress, not valid.
return
null
;
}
else
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
false
;
}
else
if
(
method
.
getName
().
equals
(
"getTargetConnection"
))
{
// Handle getTargetConnection method: return underlying Connection.
return
this
.
target
;
}
// Invoke method on target Connection.
try
{
...
...
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
浏览文件 @
be04aca0
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
10
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -288,6 +288,16 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
// Connection has been fetched: use hashCode of Connection proxy.
return
System
.
identityHashCode
(
proxy
);
}
else
if
(
method
.
getName
().
equals
(
"unwrap"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
proxy
;
}
}
else
if
(
method
.
getName
().
equals
(
"isWrapperFor"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
true
;
}
}
else
if
(
method
.
getName
().
equals
(
"getTargetConnection"
))
{
// Handle getTargetConnection method: return underlying connection.
return
getTargetConnection
(
method
);
...
...
@@ -344,14 +354,14 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
else
if
(
method
.
getName
().
equals
(
"clearWarnings"
))
{
return
null
;
}
else
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
this
.
closed
;
}
else
if
(
method
.
getName
().
equals
(
"close"
))
{
// Ignore: no target connection yet.
this
.
closed
=
true
;
return
null
;
}
else
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
this
.
closed
;
}
else
if
(
this
.
closed
)
{
// Connection proxy closed, without ever having fetched a
// physical JDBC Connection: throw corresponding SQLException.
...
...
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/SingleConnectionDataSource.java
浏览文件 @
be04aca0
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
10
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -325,10 +325,23 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
// Use hashCode of Connection proxy.
return
System
.
identityHashCode
(
proxy
);
}
else
if
(
method
.
getName
().
equals
(
"unwrap"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
proxy
;
}
}
else
if
(
method
.
getName
().
equals
(
"isWrapperFor"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
true
;
}
}
else
if
(
method
.
getName
().
equals
(
"close"
))
{
// Handle close method: don't pass the call on.
return
null
;
}
else
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
false
;
}
else
if
(
method
.
getName
().
equals
(
"getTargetConnection"
))
{
// Handle getTargetConnection method: return underlying Connection.
return
this
.
target
;
...
...
org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java
浏览文件 @
be04aca0
...
...
@@ -196,8 +196,15 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
}
return
sb
.
toString
();
}
else
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
this
.
closed
;
else
if
(
method
.
getName
().
equals
(
"unwrap"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
proxy
;
}
}
else
if
(
method
.
getName
().
equals
(
"isWrapperFor"
))
{
if
(((
Class
)
args
[
0
]).
isInstance
(
proxy
))
{
return
true
;
}
}
else
if
(
method
.
getName
().
equals
(
"close"
))
{
// Handle close method: only close if not within a transaction.
...
...
@@ -205,6 +212,9 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
this
.
closed
=
true
;
return
null
;
}
else
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
this
.
closed
;
}
if
(
this
.
target
==
null
)
{
if
(
this
.
closed
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录