Enum Class CloudPlatform

java.lang.Object
java.lang.Enum<CloudPlatform>
org.springframework.boot.cloud.CloudPlatform
All Implemented Interfaces:
Serializable, Comparable<CloudPlatform>, Constable

public enum CloudPlatform extends Enum<CloudPlatform>
Simple detection for well known cloud platforms. Detection can be forced using the "spring.main.cloud-platform" configuration property.
Since:
1.3.0
Author:
Phillip Webb, Brian Clozel, Nguyen Sach
  • Enum Constant Details

    • NONE

      public static final CloudPlatform NONE
      No Cloud platform. Useful when false-positives are detected.
    • CLOUD_FOUNDRY

      public static final CloudPlatform CLOUD_FOUNDRY
      Cloud Foundry platform.
    • HEROKU

      public static final CloudPlatform HEROKU
      Heroku platform.
    • SAP

      public static final CloudPlatform SAP
      SAP Cloud platform.
    • NOMAD

      public static final CloudPlatform NOMAD
      Nomad platform.
      Since:
      3.1.0
    • KUBERNETES

      public static final CloudPlatform KUBERNETES
      Kubernetes platform.
    • AZURE_APP_SERVICE

      public static final CloudPlatform AZURE_APP_SERVICE
      Azure App Service platform.
  • Method Details

    • values

      public static CloudPlatform[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CloudPlatform valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isActive

      public boolean isActive(Environment environment)
      Determines if the platform is active (i.e. the application is running in it).
      Parameters:
      environment - the environment
      Returns:
      if the platform is active.
    • isEnforced

      public boolean isEnforced(Environment environment)
      Determines if the platform is enforced by looking at the "spring.main.cloud-platform" configuration property.
      Parameters:
      environment - the environment
      Returns:
      if the platform is enforced
      Since:
      2.3.0
    • isEnforced

      public boolean isEnforced(Binder binder)
      Determines if the platform is enforced by looking at the "spring.main.cloud-platform" configuration property.
      Parameters:
      binder - the binder
      Returns:
      if the platform is enforced
      Since:
      2.4.0
    • isDetected

      public abstract boolean isDetected(Environment environment)
      Determines if the platform is detected by looking for platform-specific environment variables.
      Parameters:
      environment - the environment
      Returns:
      if the platform is auto-detected.
      Since:
      2.3.0
    • isUsingForwardHeaders

      public boolean isUsingForwardHeaders()
      Returns if the platform is behind a load balancer and uses X-Forwarded-For headers.
      Returns:
      if X-Forwarded-For headers are used
    • getActive

      public static CloudPlatform getActive(Environment environment)
      Returns the active CloudPlatform or null if one is not active.
      Parameters:
      environment - the environment
      Returns:
      the CloudPlatform or null