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
171c1366
Commit
171c1366
authored
Nov 26, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move shutdown enable flag to the endpoint
parent
cd54e1ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
26 deletions
+19
-26
ShutdownEndpoint.java
...ringframework/boot/actuate/endpoint/ShutdownEndpoint.java
+15
-6
ManagementServerProperties.java
...k/boot/actuate/properties/ManagementServerProperties.java
+0
-10
ShutdownEndpointTests.java
...ramework/boot/actuate/endpoint/ShutdownEndpointTests.java
+4
-10
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ShutdownEndpoint.java
View file @
171c1366
...
@@ -20,8 +20,6 @@ import java.util.Collections;
...
@@ -20,8 +20,6 @@ import java.util.Collections;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.properties.ManagementServerProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationContextAware
;
...
@@ -40,8 +38,7 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
...
@@ -40,8 +38,7 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
private
ConfigurableApplicationContext
context
;
private
ConfigurableApplicationContext
context
;
@Autowired
(
required
=
false
)
private
boolean
enabled
=
false
;
private
ManagementServerProperties
configuration
=
new
ManagementServerProperties
();
/**
/**
* Create a new {@link ShutdownEndpoint} instance.
* Create a new {@link ShutdownEndpoint} instance.
...
@@ -52,12 +49,17 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
...
@@ -52,12 +49,17 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
@Override
@Override
public
Map
<
String
,
Object
>
invoke
()
{
public
Map
<
String
,
Object
>
invoke
()
{
if
(
this
.
configuration
==
null
||
!
this
.
configuration
.
isAllowShutdown
()
||
this
.
context
==
null
)
{
if
(!
this
.
enabled
)
{
return
Collections
.<
String
,
Object
>
singletonMap
(
"message"
,
return
Collections
.<
String
,
Object
>
singletonMap
(
"message"
,
"Shutdown not enabled, sorry."
);
"Shutdown not enabled, sorry."
);
}
}
if
(
this
.
context
==
null
)
{
return
Collections
.<
String
,
Object
>
singletonMap
(
"message"
,
"No context to shutdown."
);
}
new
Thread
(
new
Runnable
()
{
new
Thread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -87,4 +89,11 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
...
@@ -87,4 +89,11 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> impl
return
POST_HTTP_METHOD
;
return
POST_HTTP_METHOD
;
}
}
public
boolean
isEnabled
()
{
return
this
.
enabled
;
}
public
void
setEnabled
(
boolean
enabled
)
{
this
.
enabled
=
enabled
;
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/properties/ManagementServerProperties.java
View file @
171c1366
...
@@ -42,18 +42,8 @@ public class ManagementServerProperties implements SecurityPrequisite {
...
@@ -42,18 +42,8 @@ public class ManagementServerProperties implements SecurityPrequisite {
@NotNull
@NotNull
private
String
contextPath
=
""
;
private
String
contextPath
=
""
;
private
boolean
allowShutdown
=
false
;
private
Security
security
=
maybeCreateSecurity
();
private
Security
security
=
maybeCreateSecurity
();
public
boolean
isAllowShutdown
()
{
return
this
.
allowShutdown
;
}
public
void
setAllowShutdown
(
boolean
allowShutdown
)
{
this
.
allowShutdown
=
allowShutdown
;
}
/**
/**
* Returns the management port or {@code null} if the
* Returns the management port or {@code null} if the
* {@link ServerProperties#getPort() server port} should be used.
* {@link ServerProperties#getPort() server port} should be used.
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/ShutdownEndpointTests.java
View file @
171c1366
...
@@ -17,8 +17,6 @@
...
@@ -17,8 +17,6 @@
package
org
.
springframework
.
boot
.
actuate
.
endpoint
;
package
org
.
springframework
.
boot
.
actuate
.
endpoint
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.endpoint.ShutdownEndpoint
;
import
org.springframework.boot.actuate.properties.ManagementServerProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -32,6 +30,7 @@ import static org.junit.Assert.assertTrue;
...
@@ -32,6 +30,7 @@ import static org.junit.Assert.assertTrue;
* Tests for {@link ShutdownEndpoint}.
* Tests for {@link ShutdownEndpoint}.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
*/
*/
public
class
ShutdownEndpointTests
extends
AbstractEndpointTests
<
ShutdownEndpoint
>
{
public
class
ShutdownEndpointTests
extends
AbstractEndpointTests
<
ShutdownEndpoint
>
{
...
@@ -53,16 +52,11 @@ public class ShutdownEndpointTests extends AbstractEndpointTests<ShutdownEndpoin
...
@@ -53,16 +52,11 @@ public class ShutdownEndpointTests extends AbstractEndpointTests<ShutdownEndpoin
@EnableConfigurationProperties
@EnableConfigurationProperties
public
static
class
Config
{
public
static
class
Config
{
@Bean
public
ManagementServerProperties
managementServerProperties
()
{
ManagementServerProperties
properties
=
new
ManagementServerProperties
();
properties
.
setAllowShutdown
(
true
);
return
properties
;
}
@Bean
@Bean
public
ShutdownEndpoint
endpoint
()
{
public
ShutdownEndpoint
endpoint
()
{
return
new
ShutdownEndpoint
();
ShutdownEndpoint
endpoint
=
new
ShutdownEndpoint
();
endpoint
.
setEnabled
(
true
);
return
endpoint
;
}
}
}
}
...
...
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