org.springframework.boot.cloud

Enum CloudPlatform

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


    public enum CloudPlatform
    extends java.lang.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
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      static CloudPlatform getActive(org.springframework.core.env.Environment environment)
      Returns the active CloudPlatform or null if one is not active.
      boolean isActive(org.springframework.core.env.Environment environment)
      Determines if the platform is active (i.e.
      abstract boolean isDetected(org.springframework.core.env.Environment environment)
      Determines if the platform is detected by looking for platform-specific environment variables.
      boolean isEnforced(Binder binder)
      Determines if the platform is enforced by looking at the "spring.main.cloud-platform" configuration property.
      boolean isEnforced(org.springframework.core.env.Environment environment)
      Determines if the platform is enforced by looking at the "spring.main.cloud-platform" configuration property.
      boolean isUsingForwardHeaders()
      Returns if the platform is behind a load balancer and uses X-Forwarded-For headers.
      static CloudPlatform valueOf(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CloudPlatform[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • 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.
      • KUBERNETES

        public static final CloudPlatform KUBERNETES
        Kubernetes platform.
      • AZURE_APP_SERVICE

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

      • values

        public static CloudPlatform[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CloudPlatform c : CloudPlatform.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CloudPlatform valueOf(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isActive

        public boolean isActive(org.springframework.core.env.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(org.springframework.core.env.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(org.springframework.core.env.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(org.springframework.core.env.Environment environment)
        Returns the active CloudPlatform or null if one is not active.
        Parameters:
        environment - the environment
        Returns:
        the CloudPlatform or null