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
5d311d62
Commit
5d311d62
authored
Dec 17, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
ec2064d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
EndpointWebMvcAutoConfiguration.java
...ctuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
+15
-10
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
View file @
5d311d62
...
@@ -315,16 +315,15 @@ public class EndpointWebMvcAutoConfiguration
...
@@ -315,16 +315,15 @@ public class EndpointWebMvcAutoConfiguration
Integer
serverPort
=
getPortProperty
(
environment
,
"server."
);
Integer
serverPort
=
getPortProperty
(
environment
,
"server."
);
if
(
serverPort
==
null
&&
hasCustomBeanDefinition
(
beanFactory
,
if
(
serverPort
==
null
&&
hasCustomBeanDefinition
(
beanFactory
,
ServerProperties
.
class
,
ServerPropertiesAutoConfiguration
.
class
))
{
ServerProperties
.
class
,
ServerPropertiesAutoConfiguration
.
class
))
{
ServerProperties
bean
=
getBean
(
beanFactory
,
ServerProperties
.
class
);
serverPort
=
getTemporaryBean
(
beanFactory
,
ServerProperties
.
class
)
serverPort
=
bean
.
getPort
();
.
getPort
();
}
}
Integer
managementPort
=
getPortProperty
(
environment
,
"management."
);
Integer
managementPort
=
getPortProperty
(
environment
,
"management."
);
if
(
managementPort
==
null
&&
hasCustomBeanDefinition
(
beanFactory
,
if
(
managementPort
==
null
&&
hasCustomBeanDefinition
(
beanFactory
,
ManagementServerProperties
.
class
,
ManagementServerProperties
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
))
{
ManagementServerPropertiesAutoConfiguration
.
class
))
{
ManagementServerProperties
bean
=
getBean
(
beanFactory
,
managementPort
=
getTemporaryBean
(
beanFactory
,
ManagementServerProperties
.
class
);
ManagementServerProperties
.
class
).
getPort
();
managementPort
=
bean
.
getPort
();
}
}
if
(
managementPort
!=
null
&&
managementPort
<
0
)
{
if
(
managementPort
!=
null
&&
managementPort
<
0
)
{
return
DISABLE
;
return
DISABLE
;
...
@@ -335,7 +334,7 @@ public class EndpointWebMvcAutoConfiguration
...
@@ -335,7 +334,7 @@ public class EndpointWebMvcAutoConfiguration
:
DIFFERENT
);
:
DIFFERENT
);
}
}
private
static
<
T
>
T
getBean
(
BeanFactory
beanFactory
,
Class
<
T
>
type
)
{
private
static
<
T
>
T
get
Temporary
Bean
(
BeanFactory
beanFactory
,
Class
<
T
>
type
)
{
if
(!(
beanFactory
instanceof
ConfigurableListableBeanFactory
))
{
if
(!(
beanFactory
instanceof
ConfigurableListableBeanFactory
))
{
return
null
;
return
null
;
}
}
...
@@ -346,10 +345,16 @@ public class EndpointWebMvcAutoConfiguration
...
@@ -346,10 +345,16 @@ public class EndpointWebMvcAutoConfiguration
}
}
// Use a temporary child bean factory to avoid instantiating the bean in the
// Use a temporary child bean factory to avoid instantiating the bean in the
// parent (it won't be bound to the environment yet)
// parent (it won't be bound to the environment yet)
BeanDefinition
definition
=
listable
.
getBeanDefinition
(
names
[
0
]);
return
createTemporaryBean
(
type
,
listable
,
DefaultListableBeanFactory
temp
=
new
DefaultListableBeanFactory
(
listable
);
listable
.
getBeanDefinition
(
names
[
0
]));
temp
.
registerBeanDefinition
(
type
.
getName
(),
definition
);
}
return
temp
.
getBean
(
type
);
private
static
<
T
>
T
createTemporaryBean
(
Class
<
T
>
type
,
ConfigurableListableBeanFactory
parent
,
BeanDefinition
definition
)
{
DefaultListableBeanFactory
beanFactory
=
new
DefaultListableBeanFactory
(
parent
);
beanFactory
.
registerBeanDefinition
(
type
.
getName
(),
definition
);
return
beanFactory
.
getBean
(
type
);
}
}
private
static
Integer
getPortProperty
(
Environment
environment
,
String
prefix
)
{
private
static
Integer
getPortProperty
(
Environment
environment
,
String
prefix
)
{
...
...
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