grails.util
Enum Environment

java.lang.Object
  extended by java.lang.Enum<Environment>
      extended by grails.util.Environment
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Environment>

public enum Environment
extends java.lang.Enum<Environment>

Represents the current environment.

Since:
1.1

Enum Constant Summary
APPLICATION
          For the application data source, primarly for backward compatability for those applications that use ApplicationDataSource.groovy.
CUSTOM
          A custom environment
DEVELOPMENT
          The development environment
PRODUCTION
          The production environment
TEST
          The test environment
 
Field Summary
static java.lang.String DEFAULT
          Constants that indicates whether this GrailsApplication is running in the default environment
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)
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
 
Method Summary
static void cacheCurrentEnvironment()
           
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
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
static Environment getCurrent()
          Returns the current environment which is typcally either DEVELOPMENT, PRODUCTION or TEST.
static Environment getCurrentEnvironment()
           
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: 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
 java.lang.String getName()
           
 java.lang.String getReloadLocation()
           
 boolean hasReloadLocation()
           
static boolean isDevelopmentMode()
          Returns true if the application is running in development mode (within grails run-app)
static boolean isFork()
          Whether this is a fork of the Grails command line environment
static boolean isInitializing()
           
static boolean isInteractiveMode()
           
 boolean isReloadEnabled()
           
static boolean isReloadingAgentEnabled()
           
static boolean isSystemSet()
           
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 setInitializing(boolean initializing)
           
 void setName(java.lang.String name)
          Set the name.
static Environment valueOf(java.lang.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 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

DEVELOPMENT

public static final Environment DEVELOPMENT
The development environment


PRODUCTION

public static final Environment PRODUCTION
The production environment


TEST

public static final Environment TEST
The test environment


APPLICATION

public static final Environment APPLICATION
For the application data source, primarly for backward compatability for those applications that use ApplicationDataSource.groovy.


CUSTOM

public static final Environment CUSTOM
A custom environment

Field Detail

KEY

public static java.lang.String KEY
Constant used to resolve the environment via System.getProperty(Environment.KEY)


RELOAD_ENABLED

public static java.lang.String RELOAD_ENABLED
Specify whether reloading is enabled for this environment


RELOAD_LOCATION

public static final java.lang.String RELOAD_LOCATION
The location where to reload resources from

See Also:
Constant Field Values

INTERACTIVE_MODE_ENABLED

public static final java.lang.String INTERACTIVE_MODE_ENABLED
Whether interactive mode is enabled

See Also:
Constant Field Values

DEFAULT

public static final java.lang.String DEFAULT
Constants that indicates whether this GrailsApplication is running in the default environment

See Also:
Constant Field Values

INITIALIZING

public static final java.lang.String INITIALIZING
Whether Grails is in the middle of bootstrapping or not

See Also:
Constant Field Values
Method Detail

values

public static Environment[] 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 (Environment c : Environment.values())
    System.out.println(c);

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

valueOf

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

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.

cacheCurrentEnvironment

public static void cacheCurrentEnvironment()

getCurrentEnvironment

public static Environment getCurrentEnvironment()
Returns:
the current environment
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

isWarDeployed

public static boolean isWarDeployed()
Check whether the application is deployed

Returns:
true if is

isFork

public static boolean isFork()
Whether this is a fork of the Grails command line environment

Returns:
True if it is a fork

isWithinShell

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

isSystemSet

public static boolean isSystemSet()
Returns:
Return true if the environment has been set as a Systme property

getEnvironment

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

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

executeForEnvironment

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

getName

public java.lang.String getName()
Returns:
the name of the environment

setName

public void setName(java.lang.String name)
Set the name.

Parameters:
name - the name

isReloadEnabled

public boolean isReloadEnabled()
Returns:
Returns whether reload is enabled for the environment

isInteractiveMode

public static boolean isInteractiveMode()
Returns:
Whether interactive mode is enabled

isInitializing

public static boolean isInitializing()
Returns:
Whether interactive mode is enabled

setInitializing

public static void setInitializing(boolean initializing)

isReloadingAgentEnabled

public static boolean isReloadingAgentEnabled()
Returns:
true if the reloading agent is active

getReloadLocation

public java.lang.String getReloadLocation()
Returns:
Obtains the location to reload resources from

hasReloadLocation

public boolean hasReloadLocation()
Returns:
Whether a reload location is specified