Groovy Documentation

grails.util
[Java] Enum Environment

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

public enum Environment
extends java.lang.Enum

Represents the current environment.

Authors:
Graeme Rocher
Since:
1.1


Field Summary
static java.lang.String DEFAULT

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

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

 
Method Summary
static void cacheCurrentEnvironment()

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 Environment getCurrentEnvironment()

@see #getCurrent()

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:

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 isDevelopmentMode()

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

boolean isReloadEnabled()

@return Returns whether reload is enabled for the environment

static boolean isReloadingAgentEnabled()

@return true if the reloading agent is active

static boolean isSystemSet()

@return Return true if the environment has been set as a Systme 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)

void setName(java.lang.String name)

Set the name.

 
Methods inherited from 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(), java.lang.Enum#wait(long), java.lang.Enum#wait(long, int), java.lang.Enum#getClass(), java.lang.Enum#notify(), java.lang.Enum#notifyAll()
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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()
 

Field Detail

DEFAULT

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


KEY

public static java.lang.String KEY
Represents the current environment.
Authors:
Graeme Rocher
Since:
1.1


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


 
Method Detail

cacheCurrentEnvironment

public static void cacheCurrentEnvironment()


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


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()
Returns:
the current environment
See Also:
getCurrent()


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


getName

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


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


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


isReloadEnabled

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


isReloadingAgentEnabled

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


isSystemSet

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


isWarDeployed

public static boolean isWarDeployed()
Check whether the application is deployed
Returns:
True if is


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


setName

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


 

Groovy Documentation