Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

## grails.util
Enum Environment

    java.lang.Object
      java.lang.Enum<Environment>
          grails.util.Environment

All Implemented Interfaces:
  Serializable, Comparable<Environment>

    public enum Environment

extends Enum<Environment>

An enum that represents the current environment

Since:
  1.1

  Created: Dec 12, 2008
Author:
  Graeme Rocher

Enum Constant Summary
`APPLICATION`
`CUSTOM`
`DEVELOPMENT`
`PRODUCTION`
`TEST`

Field Summary
`static String` | `DEFAULT` Constants that indicates whether this GrailsApplication is running in the default environment
`static String` | `KEY` Constant used to resolve the environment via System.getProperty(Environment.KEY)
`static String` | `RELOAD_ENABLED` Specify whether reloading is enabled for this environment
`static String` | `RELOAD_LOCATION` The location where to reload resources from

Method Summary
`static 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
`static 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
`static Environment` | `getCurrent()` Returns the current environment which is typcally either DEVELOPMENT, PRODUCTION or TEST.
`static Environment` | `getCurrentEnvironment()`
`static Environment` | `getEnvironment(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: `environments { development {} production {} }` And returns the closure that relates to the current environment
`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
`String` | `getName()`
`String` | `getReloadLocation()`
`boolean` | `hasReloadLocation()`
`static boolean` | `isDevelopmentMode()` Returns true if the application is running in development mode (within grails run-app)
`boolean` | `isReloadEnabled()`
`static boolean` | `isSystemSet()`
`void` | `setName(String name)`
`static Environment` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
`static Environment[]` | `values()` Returns an array containing the constants of this enum type, in the order they're declared.

Methods inherited from class java.lang.Enum
`clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Enum Constant Detail

### DEVELOPMENT

    public static final Environment DEVELOPMENT

### PRODUCTION

    public static final Environment PRODUCTION

### TEST

    public static final Environment TEST

### APPLICATION

    public static final Environment APPLICATION

### CUSTOM

    public static final Environment CUSTOM

Field Detail

### KEY

    public static String KEY

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

### RELOAD_ENABLED

    public static String RELOAD_ENABLED

  Specify whether reloading is enabled for this environment

### RELOAD_LOCATION

    public static final String RELOAD_LOCATION

  The location where to reload resources from

  See Also:
    Constant Field Values

### DEFAULT

    public static final String DEFAULT

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

  See Also:
    Constant Field Values

Method Detail

### values

    public static final Environment[] values()

  Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:

      for(Environment c : Environment.values())
              System.out.println(c);

  Returns:
    an array containing the constants of this enum type, in the order they're declared

### valueOf

    public static Environment valueOf(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:
    `IllegalArgumentException` - if this enum type has no constant with the specified name

### getCurrent

    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.

### getCurrentEnvironment

    public static Environment getCurrentEnvironment()

  See Also:
    `getCurrent()`

### isDevelopmentMode

    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

### isSystemSet

    public static boolean isSystemSet()

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

### getEnvironment

    public static Environment getEnvironment(String shortName)

  Returns the environment for the given short name

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

### getEnvironmentSpecificBlock

    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

### getEnvironmentSpecificBlock

    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

### executeForCurrentEnvironment

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

### executeForEnvironment

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

### getName

    public String getName()

  Returns:
    The name of the environment

### setName

    public void setName(String name)

### isReloadEnabled

    public boolean isReloadEnabled()

  Returns:
    Returns whether reload is enabled for the environment

### getReloadLocation

    public String getReloadLocation()

  Returns:
    Obtains the location to reload resources from

### hasReloadLocation

    public boolean hasReloadLocation()

  Returns:
    Whether a reload location is specified

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

Copyright (c) 2005-2009 The Grails project