Environment (Grails 6.0.0)

Package: grails.util

## [Groovy] Enum Environment

- grails.util.Environment

-     @groovy.transform.CompileStatic
      final enum Environment
      extends java.lang.Enum<E<E>>

  Represents the current environment.

  Authors:
    Graeme Rocher
  Since:
    1.1

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static Environment[]` | `$VALUES` |
    `static Environment` | `APPLICATION` | For the application data source, primarily for backward compatibility for those applications that use ApplicationDataSource.groovy.
    `static Environment` | `CUSTOM` | A custom environment
    `static java.lang.String` | `DEFAULT` | Constants that indicates whether this GrailsApplication is running in the default environment
    `static Environment` | `DEVELOPMENT` | The development environment
    `private static java.lang.String` | `DEVELOPMENT_ENVIRONMENT_SHORT_NAME` |
    `private static boolean` | `DEVELOPMENT_MODE` |
    `static java.lang.String` | `ENV_GRAILS_HOME` | The name of the GRAILS_HOME environment variable
    `static java.lang.String` | `ENV_KEY` | Constant used to resolve the environment via System.getenv(Environment.ENV_KEY).
    `static java.lang.String` | `FULL_STACKTRACE` | Whether the display of full stack traces is needed
    `private static java.lang.String` | `GRAILS_IMPLEMENTATION_TITLE` |
    `private static java.lang.String` | `GRAILS_VERSION` |
    `static java.lang.String` | `INITIALIZING` | Whether Grails is in the middle of bootstrapping or not
    `static java.lang.String` | `INTERACTIVE_MODE_ENABLED` | Whether interactive mode is enabled
    `static java.lang.String` | `KEY` | Constant used to resolve the environment via System.getProperty(Environment.KEY)
    `private static java.util.function.Supplier<org.slf4j.Logger>` | `LOG` | The development environment
    `static Environment` | `MAX_VALUE` |
    `static Environment` | `MIN_VALUE` |
    `static Environment` | `PRODUCTION` | The production environment
    `private static java.lang.String` | `PRODUCTION_ENV_SHORT_NAME` |
    `private static java.lang.Boolean` | `RELOADING_AGENT_ENABLED` |
    `static java.lang.String` | `RELOAD_ENABLED` | Specify whether reloading is enabled for this environment
    `static java.lang.String` | `RELOAD_LOCATION` | The location where to reload resources from
    `static java.lang.String` | `RUN_ACTIVE` | Constant indicating whether run-app or test-app was executed
    `static java.lang.String` | `STANDALONE` | Whether Grails has been executed standalone via the static void main method and not loaded in via the container
    `private static boolean` | `STANDALONE_DEPLOYED` |
    `static Environment` | `TEST` | The test environment
    `private static java.lang.String` | `TEST_ENVIRONMENT_SHORT_NAME` |
    `private static boolean` | `WAR_DEPLOYED` |
    `private static Holder<Environment>` | `cachedCurrentEnvironment` |
    `static org.codehaus.groovy.control.MultipleCompilationErrorsException` | `currentCompilationError` |
    `static java.lang.Throwable` | `currentReloadError` |
    `private static java.util.Map<java.lang.String, java.lang.String>` | `envNameMappings` |
    `private static boolean` | `initializingState` |
    `private java.lang.String` | `name` |
    `private java.lang.String` | `reloadLocation` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `java.lang.Throwable` | `currentReloadError`
    `boolean` | `initializing`
    `java.lang.String` | `name`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `private Environment ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static void` | `()`
    `` | `private static Environment` | `cacheCurrentEnvironment()`
    `` | `private static EnvironmentBlockEvaluator` | `evaluateEnvironmentSpecificBlock(Environment environment, groovy.lang.Closure<?> closure)`
    `` | `static java.lang.Object` | `executeForCurrentEnvironment(groovy.lang.Closure<?> closure)` Takes an environment specific DSL block like:
    `` | `static java.lang.Object` | `executeForEnvironment(Environment env, groovy.lang.Closure<?> closure)` Takes an environment specific DSL block like:
    `` | `static Environment` | `getCurrent()` Returns the current environment which is typcally either DEVELOPMENT, PRODUCTION or TEST.
    `` | `static org.codehaus.groovy.control.MultipleCompilationErrorsException` | `getCurrentCompilationError()`
    `` | `static Environment` | `getCurrentEnvironment()` See Also: getCurrent()
    `` | `static java.lang.Throwable` | `getCurrentReloadError()`
    `` | `static Environment` | `getEnvironment(java.lang.String shortName)` Returns the environment for the given short name
    `` | `private static java.lang.String` | `getEnvironmentInternal()`
    `` | `static groovy.lang.Closure<?>` | `getEnvironmentSpecificBlock(groovy.lang.Closure<?> closure)` Takes an environment specific DSL block like:
    `` | `static groovy.lang.Closure<?>` | `getEnvironmentSpecificBlock(Environment env, groovy.lang.Closure<?> closure)` Takes an environment specific DSL block like:
    `` | `static java.lang.String` | `getGrailsVersion()` Returns: The current Grails version
    `` | `java.lang.String` | `getName()` Returns: the name of the environment
    `` | `java.lang.String` | `getReloadLocation()` Returns: Obtains the location to reload resources from
    `` | `private java.lang.String` | `getReloadLocationInternal()`
    `` | `private boolean` | `hasLocation(java.lang.String location)`
    `` | `boolean` | `hasReloadLocation()` Returns: Whether a reload location is specified
    `` | `private void` | `initialize()`
    `` | `private static boolean` | `isBlank(java.lang.String value)`
    `` | `static boolean` | `isDevelopmentEnvironmentAvailable()` This method will return true if the 'grails-app' directory was found, regardless of whether reloading is active or not
    `` | `static boolean` | `isDevelopmentMode()` Returns true if the application is running in development mode (within grails run-app)
    `` | `static boolean` | `isDevelopmentRun()` This method will return true the application is run
    `` | `static boolean` | `isDevtoolsRestart()` Checks if the run of the app is due to spring dev-tools or not.
    `` | `static boolean` | `isFork()` Whether this is a fork of the Grails command line environment
    `` | `static boolean` | `isInitializing()` Returns: Whether interactive mode is enabled
    `` | `static boolean` | `isInteractiveMode()` Returns: Whether interactive mode is enabled
    `` | `boolean` | `isReloadEnabled()` Returns: Returns whether reload is enabled for the environment
    `` | `static boolean` | `isReloadInProgress()`
    `` | `static boolean` | `isReloadingAgentEnabled()` Returns: true if the reloading agent is active
    `` | `static boolean` | `isStandalone()` Whether the application has been executed standalone via static void main.
    `` | `static boolean` | `isStandaloneDeployed()` Whether the application is running standalone within a JAR
    `` | `static boolean` | `isSystemSet()` Returns: Return true if the environment has been set as a System property
    `` | `static boolean` | `isWarDeployed()` Check whether the application is deployed
    `` | `private static boolean` | `isWebPath(java.lang.String path)`
    `` | `static boolean` | `isWithinShell()` Returns whether the environment is running within the Grails shell (executed via the 'grails' command line in a terminal window)
    `` | `Environment` | `next()`
    `` | `Environment` | `previous()`
    `` | `static void` | `reset()` Reset the current environment
    `` | `private static Environment` | `resolveCurrentEnvironment()`
    `` | `static void` | `setCurrentReloadError(java.lang.Throwable currentReloadError)`
    `` | `static void` | `setInitializing(boolean initializing)`
    `` | `void` | `setName(java.lang.String name)` Set the name.
    `` | `static Environment` | `valueOf(java.lang.String name)`
    `` | `static final Environment[]` | `values()`
    `` | `private static void` | `writeDevToolsPidFile(java.io.File pidFile, java.lang.String content)`

- - ### Field Detail

    - #### private static final Environment[] $VALUES

    - #### public static final Environment APPLICATION

      For the application data source, primarily for backward compatibility for those applications that use ApplicationDataSource.groovy.

    - #### public static final Environment CUSTOM

      A custom environment

    - #### public static final java.lang.String DEFAULT

      Constants that indicates whether this GrailsApplication is running in the default environment

    - #### public static final Environment DEVELOPMENT

      The development environment

    - #### private static final java.lang.String DEVELOPMENT_ENVIRONMENT_SHORT_NAME

    - #### private static final boolean DEVELOPMENT_MODE

    - #### public static java.lang.String ENV_GRAILS_HOME

      The name of the GRAILS_HOME environment variable

    - #### public static final java.lang.String ENV_KEY

      Constant used to resolve the environment via System.getenv(Environment.ENV_KEY).

    - #### public static java.lang.String FULL_STACKTRACE

      Whether the display of full stack traces is needed

    - #### private static final java.lang.String GRAILS_IMPLEMENTATION_TITLE

    - #### private static final java.lang.String GRAILS_VERSION

    - #### public static final java.lang.String INITIALIZING

      Whether Grails is in the middle of bootstrapping or not

    - #### public static final java.lang.String INTERACTIVE_MODE_ENABLED

      Whether interactive mode is enabled

    - #### public static java.lang.String KEY

      Constant used to resolve the environment via System.getProperty(Environment.KEY)

    - #### private static final java.util.function.Supplier<org.slf4j.Logger> LOG

      The development environment

    - #### public static final Environment MAX_VALUE

    - #### public static final Environment MIN_VALUE

    - #### public static final Environment PRODUCTION

      The production environment

    - #### private static final java.lang.String PRODUCTION_ENV_SHORT_NAME

    - #### private static java.lang.Boolean RELOADING_AGENT_ENABLED

    - #### public static java.lang.String RELOAD_ENABLED

      Specify whether reloading is enabled for this environment

    - #### public static final java.lang.String RELOAD_LOCATION

      The location where to reload resources from

    - #### public static java.lang.String RUN_ACTIVE

      Constant indicating whether run-app or test-app was executed

    - #### public static final java.lang.String STANDALONE

      Whether Grails has been executed standalone via the static void main method and not loaded in via the container

    - #### private static final boolean STANDALONE_DEPLOYED

    - #### public static final Environment TEST

      The test environment

    - #### private static final java.lang.String TEST_ENVIRONMENT_SHORT_NAME

    - #### private static final boolean WAR_DEPLOYED

    - #### private static Holder<Environment> cachedCurrentEnvironment

    - #### public static org.codehaus.groovy.control.MultipleCompilationErrorsException currentCompilationError

    - #### public static java.lang.Throwable currentReloadError

    - #### @java.lang.SuppressWarnings(value: unchecked) private static java.util.Map<java.lang.String, java.lang.String> envNameMappings

    - #### private static boolean initializingState

    - #### private java.lang.String name

    - #### private java.lang.String reloadLocation

  - ### Property Detail

    - #### java.lang.Throwable currentReloadError

    - #### boolean initializing

    - #### java.lang.String name

  - ### Constructor Detail

    - #### private Environment()

  - ### Method Detail

    - #### static void ()

    - #### private static Environment cacheCurrentEnvironment()

    - #### private static EnvironmentBlockEvaluator evaluateEnvironmentSpecificBlock(Environment environment, groovy.lang.Closure<?> closure)

    - #### static java.lang.Object executeForCurrentEnvironment(groovy.lang.Closure<?> closure)

      Takes an environment specific DSL block like: `environments { development {} production {} }` And executes the closure that relates to the current environment

      Parameters:
        `closure` - The top level closure
      Returns:
        The result of the closure execution

    - #### static java.lang.Object executeForEnvironment(Environment env, groovy.lang.Closure<?> closure)

      Takes an environment specific DSL block like: `environments { development {} production {} }` And executes the closure that relates to the specified environment

      Parameters:
        `env` - The environment to use
        `closure` - The top level closure
      Returns:
        The result of the closure execution

    - #### static Environment getCurrent()

      Returns the current environment which is typcally either DEVELOPMENT, PRODUCTION or TEST. For custom environments CUSTOM type is returned.

      Returns:
        The current environment.

    - #### static org.codehaus.groovy.control.MultipleCompilationErrorsException getCurrentCompilationError()

    - #### static Environment getCurrentEnvironment()

      See Also:
        getCurrent()
      Returns:
        the current environment

    - #### static java.lang.Throwable getCurrentReloadError()

    - #### static Environment getEnvironment(java.lang.String shortName)

      Returns the environment for the given short name

      Parameters:
        `shortName` - The short name
      Returns:
        The Environment or null if not known

    - #### private static java.lang.String getEnvironmentInternal()

    - #### static groovy.lang.Closure<?> getEnvironmentSpecificBlock(groovy.lang.Closure<?> closure)

      Takes an environment specific DSL block like: `environments { development {} production {} }` And returns the closure that relates to the current environment

      Parameters:
        `closure` - The top level closure
      Returns:
        The environment specific block or null if non exists

    - #### static groovy.lang.Closure<?> getEnvironmentSpecificBlock(Environment env, groovy.lang.Closure<?> closure)

      Takes an environment specific DSL block like: `environments { development {} production {} }` And returns the closure that relates to the specified

      Parameters:
        `env` - The environment to use
        `closure` - The top level closure
      Returns:
        The environment specific block or null if non exists

    - #### static java.lang.String getGrailsVersion()

      Returns:
        The current Grails version

    - #### java.lang.String getName()

      Returns:
        the name of the environment

    - #### java.lang.String getReloadLocation()

      Returns:
        Obtains the location to reload resources from

    - #### private java.lang.String getReloadLocationInternal()

    - #### private boolean hasLocation(java.lang.String location)

    - #### boolean hasReloadLocation()

      Returns:
        Whether a reload location is specified

    - #### private void initialize()

    - #### private static boolean isBlank(java.lang.String value)

    - #### static boolean isDevelopmentEnvironmentAvailable()

      This method will return true if the 'grails-app' directory was found, regardless of whether reloading is active or not

      Returns:
        True if the development sources are present

    - #### static boolean isDevelopmentMode()

      Returns true if the application is running in development mode (within grails run-app)

      Returns:
        true if the application is running in development mode

    - #### static boolean isDevelopmentRun()

      This method will return true the application is run

      Returns:
        True if the development sources are present

    - #### static boolean isDevtoolsRestart()

      Checks if the run of the app is due to spring dev-tools or not.

      Returns:
        True if spring-dev-tools restart

    - #### static boolean isFork()

      Whether this is a fork of the Grails command line environment

      Returns:
        True if it is a fork

    - #### static boolean isInitializing()

      Returns:
        Whether interactive mode is enabled

    - #### static boolean isInteractiveMode()

      Returns:
        Whether interactive mode is enabled

    - #### boolean isReloadEnabled()

      Returns:
        Returns whether reload is enabled for the environment

    - #### static boolean isReloadInProgress()

    - #### static boolean isReloadingAgentEnabled()

      Returns:
        true if the reloading agent is active

    - #### static boolean isStandalone()

      Whether the application has been executed standalone via static void main. This method will return true when the application is executed via `java -jar` or if the application is run directly via the main method within an IDE

      Returns:
        True if it is running standalone outside of a servlet container

    - #### static boolean isStandaloneDeployed()

      Whether the application is running standalone within a JAR This method will return true only if the the application is executed via `java -jar` and not if it is run via the main method within an IDE

      Returns:
        True if it is running standalone outside a servlet container from within a JAR or WAR file

    - #### static boolean isSystemSet()

      Returns:
        Return true if the environment has been set as a System property

    - #### static boolean isWarDeployed()

      Check whether the application is deployed

      Returns:
        true if is

    - #### private static boolean isWebPath(java.lang.String path)

    - #### static boolean isWithinShell()

      Returns whether the environment is running within the Grails shell (executed via the 'grails' command line in a terminal window)

      Returns:
        true if is

    - #### @groovy.transform.Generated Environment next()

    - #### @groovy.transform.Generated Environment previous()

    - #### static void reset()

      Reset the current environment

    - #### private static Environment resolveCurrentEnvironment()

    - #### static void setCurrentReloadError(java.lang.Throwable currentReloadError)

    - #### static void setInitializing(boolean initializing)

    - #### void setName(java.lang.String name)

      Set the name.

      Parameters:
        `name` - the name

    - #### @groovy.transform.Generated static Environment valueOf(java.lang.String name)

    - #### @groovy.transform.Generated static final Environment[] values()

    - #### private static void writeDevToolsPidFile(java.io.File pidFile, java.lang.String content)