public class StandaloneGrailsApplication
extends groovy.lang.GroovyObjectSupport
| Modifier and Type | Field and Description |
|---|---|
protected grails.util.Metadata |
applicationMeta |
protected java.lang.ClassLoader |
classLoader |
protected groovy.util.ConfigObject |
config |
protected java.util.Map |
flatConfig |
protected org.springframework.context.ApplicationContext |
mainContext |
protected org.springframework.context.ApplicationContext |
parentContext |
APPLICATION_ID, CLASS_EDITOR_BEAN, CLASS_LOADER_BEAN, CONFIG_CLASS, CUSTOM_EDITORS_BEAN, DATA_SOURCE_BEAN, DATA_SOURCE_CLASS, DIALECT_DETECTOR_BEAN, ENV_APPLICATION, ENV_DEVELOPMENT, ENV_PRODUCTION, ENV_TEST, ENVIRONMENT, ENVIRONMENT_DEFAULT, EXCEPTION_HANDLER_BEAN, GLOBAL_PLUGINS_DIR, HIBERNATE_PROPERTIES_BEAN, MESSAGE_SOURCE_BEAN, MULTIPART_RESOLVER_BEAN, OPEN_SESSION_IN_VIEW_INTERCEPTOR_BEAN, PLUGINS_DIR, PROJECT_CLASSES_DIR, PROJECT_META_FILE, PROJECT_RESOURCES_DIR, PROJECT_TEST_CLASSES_DIR, PROJECT_WORK_DIR, SESSION_FACTORY_BEAN, TRANSACTION_MANAGER_BEAN, WORK_DIR| Constructor and Description |
|---|
StandaloneGrailsApplication() |
| Modifier and Type | Method and Description |
|---|---|
void |
addArtefact(java.lang.Class artefact)
Adds the given artefact, attempting to determine type from
|
GrailsClass |
addArtefact(java.lang.String artefactType,
java.lang.Class artefactClass)
Registers a new artefact
|
GrailsClass |
addArtefact(java.lang.String artefactType,
GrailsClass artefactGrailsClass)
Registers a new artefact
|
void |
addOverridableArtefact(java.lang.Class artefact)
Adds an artefact that can be overriden by user defined classes
|
void |
configChanged()
Fired to inform the application when the Config.groovy file changes.
|
java.lang.Class[] |
getAllArtefacts()
Retrieves all java.lang.Class instances considered Artefacts loaded by the Grails class loader
|
java.lang.Class[] |
getAllClasses()
Retrieves all java.lang.Class instances loaded by the Grails class loader
|
GrailsClass |
getArtefact(java.lang.String artefactType,
java.lang.String name)
Gets the GrailsClass associated with the named artefact class
|
GrailsClass |
getArtefactByLogicalPropertyName(java.lang.String type,
java.lang.String logicalName)
Retrieves an artefact by its logical property name.
|
GrailsClass |
getArtefactForFeature(java.lang.String artefactType,
java.lang.Object featureID)
Get an artefact GrailsClass by a "feature" which depending on the artefact may be a URI or tag name
for example
|
ArtefactHandler |
getArtefactHandler(java.lang.String type)
Returns the ArtefactHandler for the given type
|
ArtefactHandler[] |
getArtefactHandlers()
Obtain a list of all the artefact handlers
|
ArtefactInfo |
getArtefactInfo(java.lang.String artefactType)
Obtain all the class information about the artefactType specified
|
GrailsClass[] |
getArtefacts(java.lang.String artefactType)
Get an array of all the GrailsClass instances relating to artefacts of the specified type.
|
ArtefactHandler |
getArtefactType(java.lang.Class theClass)
Returns the ArtefactHandler for the given class or null
|
java.lang.Class |
getClassForName(java.lang.String className)
Retrieves a class for the given name within the GrailsApplication or returns null
|
java.lang.ClassLoader |
getClassLoader()
Returns the class loader instance for the Grails application.
|
groovy.util.ConfigObject |
getConfig()
Returns the ConfigObject instance.
|
java.util.Map<java.lang.String,java.lang.Object> |
getFlatConfig()
Returns the flatten ConfigObject for use from Java classes.
|
org.springframework.context.ApplicationContext |
getMainContext()
Returns the Spring context for this application.
|
grails.util.Metadata |
getMetadata()
Get access to the project's metadata, specified in application.properties
|
org.springframework.context.ApplicationContext |
getParentContext()
Returns the Spring application context that contains this
application instance.
|
org.springframework.core.io.Resource |
getResourceForClass(java.lang.Class theClazz)
Retrieves a Resource instance for the given Grails class or null it doesn't exist.
|
boolean |
hasArtefactHandler(java.lang.String type)
Test whether an artefact handler exists for a given type
|
void |
initialise()
Initialise this GrailsApplication.
|
boolean |
isArtefact(java.lang.Class theClazz)
Call this to find out if the class you have is an artefact loaded by grails.
|
boolean |
isArtefactOfType(java.lang.String artefactType,
java.lang.Class theClazz)
Check if the specified artefact Class has been loaded by Grails already AND is
of the type expected
|
boolean |
isArtefactOfType(java.lang.String artefactType,
java.lang.String className)
Check if the artefact Class with the name specified is of the type expected
|
boolean |
isInitialised()
Returns whether this GrailsApplication has been initialised or not.
|
boolean |
isWarDeployed()
Returns true if this application has been deployed as a WAR file
|
void |
rebuild()
Rebuilds this Application throwing away the class loader and re-constructing it from the loaded
resources again.
|
void |
refresh()
This method will refresh the entire application
|
void |
refreshConstraints()
Rebuilds the constraint definitions.
|
void |
registerArtefactHandler(ArtefactHandler handler)
Register a new artefact handler
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setBeanClassLoader(java.lang.ClassLoader classLoader) |
void |
setConfig(groovy.util.ConfigObject config) |
void |
setMainContext(org.springframework.context.ApplicationContext context)
Sets the main Spring context for this application.
|
void |
updateFlatConfig() |
protected java.lang.ClassLoader classLoader
protected groovy.util.ConfigObject config
protected java.util.Map flatConfig
protected org.springframework.context.ApplicationContext parentContext
protected org.springframework.context.ApplicationContext mainContext
protected grails.util.Metadata applicationMeta
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic java.lang.Class[] getAllClasses()
GrailsApplicationpublic java.lang.Class[] getAllArtefacts()
GrailsApplicationpublic void refreshConstraints()
GrailsApplicationpublic void refresh()
GrailsApplicationpublic void rebuild()
GrailsApplicationpublic org.springframework.core.io.Resource getResourceForClass(java.lang.Class theClazz)
GrailsApplicationtheClazz - The Grails classpublic boolean isArtefact(java.lang.Class theClazz)
GrailsApplicationCall this to find out if the class you have is an artefact loaded by grails.
theClazz - A class to testpublic boolean isArtefactOfType(java.lang.String artefactType,
java.lang.Class theClazz)
GrailsApplicationCheck if the specified artefact Class has been loaded by Grails already AND is of the type expected
artefactType - A string identifying the artefact type to check fortheClazz - The class to checkpublic boolean isArtefactOfType(java.lang.String artefactType,
java.lang.String className)
GrailsApplicationCheck if the artefact Class with the name specified is of the type expected
artefactType - A string identifying the artefact type to check forclassName - The name of a class to checkpublic GrailsClass getArtefact(java.lang.String artefactType, java.lang.String name)
GrailsApplicationGets the GrailsClass associated with the named artefact class
i.e. to get the GrailsClass for controller called "BookController" you pass the name "BookController"
artefactType - The type of artefact to retrieve, i.e. "Controller"name - The name of an artefact such as "BookController"public ArtefactHandler getArtefactType(java.lang.Class theClass)
GrailsApplicationtheClass - The classpublic ArtefactInfo getArtefactInfo(java.lang.String artefactType)
GrailsApplicationObtain all the class information about the artefactType specified
artefactType - An artefact type identifier i.e. "Domain"public GrailsClass[] getArtefacts(java.lang.String artefactType)
GrailsApplicationGet an array of all the GrailsClass instances relating to artefacts of the specified type.
artefactType - The type of artefact to retrieve, i.e. "Controller"public GrailsClass getArtefactForFeature(java.lang.String artefactType, java.lang.Object featureID)
GrailsApplicationGet an artefact GrailsClass by a "feature" which depending on the artefact may be a URI or tag name for example
artefactType - The type ID of the artefact, i.e. "TagLib"featureID - The "feature" ID, say a URL or tag namepublic GrailsClass addArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
GrailsApplicationRegisters a new artefact
artefactType - The type ID of the artefact, i.e. "TagLib"artefactClass - The class of the artefact. A new GrailsClass will be created automatically and added
to internal structures, using the appropriate ArtefactHandlerpublic GrailsClass addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsClass)
GrailsApplicationRegisters a new artefact
artefactType - The type ID of the artefact, i.e. "TagLib"artefactGrailsClass - The GrailsClass of the artefact.public void registerArtefactHandler(ArtefactHandler handler)
GrailsApplicationRegister a new artefact handler
handler - The new handler to addpublic boolean hasArtefactHandler(java.lang.String type)
GrailsApplicationTest whether an artefact handler exists for a given type
type - The type of the handlerpublic ArtefactHandler[] getArtefactHandlers()
GrailsApplicationObtain a list of all the artefact handlers
public void initialise()
GrailsApplicationpublic boolean isInitialised()
GrailsApplicationpublic GrailsClass getArtefactByLogicalPropertyName(java.lang.String type, java.lang.String logicalName)
GrailsApplicationtype - The artefact typelogicalName - The logical namepublic void addArtefact(java.lang.Class artefact)
GrailsApplicationartefact - The artefact to addpublic void addOverridableArtefact(java.lang.Class artefact)
GrailsApplicationartefact - An overridable artefactpublic ArtefactHandler getArtefactHandler(java.lang.String type)
GrailsApplicationtype - The artefact handler typepublic grails.util.Metadata getMetadata()
GrailsApplicationGet access to the project's metadata, specified in application.properties
This provides access to information like required grails version, application name, version etc but NOT general application settings.
getMetadata in interface GrailsApplicationpublic boolean isWarDeployed()
GrailsApplicationisWarDeployed in interface GrailsApplicationpublic groovy.util.ConfigObject getConfig()
GrailsApplicationgetConfig in interface GrailsApplicationpublic void setConfig(groovy.util.ConfigObject config)
public void updateFlatConfig()
public java.util.Map<java.lang.String,java.lang.Object> getFlatConfig()
GrailsApplicationgetFlatConfig in interface GrailsApplicationpublic void configChanged()
GrailsApplicationconfigChanged in interface GrailsApplicationpublic void setBeanClassLoader(java.lang.ClassLoader classLoader)
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAwarepublic java.lang.ClassLoader getClassLoader()
GrailsApplicationgetClassLoader in interface GrailsApplicationpublic java.lang.Class getClassForName(java.lang.String className)
GrailsApplicationgetClassForName in interface GrailsApplicationclassName - The name of the classpublic org.springframework.context.ApplicationContext getMainContext()
GrailsApplicationnull until the application is fully
initialised. This context contains all the application artifacts,
plugin beans, the works.getMainContext in interface GrailsApplicationpublic void setMainContext(org.springframework.context.ApplicationContext context)
GrailsApplicationsetMainContext in interface GrailsApplicationpublic org.springframework.context.ApplicationContext getParentContext()
GrailsApplicationGrailsApplication.getMainContext().getParentContext in interface GrailsApplication