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
953ef709
Commit
953ef709
authored
Oct 06, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of Ordered from auto-configuration classes
Closes gh-4056
parent
89ed2aa0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
43 deletions
+74
-43
DataSourceTransactionManagerAutoConfiguration.java
...e/jdbc/DataSourceTransactionManagerAutoConfiguration.java
+4
-6
ErrorMvcAutoConfiguration.java
...ork/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
+31
-13
ServerPropertiesAutoConfiguration.java
.../autoconfigure/web/ServerPropertiesAutoConfiguration.java
+39
-24
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.java
View file @
953ef709
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jdbc;
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jdbc;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.AutoConfigureOrder
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
...
@@ -38,15 +39,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
...
@@ -38,15 +39,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*
*
* @author Dave Syer
* @author Dave Syer
* @author Stephane Nicoll
* @author Stephane Nicoll
* @author Andy Wilkinson
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
({
JdbcTemplate
.
class
,
PlatformTransactionManager
.
class
})
@ConditionalOnClass
({
JdbcTemplate
.
class
,
PlatformTransactionManager
.
class
})
public
class
DataSourceTransactionManagerAutoConfiguration
implements
Ordered
{
@AutoConfigureOrder
(
Ordered
.
LOWEST_PRECEDENCE
)
public
class
DataSourceTransactionManagerAutoConfiguration
{
@Override
public
int
getOrder
()
{
return
Integer
.
MAX_VALUE
;
}
@Autowired
(
required
=
false
)
@Autowired
(
required
=
false
)
private
DataSource
dataSource
;
private
DataSource
dataSource
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
View file @
953ef709
...
@@ -58,7 +58,7 @@ import org.springframework.web.servlet.view.BeanNameViewResolver;
...
@@ -58,7 +58,7 @@ import org.springframework.web.servlet.view.BeanNameViewResolver;
import
org.springframework.web.util.HtmlUtils
;
import
org.springframework.web.util.HtmlUtils
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} to render errors via a MVC error
* {@link EnableAutoConfiguration Auto-configuration} to render errors via a
n
MVC error
* controller.
* controller.
*
*
* @author Dave Syer
* @author Dave Syer
...
@@ -72,17 +72,10 @@ import org.springframework.web.util.HtmlUtils;
...
@@ -72,17 +72,10 @@ import org.springframework.web.util.HtmlUtils;
@AutoConfigureBefore
(
WebMvcAutoConfiguration
.
class
)
@AutoConfigureBefore
(
WebMvcAutoConfiguration
.
class
)
@EnableConfigurationProperties
(
ErrorProperties
.
class
)
@EnableConfigurationProperties
(
ErrorProperties
.
class
)
@Configuration
@Configuration
public
class
ErrorMvcAutoConfiguration
implements
EmbeddedServletContainerCustomizer
,
public
class
ErrorMvcAutoConfiguration
{
Ordered
{
@Autowired
@Autowired
private
ServerProperties
properties
;
private
ServerProperties
properties
;
@Override
public
int
getOrder
()
{
return
0
;
}
@Bean
@Bean
@ConditionalOnMissingBean
(
value
=
ErrorAttributes
.
class
,
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnMissingBean
(
value
=
ErrorAttributes
.
class
,
search
=
SearchStrategy
.
CURRENT
)
public
DefaultErrorAttributes
errorAttributes
()
{
public
DefaultErrorAttributes
errorAttributes
()
{
...
@@ -95,10 +88,9 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
...
@@ -95,10 +88,9 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
return
new
BasicErrorController
(
errorAttributes
,
this
.
properties
.
getError
());
return
new
BasicErrorController
(
errorAttributes
,
this
.
properties
.
getError
());
}
}
@Override
@Bean
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
public
ErrorPageCustomizer
errorPageCustomizer
()
{
container
.
addErrorPages
(
new
ErrorPage
(
this
.
properties
.
getServletPrefix
()
return
new
ErrorPageCustomizer
(
this
.
properties
);
+
this
.
properties
.
getError
().
getPath
()));
}
}
@Configuration
@Configuration
...
@@ -224,4 +216,30 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
...
@@ -224,4 +216,30 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
}
}
/**
* {@link EmbeddedServletContainerCustomizer} that configures the container's error
* pages.
*/
private
static
class
ErrorPageCustomizer
implements
EmbeddedServletContainerCustomizer
,
Ordered
{
private
final
ServerProperties
properties
;
protected
ErrorPageCustomizer
(
ServerProperties
properties
)
{
this
.
properties
=
properties
;
}
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
container
.
addErrorPages
(
new
ErrorPage
(
this
.
properties
.
getServletPrefix
()
+
this
.
properties
.
getError
().
getPath
()));
}
@Override
public
int
getOrder
()
{
return
0
;
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java
View file @
953ef709
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -37,19 +37,12 @@ import org.springframework.util.StringUtils;
...
@@ -37,19 +37,12 @@ import org.springframework.util.StringUtils;
* {@link ConfigurableEmbeddedServletContainer} from a {@link ServerProperties} bean.
* {@link ConfigurableEmbeddedServletContainer} from a {@link ServerProperties} bean.
*
*
* @author Dave Syer
* @author Dave Syer
* @author Andy Wilkinson
*/
*/
@Configuration
@Configuration
@EnableConfigurationProperties
@EnableConfigurationProperties
@ConditionalOnWebApplication
@ConditionalOnWebApplication
public
class
ServerPropertiesAutoConfiguration
implements
ApplicationContextAware
,
public
class
ServerPropertiesAutoConfiguration
{
EmbeddedServletContainerCustomizer
,
Ordered
{
private
ApplicationContext
applicationContext
;
@Override
public
int
getOrder
()
{
return
0
;
}
@Bean
@Bean
@ConditionalOnMissingBean
(
search
=
SearchStrategy
.
CURRENT
)
@ConditionalOnMissingBean
(
search
=
SearchStrategy
.
CURRENT
)
...
@@ -57,22 +50,44 @@ public class ServerPropertiesAutoConfiguration implements ApplicationContextAwar
...
@@ -57,22 +50,44 @@ public class ServerPropertiesAutoConfiguration implements ApplicationContextAwar
return
new
ServerProperties
();
return
new
ServerProperties
();
}
}
@Override
@Bean
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
public
DuplicateServerPropertiesDetector
duplicateServerPropertiesDetector
()
{
throws
BeansException
{
return
new
DuplicateServerPropertiesDetector
();
this
.
applicationContext
=
applicationContext
;
}
}
@Override
/**
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
* {@link EmbeddedServletContainerCustomizer} that ensures there is exactly one
// ServerProperties handles customization, this just checks we only have
* {@link ServerProperties} bean in the application context.
// a single bean
*/
String
[]
serverPropertiesBeans
=
this
.
applicationContext
private
static
class
DuplicateServerPropertiesDetector
implements
.
getBeanNamesForType
(
ServerProperties
.
class
);
EmbeddedServletContainerCustomizer
,
Ordered
,
ApplicationContextAware
{
Assert
.
state
(
serverPropertiesBeans
.
length
==
1
,
private
ApplicationContext
applicationContext
;
"Multiple ServerProperties beans registered "
+
StringUtils
.
arrayToCommaDelimitedString
(
serverPropertiesBeans
));
@Override
public
int
getOrder
()
{
return
0
;
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
}
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
// ServerProperties handles customization, this just checks we only have
// a single bean
String
[]
serverPropertiesBeans
=
this
.
applicationContext
.
getBeanNamesForType
(
ServerProperties
.
class
);
Assert
.
state
(
serverPropertiesBeans
.
length
==
1
,
"Multiple ServerProperties beans registered "
+
StringUtils
.
arrayToCommaDelimitedString
(
serverPropertiesBeans
));
}
}
}
}
}
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