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
2f4b89d1
Commit
2f4b89d1
authored
Oct 01, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
04c2e25a
c3d1241e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
ApplicationPidListener.java
...framework/boot/actuate/system/ApplicationPidListener.java
+9
-4
ApplicationPidListenerTests.java
...work/boot/actuate/system/ApplicationPidListenerTests.java
+12
-2
ApplicationStartedEvent.java
...framework/boot/context/event/ApplicationStartedEvent.java
+1
-1
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/ApplicationPidListener.java
View file @
2f4b89d1
...
...
@@ -26,10 +26,13 @@ import org.springframework.boot.context.event.ApplicationStartedEvent;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.core.Ordered
;
import
org.springframework.util.Assert
;
import
org.springframework.util.SystemPropertyUtils
;
/**
* An {@link org.springframework.context.ApplicationListener} that saves application PID
* into file. This application listener will be triggered exactly once per JVM.
* into file. This application listener will be triggered exactly once per JVM, and the file
* name can be overridden at runtime with a System property or environment variable named
* "PIDFILE" (or "pidfile").
*
* @author Jakub Kubrynski
* @author Dave Syer
...
...
@@ -62,8 +65,7 @@ public class ApplicationPidListener implements
* @param filename the name of file containing pid
*/
public
ApplicationPidListener
(
String
filename
)
{
Assert
.
notNull
(
filename
,
"Filename must not be null"
);
this
.
file
=
new
File
(
filename
);
this
(
new
File
(
filename
));
}
/**
...
...
@@ -72,7 +74,10 @@ public class ApplicationPidListener implements
*/
public
ApplicationPidListener
(
File
file
)
{
Assert
.
notNull
(
file
,
"File must not be null"
);
this
.
file
=
file
;
String
actual
=
SystemPropertyUtils
.
resolvePlaceholders
(
"${PIDFILE}"
,
true
);
actual
=
!
actual
.
contains
(
"$"
)
?
actual
:
SystemPropertyUtils
.
resolvePlaceholders
(
"${pidfile}"
,
true
);
actual
=
!
actual
.
contains
(
"$"
)
?
actual
:
file
.
getAbsolutePath
();
this
.
file
=
new
File
(
actual
);
}
@Override
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/ApplicationPidListenerTest.java
→
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/ApplicationPidListenerTest
s
.java
View file @
2f4b89d1
...
...
@@ -33,12 +33,12 @@ import static org.hamcrest.Matchers.not;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Tests f
p
r {@link ApplicationPidListener}.
* Tests f
o
r {@link ApplicationPidListener}.
*
* @author Jakub Kubrynski
* @author Dave Syer
*/
public
class
ApplicationPidListenerTest
{
public
class
ApplicationPidListenerTest
s
{
private
static
final
ApplicationStartedEvent
EVENT
=
new
ApplicationStartedEvent
(
new
SpringApplication
(),
new
String
[]
{});
...
...
@@ -49,6 +49,7 @@ public class ApplicationPidListenerTest {
@Before
@After
public
void
resetListener
()
{
System
.
clearProperty
(
"PIDFILE"
);
ApplicationPidListener
.
reset
();
}
...
...
@@ -60,4 +61,13 @@ public class ApplicationPidListenerTest {
assertThat
(
FileCopyUtils
.
copyToString
(
new
FileReader
(
file
)),
not
(
isEmptyString
()));
}
@Test
public
void
overridePidFile
()
throws
Exception
{
File
file
=
this
.
temporaryFolder
.
newFile
();
System
.
setProperty
(
"PIDFILE"
,
this
.
temporaryFolder
.
newFile
().
getAbsolutePath
());
ApplicationPidListener
listener
=
new
ApplicationPidListener
(
file
);
listener
.
onApplicationEvent
(
EVENT
);
assertThat
(
FileCopyUtils
.
copyToString
(
new
FileReader
(
System
.
getProperty
(
"PIDFILE"
))),
not
(
isEmptyString
()));
}
}
spring-boot/src/main/java/org/springframework/boot/context/event/ApplicationStartedEvent.java
View file @
2f4b89d1
...
...
@@ -34,7 +34,7 @@ public class ApplicationStartedEvent extends SpringApplicationEvent {
/**
* @param application the current application
* @param args the argume
m
ts the application is running with
* @param args the argume
n
ts the application is running with
*/
public
ApplicationStartedEvent
(
SpringApplication
application
,
String
[]
args
)
{
super
(
application
,
args
);
...
...
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