类 ApplicationPidFileWriter
java.lang.Object
org.springframework.boot.context.ApplicationPidFileWriter
- 所有已实现的接口:
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
.
- 从以下版本开始:
- 2.0.0
- 作者:
- Jakub Kubrynski, Dave Syer, Phillip Webb, Tomasz Przybyla, Madhura Bhave
-
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
构造器概要
构造器构造器说明Create a newApplicationPidFileWriter
instance using the filename 'application.pid'.ApplicationPidFileWriter
(File file) Create a newApplicationPidFileWriter
instance with a specified file.ApplicationPidFileWriter
(String filename) Create a newApplicationPidFileWriter
instance with a specified filename. -
方法概要
修饰符和类型方法说明int
getOrder()
void
protected static void
reset()
Reset the created flag for testing purposes.void
setOrder
(int order) void
setTriggerEventType
(Class<? extends SpringApplicationEvent> triggerEventType) Sets the type of application event that will trigger writing of the PID file.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.context.ApplicationListener
supportsAsyncExecution
-
构造器详细资料
-
ApplicationPidFileWriter
public ApplicationPidFileWriter()Create a newApplicationPidFileWriter
instance using the filename 'application.pid'. -
ApplicationPidFileWriter
Create a newApplicationPidFileWriter
instance with a specified filename.- 参数:
filename
- the name of file containing pid
-
ApplicationPidFileWriter
Create a newApplicationPidFileWriter
instance with a specified file.- 参数:
file
- the file containing pid
-
-
方法详细资料
-
setTriggerEventType
Sets the type of application event that will trigger writing of the PID file. Defaults toApplicationPreparedEvent
. NOTE: If you use theApplicationStartingEvent
to trigger the write, you will not be able to specify the PID filename in the SpringEnvironment
.- 参数:
triggerEventType
- the trigger event type
-
onApplicationEvent
-
setOrder
public void setOrder(int order) -
getOrder
public int getOrder() -
reset
protected static void reset()Reset the created flag for testing purposes.
-