org.springframework.boot.system

Class EmbeddedServerPortFileWriter

  • All Implemented Interfaces:
    EventListener, org.springframework.context.ApplicationListener<EmbeddedServletContainerInitializedEvent>


    public class EmbeddedServerPortFileWriter
    extends Object
    implements org.springframework.context.ApplicationListener<EmbeddedServletContainerInitializedEvent>
    An ApplicationListener that saves embedded server port and management port into file. This application listener will be triggered whenever the servlet container starts, and the file name can be overridden at runtime with a System property or environment variable named "PORTFILE" or "portfile".
    Since:
    1.4.0
    Author:
    David Liu, Phillip Webb, Andy Wilkinson
    • Constructor Detail

      • EmbeddedServerPortFileWriter

        public EmbeddedServerPortFileWriter()
        Create a new EmbeddedServerPortFileWriter instance using the filename 'application.port'.
      • EmbeddedServerPortFileWriter

        public EmbeddedServerPortFileWriter(String filename)
        Create a new EmbeddedServerPortFileWriter instance with a specified filename.
        Parameters:
        filename - the name of file containing port
      • EmbeddedServerPortFileWriter

        public EmbeddedServerPortFileWriter(File file)
        Create a new EmbeddedServerPortFileWriter instance with a specified file.
        Parameters:
        file - the file containing port
    • Method Detail

      • getPortFile

        protected File getPortFile(EmbeddedWebApplicationContext applicationContext)
        Return 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.
        Parameters:
        applicationContext - the source application context
        Returns:
        the file that should be written

Copyright © 2018 Pivotal Software, Inc.. All rights reserved.