Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
308e3370
Commit
308e3370
authored
Jun 25, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Disable XML reader when spring.xml.ignore is true"
See gh-22093
parent
8d5cf796
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
BeanDefinitionLoader.java
...n/java/org/springframework/boot/BeanDefinitionLoader.java
+10
-15
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java
View file @
308e3370
...
@@ -26,6 +26,7 @@ import groovy.lang.Closure;
...
@@ -26,6 +26,7 @@ import groovy.lang.Closure;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.BeanDefinitionStoreException
;
import
org.springframework.beans.factory.BeanDefinitionStoreException
;
import
org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader
;
import
org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader
;
import
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
;
import
org.springframework.beans.factory.support.BeanDefinitionReader
;
import
org.springframework.beans.factory.support.BeanDefinitionReader
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
import
org.springframework.beans.factory.support.BeanNameGenerator
;
...
@@ -59,20 +60,14 @@ import org.springframework.util.StringUtils;
...
@@ -59,20 +60,14 @@ import org.springframework.util.StringUtils;
*/
*/
class
BeanDefinitionLoader
{
class
BeanDefinitionLoader
{
/**
// Static final field to facilitate code removal by Graal
* Boolean flag controlled by a {@code spring.xml.ignore} system property that
private
static
final
boolean
XML_ENABLED
=
!
SpringProperties
.
getFlag
(
"spring.xml.ignore"
);
* instructs Spring to ignore XML, i.e. to not initialize the XML-related
* infrastructure.
* <p>
* By default XML support is enabled.
*/
private
static
final
boolean
IS_XML_ENABLED
=
!
SpringProperties
.
getFlag
(
"spring.xml.ignore"
);
private
final
Object
[]
sources
;
private
final
Object
[]
sources
;
private
final
AnnotatedBeanDefinitionReader
annotatedReader
;
private
final
AnnotatedBeanDefinitionReader
annotatedReader
;
private
final
Xml
BeanDefinitionReader
xmlReader
;
private
final
Abstract
BeanDefinitionReader
xmlReader
;
private
final
BeanDefinitionReader
groovyReader
;
private
final
BeanDefinitionReader
groovyReader
;
...
@@ -91,7 +86,7 @@ class BeanDefinitionLoader {
...
@@ -91,7 +86,7 @@ class BeanDefinitionLoader {
Assert
.
notEmpty
(
sources
,
"Sources must not be empty"
);
Assert
.
notEmpty
(
sources
,
"Sources must not be empty"
);
this
.
sources
=
sources
;
this
.
sources
=
sources
;
this
.
annotatedReader
=
new
AnnotatedBeanDefinitionReader
(
registry
);
this
.
annotatedReader
=
new
AnnotatedBeanDefinitionReader
(
registry
);
this
.
xmlReader
=
(
IS_
XML_ENABLED
?
new
XmlBeanDefinitionReader
(
registry
)
:
null
);
this
.
xmlReader
=
(
XML_ENABLED
?
new
XmlBeanDefinitionReader
(
registry
)
:
null
);
this
.
groovyReader
=
(
isGroovyPresent
()
?
new
GroovyBeanDefinitionReader
(
registry
)
:
null
);
this
.
groovyReader
=
(
isGroovyPresent
()
?
new
GroovyBeanDefinitionReader
(
registry
)
:
null
);
this
.
scanner
=
new
ClassPathBeanDefinitionScanner
(
registry
);
this
.
scanner
=
new
ClassPathBeanDefinitionScanner
(
registry
);
this
.
scanner
.
addExcludeFilter
(
new
ClassExcludeFilter
(
sources
));
this
.
scanner
.
addExcludeFilter
(
new
ClassExcludeFilter
(
sources
));
...
@@ -104,7 +99,7 @@ class BeanDefinitionLoader {
...
@@ -104,7 +99,7 @@ class BeanDefinitionLoader {
void
setBeanNameGenerator
(
BeanNameGenerator
beanNameGenerator
)
{
void
setBeanNameGenerator
(
BeanNameGenerator
beanNameGenerator
)
{
this
.
annotatedReader
.
setBeanNameGenerator
(
beanNameGenerator
);
this
.
annotatedReader
.
setBeanNameGenerator
(
beanNameGenerator
);
this
.
scanner
.
setBeanNameGenerator
(
beanNameGenerator
);
this
.
scanner
.
setBeanNameGenerator
(
beanNameGenerator
);
if
(
IS_XML_ENABLED
)
{
if
(
this
.
xmlReader
!=
null
)
{
this
.
xmlReader
.
setBeanNameGenerator
(
beanNameGenerator
);
this
.
xmlReader
.
setBeanNameGenerator
(
beanNameGenerator
);
}
}
}
}
...
@@ -116,7 +111,7 @@ class BeanDefinitionLoader {
...
@@ -116,7 +111,7 @@ class BeanDefinitionLoader {
void
setResourceLoader
(
ResourceLoader
resourceLoader
)
{
void
setResourceLoader
(
ResourceLoader
resourceLoader
)
{
this
.
resourceLoader
=
resourceLoader
;
this
.
resourceLoader
=
resourceLoader
;
this
.
scanner
.
setResourceLoader
(
resourceLoader
);
this
.
scanner
.
setResourceLoader
(
resourceLoader
);
if
(
IS_XML_ENABLED
)
{
if
(
this
.
xmlReader
!=
null
)
{
this
.
xmlReader
.
setResourceLoader
(
resourceLoader
);
this
.
xmlReader
.
setResourceLoader
(
resourceLoader
);
}
}
}
}
...
@@ -128,7 +123,7 @@ class BeanDefinitionLoader {
...
@@ -128,7 +123,7 @@ class BeanDefinitionLoader {
void
setEnvironment
(
ConfigurableEnvironment
environment
)
{
void
setEnvironment
(
ConfigurableEnvironment
environment
)
{
this
.
annotatedReader
.
setEnvironment
(
environment
);
this
.
annotatedReader
.
setEnvironment
(
environment
);
this
.
scanner
.
setEnvironment
(
environment
);
this
.
scanner
.
setEnvironment
(
environment
);
if
(
IS_XML_ENABLED
)
{
if
(
this
.
xmlReader
!=
null
)
{
this
.
xmlReader
.
setEnvironment
(
environment
);
this
.
xmlReader
.
setEnvironment
(
environment
);
}
}
}
}
...
@@ -182,8 +177,8 @@ class BeanDefinitionLoader {
...
@@ -182,8 +177,8 @@ class BeanDefinitionLoader {
this
.
groovyReader
.
loadBeanDefinitions
(
source
);
this
.
groovyReader
.
loadBeanDefinitions
(
source
);
}
}
else
{
else
{
if
(
!
IS_XML_ENABLED
)
{
if
(
this
.
xmlReader
==
null
)
{
throw
new
BeanDefinitionStoreException
(
"Cannot load
resource
s when XML support is disabled"
);
throw
new
BeanDefinitionStoreException
(
"Cannot load
XML bean definition
s when XML support is disabled"
);
}
}
this
.
xmlReader
.
loadBeanDefinitions
(
source
);
this
.
xmlReader
.
loadBeanDefinitions
(
source
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment