Package org.springframework.boot.context
Class ApplicationPidFileWriter
java.lang.Object
org.springframework.boot.context.ApplicationPidFileWriter
- All Implemented Interfaces:
- EventListener,- ApplicationListener<SpringApplicationEvent>,- Ordered
public class ApplicationPidFileWriter
extends Object
implements ApplicationListener<SpringApplicationEvent>, Ordered
An 
ApplicationListener that saves application PID 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")
 or using a spring.pid.file property in the Spring Environment.
 
 If PID file can not be created no exception is reported. This behavior can be changed
 by assigning true to System property or environment variable named
 PID_FAIL_ON_WRITE_ERROR (or "pid_fail_on_write_error") or to
 spring.pid.fail-on-write-error property in the Spring Environment.
 
 Note: access to the Spring Environment is only possible when the
 triggerEventType is set to
 ApplicationEnvironmentPreparedEvent, ApplicationReadyEvent, or
 ApplicationPreparedEvent.
- Since:
- 2.0.0
- Author:
- Jakub Kubrynski, Dave Syer, Phillip Webb, Tomasz Przybyla, Madhura Bhave
- 
Field SummaryFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newApplicationPidFileWriterinstance using the filename 'application.pid'.ApplicationPidFileWriter(File file) Create a newApplicationPidFileWriterinstance with a specified file.ApplicationPidFileWriter(String filename) Create a newApplicationPidFileWriterinstance with a specified filename.
- 
Method SummaryModifier and TypeMethodDescriptionintgetOrder()voidprotected static voidreset()Reset the created flag for testing purposes.voidsetOrder(int order) voidsetTriggerEventType(Class<? extends SpringApplicationEvent> triggerEventType) Sets the type of application event that will trigger writing of the PID file.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListenersupportsAsyncExecution
- 
Constructor Details- 
ApplicationPidFileWriterpublic ApplicationPidFileWriter()Create a newApplicationPidFileWriterinstance using the filename 'application.pid'.
- 
ApplicationPidFileWriterCreate a newApplicationPidFileWriterinstance with a specified filename.- Parameters:
- filename- the name of file containing pid
 
- 
ApplicationPidFileWriterCreate a newApplicationPidFileWriterinstance with a specified file.- Parameters:
- file- the file containing pid
 
 
- 
- 
Method Details- 
setTriggerEventTypeSets the type of application event that will trigger writing of the PID file. Defaults toApplicationPreparedEvent. NOTE: If you use theApplicationStartingEventto trigger the write, you will not be able to specify the PID filename in the SpringEnvironment.- Parameters:
- triggerEventType- the trigger event type
 
- 
onApplicationEvent- Specified by:
- onApplicationEventin interface- ApplicationListener<SpringApplicationEvent>
 
- 
setOrderpublic void setOrder(int order) 
- 
getOrderpublic int getOrder()
- 
resetprotected static void reset()Reset the created flag for testing purposes.
 
-