Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hk581
spring-framework
提交
d0948f1f
S
spring-framework
项目概览
hk581
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
d0948f1f
编写于
7月 31, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed misunderstanding with respect to excludeUnlistedClasses default in JPA 2.0
Issue: SPR-10767
上级
ae0f23e9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
44 deletion
+37
-44
spring-core/src/main/java/org/springframework/util/xml/DomUtils.java
.../src/main/java/org/springframework/util/xml/DomUtils.java
+27
-27
spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java
...mework/orm/jpa/persistenceunit/PersistenceUnitReader.java
+9
-16
spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java
...k/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java
+1
-1
未找到文件。
spring-core/src/main/java/org/springframework/util/xml/DomUtils.java
浏览文件 @
d0948f1f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -39,18 +39,17 @@ import org.springframework.util.Assert;
* @author Costin Leau
* @author Arjen Poutsma
* @author Luke Taylor
* @since 1.2
* @see org.w3c.dom.Node
* @see org.w3c.dom.Element
* @since 1.2
*/
public
abstract
class
DomUtils
{
/**
* Retrieve all child elements of the given DOM element that match any of the given element names. Only look at the
* direct child level of the given element; do not go into further depth (in contrast to the DOM API's
* {@code getElementsByTagName} method).
*
* @param ele the DOM element to analyze
* Retrieves all child elements of the given DOM element that match any of the given element names.
* Only looks at the direct child level of the given element; do not go into further depth
* (in contrast to the DOM API's {@code getElementsByTagName} method).
* @param ele the DOM element to analyze
* @param childEleNames the child element names to look for
* @return a List of child {@code org.w3c.dom.Element} instances
* @see org.w3c.dom.Element
...
...
@@ -72,11 +71,10 @@ public abstract class DomUtils {
}
/**
* Retrieve all child elements of the given DOM element that match the given element name. Only look at the direct
* child level of the given element; do not go into further depth (in contrast to the DOM API's
* {@code getElementsByTagName} method).
*
* @param ele the DOM element to analyze
* Retrieves all child elements of the given DOM element that match the given element name.
* Only look at the direct child level of the given element; do not go into further depth
* (in contrast to the DOM API's {@code getElementsByTagName} method).
* @param ele the DOM element to analyze
* @param childEleName the child element name to look for
* @return a List of child {@code org.w3c.dom.Element} instances
* @see org.w3c.dom.Element
...
...
@@ -88,8 +86,7 @@ public abstract class DomUtils {
/**
* Utility method that returns the first child element identified by its name.
*
* @param ele the DOM element to analyze
* @param ele the DOM element to analyze
* @param childEleName the child element name to look for
* @return the {@code org.w3c.dom.Element} instance, or {@code null} if none found
*/
...
...
@@ -108,8 +105,7 @@ public abstract class DomUtils {
/**
* Utility method that returns the first child element value identified by its name.
*
* @param ele the DOM element to analyze
* @param ele the DOM element to analyze
* @param childEleName the child element name to look for
* @return the extracted text value, or {@code null} if no child element found
*/
...
...
@@ -119,9 +115,8 @@ public abstract class DomUtils {
}
/**
* Retrieve all child elements of the given DOM element
* @param ele the DOM element to analyze
* Retrieves all child elements of the given DOM element
* @param ele the DOM element to analyze
* @return a List of child {@code org.w3c.dom.Element} instances
*/
public
static
List
<
Element
>
getChildElements
(
Element
ele
)
{
...
...
@@ -138,9 +133,10 @@ public abstract class DomUtils {
}
/**
* Extract the text value from the given DOM element, ignoring XML comments. <p>Appends all CharacterData nodes and
* EntityReference nodes into a single String value, excluding Comment nodes.
*
* Extracts the text value from the given DOM element, ignoring XML comments.
* <p>Appends all CharacterData nodes and EntityReference nodes into a single
* String value, excluding Comment nodes. Only exposes actual user-specified
* text, no default values of any kind.
* @see CharacterData
* @see EntityReference
* @see Comment
...
...
@@ -159,8 +155,9 @@ public abstract class DomUtils {
}
/**
* Namespace-aware equals comparison. Returns {@code true} if either {@link Node#getLocalName} or {@link
* Node#getNodeName} equals {@code desiredName}, otherwise returns {@code false}.
* Namespace-aware equals comparison. Returns {@code true} if either
* {@link Node#getLocalName} or {@link Node#getNodeName} equals
* {@code desiredName}, otherwise returns {@code false}.
*/
public
static
boolean
nodeNameEquals
(
Node
node
,
String
desiredName
)
{
Assert
.
notNull
(
node
,
"Node must not be null"
);
...
...
@@ -170,7 +167,6 @@ public abstract class DomUtils {
/**
* Returns a SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s.
*
* @param node the node to publish events to
* @return the content handler
*/
...
...
@@ -178,12 +174,16 @@ public abstract class DomUtils {
return
new
DomContentHandler
(
node
);
}
/** Matches the given node's name and local name against the given desired name. */
/**
* Matches the given node's name and local name against the given desired name.
*/
private
static
boolean
nodeNameMatch
(
Node
node
,
String
desiredName
)
{
return
(
desiredName
.
equals
(
node
.
getNodeName
())
||
desiredName
.
equals
(
node
.
getLocalName
()));
}
/** Matches the given node's name and local name against the given desired names. */
/**
* Matches the given node's name and local name against the given desired names.
*/
private
static
boolean
nodeNameMatch
(
Node
node
,
Collection
desiredNames
)
{
return
(
desiredNames
.
contains
(
node
.
getNodeName
())
||
desiredNames
.
contains
(
node
.
getLocalName
()));
}
...
...
spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java
浏览文件 @
d0948f1f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -21,7 +21,6 @@ import java.io.InputStream;
import
java.net.URL
;
import
java.util.LinkedList
;
import
java.util.List
;
import
javax.persistence.spi.PersistenceUnitTransactionType
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
...
...
@@ -29,6 +28,11 @@ import javax.xml.parsers.ParserConfigurationException;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.xml.sax.ErrorHandler
;
import
org.xml.sax.SAXException
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.jdbc.datasource.lookup.DataSourceLookup
;
...
...
@@ -37,10 +41,6 @@ import org.springframework.util.ResourceUtils;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.xml.DomUtils
;
import
org.springframework.util.xml.SimpleSaxErrorHandler
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.xml.sax.ErrorHandler
;
import
org.xml.sax.SAXException
;
/**
* Internal helper class for reading JPA-compliant {@code persistence.xml} files.
...
...
@@ -81,8 +81,6 @@ class PersistenceUnitReader {
private
static
final
String
META_INF
=
"META-INF"
;
private
static
final
String
VERSION_1
=
"1.0"
;
private
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
...
...
@@ -249,7 +247,7 @@ class PersistenceUnitReader {
unitInfo
.
setTransactionType
(
PersistenceUnitTransactionType
.
valueOf
(
txType
));
}
//
data-source
//
evaluate data sources
String
jtaDataSource
=
DomUtils
.
getChildElementValueByTagName
(
persistenceUnit
,
JTA_DATA_SOURCE
);
if
(
StringUtils
.
hasText
(
jtaDataSource
))
{
unitInfo
.
setJtaDataSource
(
this
.
dataSourceLookup
.
getDataSource
(
jtaDataSource
.
trim
()));
...
...
@@ -268,14 +266,9 @@ class PersistenceUnitReader {
// exclude unlisted classes
Element
excludeUnlistedClasses
=
DomUtils
.
getChildElementByTagName
(
persistenceUnit
,
EXCLUDE_UNLISTED_CLASSES
);
if
(
excludeUnlistedClasses
==
null
)
{
// element is not defined, use default appropriate for version
unitInfo
.
setExcludeUnlistedClasses
(!
VERSION_1
.
equals
(
version
));
}
else
{
if
(
excludeUnlistedClasses
!=
null
)
{
String
excludeText
=
DomUtils
.
getTextValue
(
excludeUnlistedClasses
);
unitInfo
.
setExcludeUnlistedClasses
(
StringUtils
.
isEmpty
(
excludeText
)
||
Boolean
.
valueOf
(
excludeText
));
unitInfo
.
setExcludeUnlistedClasses
(!
StringUtils
.
hasText
(
excludeText
)
||
Boolean
.
valueOf
(
excludeText
));
}
// set JPA 2.0 shared cache mode
...
...
spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java
浏览文件 @
d0948f1f
...
...
@@ -351,7 +351,7 @@ public class PersistenceXmlParsingTests {
PersistenceUnitInfo
noExclude
=
info
[
0
];
assertNotNull
(
"noExclude should not be null."
,
noExclude
);
assertEquals
(
"noExclude name is not correct."
,
"NoExcludeElement"
,
noExclude
.
getPersistenceUnitName
());
assert
True
(
"Exclude unlisted should default tru
e in 2.0."
,
noExclude
.
excludeUnlistedClasses
());
assert
False
(
"Exclude unlisted still defaults to fals
e in 2.0."
,
noExclude
.
excludeUnlistedClasses
());
PersistenceUnitInfo
emptyExclude
=
info
[
1
];
assertNotNull
(
"emptyExclude should not be null."
,
emptyExclude
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录