Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
211f8ea8
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,发现更多精彩内容 >>
提交
211f8ea8
编写于
1月 05, 2012
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JBossNativeJdbcExtractor is compatible with JBoss AS 7 as well (SPR-8957)
上级
af384481
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
10 deletion
+27
-10
org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/nativejdbc/JBossNativeJdbcExtractor.java
...ork/jdbc/support/nativejdbc/JBossNativeJdbcExtractor.java
+27
-10
未找到文件。
org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/nativejdbc/JBossNativeJdbcExtractor.java
浏览文件 @
211f8ea8
/*
/*
* Copyright 2002-20
08
the original author or authors.
* Copyright 2002-20
12
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -28,7 +28,8 @@ import org.springframework.util.ReflectionUtils;
...
@@ -28,7 +28,8 @@ import org.springframework.util.ReflectionUtils;
/**
/**
* Implementation of the {@link NativeJdbcExtractor} interface for JBoss,
* Implementation of the {@link NativeJdbcExtractor} interface for JBoss,
* supporting JBoss Application Server 3.2.4+.
* supporting JBoss Application Server 3.2.4+. As of Spring 3.1.1, it also
* supports JBoss 7.
*
*
* <p>Returns the underlying native Connection, Statement, etc to
* <p>Returns the underlying native Connection, Statement, etc to
* application code instead of JBoss' wrapper implementations.
* application code instead of JBoss' wrapper implementations.
...
@@ -47,11 +48,11 @@ import org.springframework.util.ReflectionUtils;
...
@@ -47,11 +48,11 @@ import org.springframework.util.ReflectionUtils;
*/
*/
public
class
JBossNativeJdbcExtractor
extends
NativeJdbcExtractorAdapter
{
public
class
JBossNativeJdbcExtractor
extends
NativeJdbcExtractorAdapter
{
private
static
final
String
WRAPPED_CONNECTION_NAME
=
"org.jboss.resource.adapter.jdbc.WrappedConnection"
;
// JBoss 7
private
static
final
String
JBOSS_JCA_PREFIX
=
"org.jboss.jca.adapters.jdbc."
;
private
static
final
String
WRAPPED_STATEMENT_NAME
=
"org.jboss.resource.adapter.jdbc.WrappedStatement"
;
// JBoss <= 6
private
static
final
String
JBOSS_RESOURCE_PREFIX
=
"org.jboss.resource.adapter.jdbc."
;
private
static
final
String
WRAPPED_RESULT_SET_NAME
=
"org.jboss.resource.adapter.jdbc.WrappedResultSet"
;
private
Class
wrappedConnectionClass
;
private
Class
wrappedConnectionClass
;
...
@@ -72,10 +73,26 @@ public class JBossNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
...
@@ -72,10 +73,26 @@ public class JBossNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
* so we can get the underlying vendor connection using reflection.
* so we can get the underlying vendor connection using reflection.
*/
*/
public
JBossNativeJdbcExtractor
()
{
public
JBossNativeJdbcExtractor
()
{
String
prefix
=
JBOSS_JCA_PREFIX
;
try
{
// trying JBoss 7 jca package first...
this
.
wrappedConnectionClass
=
getClass
().
getClassLoader
().
loadClass
(
prefix
+
"WrappedConnection"
);
}
catch
(
ClassNotFoundException
ex
)
{
// JBoss 7 jca package not found -> try traditional resource package.
prefix
=
JBOSS_RESOURCE_PREFIX
;
try
{
this
.
wrappedConnectionClass
=
getClass
().
getClassLoader
().
loadClass
(
prefix
+
"WrappedConnection"
);
}
catch
(
ClassNotFoundException
ex2
)
{
throw
new
IllegalStateException
(
"Could not initialize JBossNativeJdbcExtractor: neither JBoss 7's ["
+
JBOSS_JCA_PREFIX
+
".WrappedConnection] nor traditional JBoss ["
+
JBOSS_RESOURCE_PREFIX
+
".WrappedConnection] found"
);
}
}
try
{
try
{
this
.
wrappedConnectionClass
=
getClass
().
getClassLoader
().
loadClass
(
WRAPPED_CONNECTION_NAME
);
this
.
wrappedStatementClass
=
getClass
().
getClassLoader
().
loadClass
(
prefix
+
"WrappedStatement"
);
this
.
wrappedStatementClass
=
getClass
().
getClassLoader
().
loadClass
(
WRAPPED_STATEMENT_NAME
);
this
.
wrappedResultSetClass
=
getClass
().
getClassLoader
().
loadClass
(
prefix
+
"WrappedResultSet"
);
this
.
wrappedResultSetClass
=
getClass
().
getClassLoader
().
loadClass
(
WRAPPED_RESULT_SET_NAME
);
this
.
getUnderlyingConnectionMethod
=
this
.
getUnderlyingConnectionMethod
=
this
.
wrappedConnectionClass
.
getMethod
(
"getUnderlyingConnection"
,
(
Class
[])
null
);
this
.
wrappedConnectionClass
.
getMethod
(
"getUnderlyingConnection"
,
(
Class
[])
null
);
this
.
getUnderlyingStatementMethod
=
this
.
getUnderlyingStatementMethod
=
...
@@ -85,7 +102,7 @@ public class JBossNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
...
@@ -85,7 +102,7 @@ public class JBossNativeJdbcExtractor extends NativeJdbcExtractorAdapter {
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
throw
new
IllegalStateException
(
throw
new
IllegalStateException
(
"Could not initialize JBossNativeJdbcExtractor because
JBoss API classes are not available
: "
+
ex
);
"Could not initialize JBossNativeJdbcExtractor because
of missing JBoss API methods/classes
: "
+
ex
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录