Class WebServerPortFileWriter
java.lang.Object
org.springframework.boot.web.context.WebServerPortFileWriter
- All Implemented Interfaces:
- EventListener,- ApplicationListener<WebServerInitializedEvent>
public class WebServerPortFileWriter
extends Object
implements ApplicationListener<WebServerInitializedEvent>
An 
ApplicationListener that saves embedded server port and management port into
 file. This application listener will be triggered whenever the server starts, and the
 file name can be overridden at runtime with a System property or environment variable
 named "PORTFILE" or "portfile".- Since:
- 2.0.0
- Author:
- David Liu, Phillip Webb, Andy Wilkinson
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newWebServerPortFileWriterinstance using the filename 'application.port'.WebServerPortFileWriter(File file) Create a newWebServerPortFileWriterinstance with a specified file.WebServerPortFileWriter(String filename) Create a newWebServerPortFileWriterinstance with a specified filename.
- 
Method SummaryModifier and TypeMethodDescriptionprotected FilegetPortFile(ApplicationContext applicationContext) Return the actual port file that should be written for the given application context.voidMethods 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- 
WebServerPortFileWriterpublic WebServerPortFileWriter()Create a newWebServerPortFileWriterinstance using the filename 'application.port'.
- 
WebServerPortFileWriterCreate a newWebServerPortFileWriterinstance with a specified filename.- Parameters:
- filename- the name of file containing port
 
- 
WebServerPortFileWriterCreate a newWebServerPortFileWriterinstance with a specified file.- Parameters:
- file- the file containing port
 
 
- 
- 
Method Details- 
onApplicationEvent- Specified by:
- onApplicationEventin interface- ApplicationListener<WebServerInitializedEvent>
 
- 
getPortFileReturn the actual port file that should be written for the given application context. The default implementation builds a file from the source file and the application context namespace if available.- Parameters:
- applicationContext- the source application context
- Returns:
- the file that should be written
 
 
-