Package: grails.util

## [Java] Enum Environment

- grails.util.Environment

- Represents the current environment.

  Authors:
    Graeme Rocher
  Since:
    1.1

- - ### Enum Constants Summary

    Enum constants classes
    Enum constant | Description
    --- | ---
    `APPLICATION` |
    `CUSTOM` |
    `DEVELOPMENT` |
    `PRODUCTION` |
    `TEST` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `DEFAULT` | Constants that indicates whether this GrailsApplication is running in the default environment
    `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
    `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` | Represents the current environment.
    `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
    `static org.codehaus.groovy.control.MultipleCompilationErrorsException` | `currentCompilationError` |
    `static java.lang.Throwable` | `currentReloadError` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `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 #getCurrent()
    `` | `static java.lang.Throwable` | `getCurrentReloadError()`
    `` | `static Environment` | `getEnvironment(java.lang.String shortName)` Returns the environment for the given short name
    `` | `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()` @return The current Grails version
    `` | `java.lang.String` | `getName()` @return the name of the environment
    `` | `java.lang.String` | `getReloadLocation()` @return Obtains the location to reload resources from
    `` | `boolean` | `hasReloadLocation()` @return Whether a reload location is specified
    `` | `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` | `isFork()` Whether this is a fork of the Grails command line environment
    `` | `static boolean` | `isInitializing()` @return Whether interactive mode is enabled
    `` | `static boolean` | `isInteractiveMode()` @return Whether interactive mode is enabled
    `` | `boolean` | `isReloadEnabled()` @return Returns whether reload is enabled for the environment
    `` | `static boolean` | `isReloadInProgress()`
    `` | `static boolean` | `isReloadingAgentEnabled()`
    `` | `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()` @return Return true if the environment has been set as a System property
    `` | `static boolean` | `isWarDeployed()` Check whether the application is deployed
    `` | `static boolean` | `isWithinShell()` Returns whether the environment is running within the Grails shell (executed via the 'grails' command line in a terminal window)
    `` | `static void` | `reset()` Reset the current environment
    `` | `static void` | `setCurrentReloadError(java.lang.Throwable currentReloadError)`
    `` | `static void` | `setInitializing(boolean initializing)`
    `` | `void` | `setName(java.lang.String name)` Set the name.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Enum` | `java.lang.Enum#name(), java.lang.Enum#equals(java.lang.Object), java.lang.Enum#toString(), java.lang.Enum#hashCode(), java.lang.Enum#compareTo(java.lang.Object), java.lang.Enum#compareTo(java.lang.Enum), java.lang.Enum#valueOf(java.lang.Class, java.lang.String), java.lang.Enum#getDeclaringClass(), java.lang.Enum#ordinal(), java.lang.Enum#wait(long, int), java.lang.Enum#wait(long), java.lang.Enum#wait(), java.lang.Enum#getClass(), java.lang.Enum#notify(), java.lang.Enum#notifyAll()`
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Enum Constant Detail

    - #### Environment APPLICATION

    - #### Environment CUSTOM

    - #### Environment DEVELOPMENT

    - #### Environment PRODUCTION

    - #### Environment TEST

  - ### Field Detail

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

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

    - #### 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

    - #### 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

      Represents the current environment.

      Authors:
        Graeme Rocher
      Since:
        1.1

    - #### 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

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

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

  - ### Method Detail

    - #### public 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

    - #### public 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

    - #### public 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.

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

    - #### public static Environment getCurrentEnvironment()

      See Also:
        getCurrent()
      Returns:
        the current environment

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

    - #### public 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

    - #### public 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

    - #### public 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

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

      Returns:
        The current Grails version

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

      Returns:
        the name of the environment

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

      Returns:
        Obtains the location to reload resources from

    - #### public boolean hasReloadLocation()

      Returns:
        Whether a reload location is specified

    - #### public 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

    - #### public 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

    - #### public static boolean isDevelopmentRun()

      This method will return true the application is run

      Returns:
        True if the development sources are present

    - #### public static boolean isFork()

      Whether this is a fork of the Grails command line environment

      Returns:
        True if it is a fork

    - #### public static boolean isInitializing()

      Returns:
        Whether interactive mode is enabled

    - #### public static boolean isInteractiveMode()

      Returns:
        Whether interactive mode is enabled

    - #### public boolean isReloadEnabled()

      Returns:
        Returns whether reload is enabled for the environment

    - #### public static boolean isReloadInProgress()

    - #### public static boolean isReloadingAgentEnabled()

    - #### public 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

    - #### public 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

    - #### public static boolean isSystemSet()

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

    - #### public static boolean isWarDeployed()

      Check whether the application is deployed

      Returns:
        true if is

    - #### public 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

    - #### public static void reset()

      Reset the current environment

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

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

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

      Set the name.

      Parameters:
        `name` - the name