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
d61c3816
Commit
d61c3816
authored
Jul 01, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
533d36a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
EndpointWebMvcAutoConfiguration.java
...ctuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
+12
-10
WelcomePageMockMvcTests.java
...ework/boot/autoconfigure/web/WelcomePageMockMvcTests.java
+8
-8
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
View file @
d61c3816
...
@@ -86,10 +86,10 @@ import org.springframework.web.servlet.DispatcherServlet;
...
@@ -86,10 +86,10 @@ import org.springframework.web.servlet.DispatcherServlet;
@ConditionalOnClass
({
Servlet
.
class
,
DispatcherServlet
.
class
})
@ConditionalOnClass
({
Servlet
.
class
,
DispatcherServlet
.
class
})
@ConditionalOnWebApplication
@ConditionalOnWebApplication
@AutoConfigureAfter
({
PropertyPlaceholderAutoConfiguration
.
class
,
@AutoConfigureAfter
({
PropertyPlaceholderAutoConfiguration
.
class
,
EmbeddedServletContainerAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
EmbeddedServletContainerAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
})
ManagementServerPropertiesAutoConfiguration
.
class
})
public
class
EndpointWebMvcAutoConfiguration
implements
ApplicationContextAware
,
public
class
EndpointWebMvcAutoConfiguration
implements
ApplicationContextAware
,
SmartInitializingSingleton
{
SmartInitializingSingleton
{
private
static
Log
logger
=
LogFactory
.
getLog
(
EndpointWebMvcAutoConfiguration
.
class
);
private
static
Log
logger
=
LogFactory
.
getLog
(
EndpointWebMvcAutoConfiguration
.
class
);
...
@@ -119,7 +119,7 @@ SmartInitializingSingleton {
...
@@ -119,7 +119,7 @@ SmartInitializingSingleton {
if
(
managementPort
==
ManagementServerPort
.
DIFFERENT
if
(
managementPort
==
ManagementServerPort
.
DIFFERENT
&&
this
.
applicationContext
instanceof
EmbeddedWebApplicationContext
&&
this
.
applicationContext
instanceof
EmbeddedWebApplicationContext
&&
((
EmbeddedWebApplicationContext
)
this
.
applicationContext
)
&&
((
EmbeddedWebApplicationContext
)
this
.
applicationContext
)
.
getEmbeddedServletContainer
()
!=
null
)
{
.
getEmbeddedServletContainer
()
!=
null
)
{
createChildManagementContext
();
createChildManagementContext
();
}
}
if
(
managementPort
==
ManagementServerPort
.
SAME
if
(
managementPort
==
ManagementServerPort
.
SAME
...
@@ -139,7 +139,7 @@ SmartInitializingSingleton {
...
@@ -139,7 +139,7 @@ SmartInitializingSingleton {
EmbeddedServletContainerAutoConfiguration
.
class
,
EmbeddedServletContainerAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
);
DispatcherServletAutoConfiguration
.
class
);
CloseEventPropagationListener
CloseEventPropagationListener
.
addIfPossible
(
this
.
applicationContext
,
childContext
);
.
addIfPossible
(
this
.
applicationContext
,
childContext
);
try
{
try
{
childContext
.
refresh
();
childContext
.
refresh
();
managementContextResolver
().
setApplicationContext
(
childContext
);
managementContextResolver
().
setApplicationContext
(
childContext
);
...
@@ -205,7 +205,7 @@ SmartInitializingSingleton {
...
@@ -205,7 +205,7 @@ SmartInitializingSingleton {
@Override
@Override
protected
void
doFilterInternal
(
HttpServletRequest
request
,
protected
void
doFilterInternal
(
HttpServletRequest
request
,
HttpServletResponse
response
,
FilterChain
filterChain
)
HttpServletResponse
response
,
FilterChain
filterChain
)
throws
ServletException
,
IOException
{
throws
ServletException
,
IOException
{
if
(
this
.
properties
==
null
)
{
if
(
this
.
properties
==
null
)
{
this
.
properties
=
this
.
applicationContext
this
.
properties
=
this
.
applicationContext
.
getBean
(
ManagementServerProperties
.
class
);
.
getBean
(
ManagementServerProperties
.
class
);
...
@@ -224,7 +224,7 @@ SmartInitializingSingleton {
...
@@ -224,7 +224,7 @@ SmartInitializingSingleton {
* parent to a child.
* parent to a child.
*/
*/
private
static
class
CloseEventPropagationListener
implements
private
static
class
CloseEventPropagationListener
implements
ApplicationListener
<
ContextClosedEvent
>
{
ApplicationListener
<
ContextClosedEvent
>
{
private
final
ApplicationContext
parentContext
;
private
final
ApplicationContext
parentContext
;
...
@@ -289,7 +289,7 @@ SmartInitializingSingleton {
...
@@ -289,7 +289,7 @@ SmartInitializingSingleton {
return
((
port
==
null
)
return
((
port
==
null
)
||
(
serverProperties
.
getPort
()
==
null
&&
port
.
equals
(
8080
))
||
(
serverProperties
.
getPort
()
==
null
&&
port
.
equals
(
8080
))
||
(
port
!=
0
&&
port
.
equals
(
serverProperties
.
getPort
()))
?
SAME
||
(
port
!=
0
&&
port
.
equals
(
serverProperties
.
getPort
()))
?
SAME
:
DIFFERENT
);
:
DIFFERENT
);
}
}
}
}
...
@@ -329,9 +329,11 @@ SmartInitializingSingleton {
...
@@ -329,9 +329,11 @@ SmartInitializingSingleton {
if
((
managementPort
==
null
)
if
((
managementPort
==
null
)
||
(
serverPort
==
null
&&
managementPort
.
equals
(
8080
))
||
(
serverPort
==
null
&&
managementPort
.
equals
(
8080
))
||
(
managementPort
!=
0
&&
managementPort
.
equals
(
serverPort
)))
{
||
(
managementPort
!=
0
&&
managementPort
.
equals
(
serverPort
)))
{
return
ConditionOutcome
.
match
(
"The main context is the management context"
);
return
ConditionOutcome
.
match
(
"The main context is the management context"
);
}
}
return
ConditionOutcome
.
noMatch
(
"The main context is not the management context"
);
return
ConditionOutcome
.
noMatch
(
"The main context is not the management context"
);
}
}
private
<
T
>
T
getBeanCarefully
(
ConditionContext
context
,
Class
<
T
>
type
)
{
private
<
T
>
T
getBeanCarefully
(
ConditionContext
context
,
Class
<
T
>
type
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WelcomePageMockMvcTests.java
View file @
d61c3816
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
...
@@ -39,6 +36,9 @@ import org.springframework.test.web.servlet.MockMvc;
...
@@ -39,6 +36,9 @@ import org.springframework.test.web.servlet.MockMvc;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.ConfigurableWebApplicationContext
;
import
org.springframework.web.context.ConfigurableWebApplicationContext
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
/**
/**
* Tests for welcome page using {@link MockMvc} and {@link SpringJUnit4ClassRunner}.
* Tests for welcome page using {@link MockMvc} and {@link SpringJUnit4ClassRunner}.
*
*
...
@@ -69,7 +69,7 @@ public class WelcomePageMockMvcTests {
...
@@ -69,7 +69,7 @@ public class WelcomePageMockMvcTests {
public
void
homePageCustomLocation
()
throws
Exception
{
public
void
homePageCustomLocation
()
throws
Exception
{
this
.
wac
=
(
ConfigurableWebApplicationContext
)
new
SpringApplicationBuilder
(
this
.
wac
=
(
ConfigurableWebApplicationContext
)
new
SpringApplicationBuilder
(
TestConfiguration
.
class
).
properties
(
TestConfiguration
.
class
).
properties
(
"spring.resources.staticLocations:classpath:/custom/"
).
run
();
"spring.resources.staticLocations:classpath:/custom/"
).
run
();
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
this
.
mockMvc
.
perform
(
get
(
"/"
)).
andExpect
(
status
().
isOk
()).
andReturn
();
this
.
mockMvc
.
perform
(
get
(
"/"
)).
andExpect
(
status
().
isOk
()).
andReturn
();
}
}
...
@@ -78,7 +78,7 @@ public class WelcomePageMockMvcTests {
...
@@ -78,7 +78,7 @@ public class WelcomePageMockMvcTests {
public
void
homePageCustomLocationNoTrailingSlash
()
throws
Exception
{
public
void
homePageCustomLocationNoTrailingSlash
()
throws
Exception
{
this
.
wac
=
(
ConfigurableWebApplicationContext
)
new
SpringApplicationBuilder
(
this
.
wac
=
(
ConfigurableWebApplicationContext
)
new
SpringApplicationBuilder
(
TestConfiguration
.
class
).
properties
(
TestConfiguration
.
class
).
properties
(
"spring.resources.staticLocations:classpath:/custom"
).
run
();
"spring.resources.staticLocations:classpath:/custom"
).
run
();
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
this
.
mockMvc
.
perform
(
get
(
"/"
)).
andExpect
(
status
().
isOk
()).
andReturn
();
this
.
mockMvc
.
perform
(
get
(
"/"
)).
andExpect
(
status
().
isOk
()).
andReturn
();
}
}
...
@@ -87,9 +87,9 @@ public class WelcomePageMockMvcTests {
...
@@ -87,9 +87,9 @@ public class WelcomePageMockMvcTests {
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Documented
@Import
({
ServerPropertiesAutoConfiguration
.
class
,
@Import
({
ServerPropertiesAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
ErrorMvcAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
})
ErrorMvcAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
})
protected
static
@interface
MinimalWebConfiguration
{
protected
static
@interface
MinimalWebConfiguration
{
}
}
...
...
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