Package io.jmix.core

Class ApplicationInfoProvider

java.lang.Object
io.jmix.core.ApplicationInfoProvider

@Component("core_ApplicationInfoProvider") @ConditionalOnClass(org.springframework.boot.web.server.context.WebServerApplicationContext.class) public class ApplicationInfoProvider extends Object
Provides information about the running application (host, port, active profiles, etc.) and stores it to the app-info.json file in the conf directory for development tools.

The file is created on application startup and removed on shutdown. It is not created if the JVM is bootstrapped by a test framework, because tests may run from the same directory as a normally running application instance and must not affect its file. On shutdown, the file is removed only if it still belongs to this application instance.

  • Field Details

    • APP_INFO_DIR_NAME

      protected static final String APP_INFO_DIR_NAME
      See Also:
    • APP_INFO_FILE_NAME

      protected static final String APP_INFO_FILE_NAME
      See Also:
    • INSTANCE_ID_PROPERTY

      protected static final String INSTANCE_ID_PROPERTY
      See Also:
    • TEST_LAUNCHER_STACK_PREFIXES

      protected static final List<String> TEST_LAUNCHER_STACK_PREFIXES
      Stack trace prefixes of test framework launchers. Same approach as in Spring Boot DevTools (DevToolsEnablementDeducer): if the application is bootstrapped by a test framework, the application info file must not be created or removed, because such a JVM may share the conf directory with a normally running application instance.
    • environment

      @Autowired protected org.springframework.core.env.Environment environment
    • coreProperties

      @Autowired protected CoreProperties coreProperties
    • instanceId

      protected String instanceId
    • host

      protected String host
    • port

      protected int port
    • contextPath

      protected String contextPath
    • protocol

      protected String protocol
    • fullUrl

      protected String fullUrl
    • activeProfiles

      protected List<String> activeProfiles
    • startupTime

      protected OffsetDateTime startupTime
  • Constructor Details

    • ApplicationInfoProvider

      public ApplicationInfoProvider()
  • Method Details

    • onApplicationReady

      @EventListener public void onApplicationReady(org.springframework.boot.context.event.ApplicationReadyEvent event)
    • getHost

      public String getHost()
    • getPort

      public int getPort()
    • getContextPath

      public String getContextPath()
    • getProtocol

      public String getProtocol()
    • getFullUrl

      public String getFullUrl()
    • getActiveProfiles

      public List<String> getActiveProfiles()
    • getStartupTime

      public OffsetDateTime getStartupTime()
    • initValues

      protected void initValues(org.springframework.context.ConfigurableApplicationContext context)
    • resolveProtocol

      protected String resolveProtocol()
    • resolveHost

      protected String resolveHost()
    • resolvePort

      protected int resolvePort(org.springframework.context.ConfigurableApplicationContext context)
    • resolveContextPath

      protected String resolveContextPath()
    • resolveActiveProfiles

      protected List<String> resolveActiveProfiles()
    • resolveFullUrl

      protected String resolveFullUrl(String protocol, String host, int port, String contextPath)
    • createAppInfoFile

      protected void createAppInfoFile()
    • createJson

      protected com.google.gson.JsonObject createJson()
    • writeFile

      protected boolean writeFile(Path fileLocation, com.google.gson.JsonObject json)
    • resolveAppInfoFileLocation

      protected Path resolveAppInfoFileLocation()
    • createActiveProfilesJsonArray

      protected com.google.gson.JsonArray createActiveProfilesJsonArray()
    • shutdownHookOperation

      protected void shutdownHookOperation()
    • removeAppInfoFile

      protected void removeAppInfoFile()
    • isOwnAppInfoFile

      protected boolean isOwnAppInfoFile(Path fileLocation)
      Checks that the file was created by this application instance. The file may have been overwritten by another instance launched from the same directory, then it must not be removed on shutdown.
    • registerShutdownHook

      protected void registerShutdownHook()
    • isLaunchedFromTest

      protected boolean isLaunchedFromTest()
      Detects that the JVM was bootstrapped by a test framework by inspecting the current thread's stack trace.