public class GrailsUtil
extends java.lang.Object
Constructor and Description |
---|
GrailsUtil() |
Modifier and Type | Method and Description |
---|---|
static ApplicationContext |
bootstrapGrailsFromApplication(GrailsApplication application)
Bootstraps Grails with the given GrailsApplication instance.
|
static ApplicationContext |
bootstrapGrailsFromClassPath()
Bootstraps a Grails application from the current classpath.
|
static ApplicationContext |
bootstrapGrailsFromParentContext(ApplicationContext parent)
Bootstraps Grails from the given parent ApplicationContext which should contain a bean definition called "grailsApplication"
of type GrailsApplication.
|
static java.lang.Throwable |
deepSanitize(java.lang.Throwable t)
Sanitize the exception and ALL nested causes
|
static void |
deprecated(java.lang.Class<?> clazz,
java.lang.String methodOrPropName)
Logs warning message about deprecation of specified property or method of some class.
|
static void |
deprecated(java.lang.Class<?> clazz,
java.lang.String methodOrPropName,
java.lang.String version)
Logs warning message about deprecation of specified property or method of some class.
|
static void |
deprecated(java.lang.String message)
Logs warning message about some deprecation and code style related hints.
|
static java.lang.Throwable |
extractRootCause(java.lang.Throwable t)
Extracts the root cause of the exception, no matter how nested it is
|
static java.lang.String |
getEnvironment()
Deprecated.
Use Environment.getCurrent() method instead
|
static java.lang.String |
getGrailsVersion() |
static boolean |
isDevelopmentEnv()
Retrieves whether the current execution environment is the development one.
|
static void |
printSanitizedStackTrace(java.lang.Throwable t) |
static void |
printSanitizedStackTrace(java.lang.Throwable t,
java.io.PrintWriter p) |
static void |
printSanitizedStackTrace(java.lang.Throwable t,
java.io.PrintWriter p,
StackTraceFilterer stackTraceFilterer) |
static java.lang.Throwable |
sanitize(java.lang.Throwable t)
Deprecated.
Use
StackTraceFilterer instead |
static java.lang.Throwable |
sanitizeRootCause(java.lang.Throwable t)
Get the root cause of an exception and sanitize it for display to the user
|
static void |
warn(java.lang.String message)
Logs warning message to grails.util.GrailsUtil logger which is turned on in development mode.
|
static void |
writeSlurperResult(GPathResult result,
java.io.Writer output)
Deprecated.
Will be removed in a future release
|
public static ApplicationContext bootstrapGrailsFromClassPath()
Bootstraps a Grails application from the current classpath. The method will look for an applicationContext.xml file in the classpath that must contain a bean of type GrailsApplication and id grailsApplication.
The method will then bootstrap Grails with the GrailsApplication and load all Grails plug-ins found in the path
public static ApplicationContext bootstrapGrailsFromApplication(GrailsApplication application)
application
- The GrailsApplication instancepublic static ApplicationContext bootstrapGrailsFromParentContext(ApplicationContext parent)
@Deprecated public static java.lang.String getEnvironment()
public static boolean isDevelopmentEnv()
public static java.lang.String getGrailsVersion()
public static void deprecated(java.lang.Class<?> clazz, java.lang.String methodOrPropName)
clazz
- A classmethodOrPropName
- Name of deprecated property or methodpublic static void deprecated(java.lang.Class<?> clazz, java.lang.String methodOrPropName, java.lang.String version)
clazz
- A classmethodOrPropName
- Name of deprecated property or methodversion
- Version of Grails release in which property or method were deprecatedpublic static void deprecated(java.lang.String message)
message
- Message to displaypublic static void warn(java.lang.String message)
message
- Message to display@Deprecated public static java.lang.Throwable sanitize(java.lang.Throwable t)
StackTraceFilterer
insteadRemove all apparently Grails-internal trace entries from the exception instance
This modifies the original instance and returns it, it does not clone
t
- The exceptionpublic static void printSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p)
public static void printSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p, StackTraceFilterer stackTraceFilterer)
public static void printSanitizedStackTrace(java.lang.Throwable t)
public static java.lang.Throwable extractRootCause(java.lang.Throwable t)
Extracts the root cause of the exception, no matter how nested it is
t
- public static java.lang.Throwable sanitizeRootCause(java.lang.Throwable t)
Get the root cause of an exception and sanitize it for display to the user
This will MODIFY the stacktrace of the root cause exception object and return it
t
- public static java.lang.Throwable deepSanitize(java.lang.Throwable t)
Sanitize the exception and ALL nested causes
This will MODIFY the stacktrace of the exception instance and all its causes irreversibly
t
- @Deprecated public static void writeSlurperResult(GPathResult result, java.io.Writer output) throws java.io.IOException
result
- The root node of the XML to write out.output
- Where to write the XML to.java.io.IOException
- If the writing fails due to a closed stream or unwritable file.