|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
org.springframework.beans.factory.Aware org.codehaus.groovy.grails.commons.GrailsApplication
public interface GrailsApplication extends org.springframework.context.ApplicationContextAware
The main interface representing a running Grails application. This interface's main purpose is to provide a mechanism for analysing the conventions within a Grails application as well as providing metadata and information about the execution environment.
The GrailsApplication interface interfacts with ArtefactHandler instances which are capable of analysing different artefact types (controllers, domain classes etc.) and introspecting the artefact conventions
Implementors of this inteface should be aware that a GrailsApplication is only initialised when the initialise() method is called. In other words GrailsApplication instances are lazily initialised by the Grails runtime.
Field Summary | |
---|---|
java.lang.String |
APPLICATION_ID
The id of the grails application within a bean context |
java.lang.String |
CONFIG_CLASS
The name of the class that provides configuration |
java.lang.String |
DATA_SOURCE_CLASS
|
java.lang.String |
ENVIRONMENT
Constant used to resolve the environment via System.getProperty(ENVIRONMENT) |
java.lang.String |
ENVIRONMENT_DEFAULT
Constants that indicates whether this GrailsApplication is running in the default environment |
java.lang.String |
ENV_APPLICATION
Constant for the application data source, primarly for backward compatability for those applications that use ApplicationDataSource.groovy |
java.lang.String |
ENV_DEVELOPMENT
Constant for the development environment |
java.lang.String |
ENV_PRODUCTION
Constant for the production environment. |
java.lang.String |
ENV_TEST
Constant for the test environment. |
java.lang.String |
GLOBAL_PLUGINS_DIR
The path to the global plug-ins directory for the application |
java.lang.String |
PLUGINS_DIR
The path to the plug-ins directory for the application |
java.lang.String |
PROJECT_CLASSES_DIR
The name of the system property whose value contains the location, during development, of the current Grails projects resources directory |
java.lang.String |
PROJECT_META_FILE
|
java.lang.String |
PROJECT_RESOURCES_DIR
The name of the system property whose value contains the location, during development, of the current Grails projects resources directory |
java.lang.String |
PROJECT_TEST_CLASSES_DIR
The name of the system property whose value contains the location, during development, of the current Grails projects resources directory |
java.lang.String |
PROJECT_WORK_DIR
The directory where temporary project resources and plug-ins are kept |
java.lang.String |
WORK_DIR
The name of the system property whose value contains the location, during development, of the Grails working directory where temporary files are generated to |
Method Summary | |
---|---|
GrailsClass
|
addArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
|
GrailsClass
|
addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsClass)
|
void
|
addArtefact(java.lang.Class artefact)
Adds the given artefact, attempting to determine type from |
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)
|
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)
|
ArtefactHandler
|
getArtefactHandler(java.lang.String type)
Returns the ArtefactHandler for the given type |
ArtefactHandler[]
|
getArtefactHandlers()
|
ArtefactInfo
|
getArtefactInfo(java.lang.String artefactType)
|
ArtefactHandler
|
getArtefactType(java.lang.Class theClass)
Returns the ArtefactHandler for the given class or null |
GrailsClass[]
|
getArtefacts(java.lang.String artefactType)
|
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
|
getFlatConfig()
Returns the flatten ConfigObject for use from Java classes. |
org.springframework.context.ApplicationContext
|
getMainContext()
Returns the Spring context for this application. |
Metadata
|
getMetadata()
|
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)
|
void
|
initialise()
Initialise this GrailsApplication. |
boolean
|
isArtefact(java.lang.Class theClazz)
|
boolean
|
isArtefactOfType(java.lang.String artefactType, java.lang.Class theClazz)
|
boolean
|
isArtefactOfType(java.lang.String artefactType, java.lang.String className)
|
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)
|
void
|
setMainContext(org.springframework.context.ApplicationContext context)
Sets the main Spring context for this application. |
Methods inherited from interface org.springframework.context.ApplicationContextAware | |
---|---|
org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) |
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 |
---|
public java.lang.String APPLICATION_ID
public java.lang.String CONFIG_CLASS
public java.lang.String DATA_SOURCE_CLASS
@Deprecated public java.lang.String ENVIRONMENT
@Deprecated public java.lang.String ENVIRONMENT_DEFAULT
@Deprecated public java.lang.String ENV_APPLICATION
@Deprecated public java.lang.String ENV_DEVELOPMENT
@Deprecated public java.lang.String ENV_PRODUCTION
@Deprecated public java.lang.String ENV_TEST
@Deprecated public java.lang.String GLOBAL_PLUGINS_DIR
@Deprecated public java.lang.String PLUGINS_DIR
@Deprecated public java.lang.String PROJECT_CLASSES_DIR
public java.lang.String PROJECT_META_FILE
@Deprecated public java.lang.String PROJECT_RESOURCES_DIR
@Deprecated public java.lang.String PROJECT_TEST_CLASSES_DIR
@Deprecated public java.lang.String PROJECT_WORK_DIR
@Deprecated public java.lang.String WORK_DIR
Method Detail |
---|
@SuppressWarnings("rawtypes") public GrailsClass addArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
Registers 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 ArtefactHandler
public GrailsClass addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsClass)
Registers a new artefact
artefactType
- The type ID of the artefact, i.e. "TagLib"artefactGrailsClass
- The GrailsClass of the artefact.
@SuppressWarnings("rawtypes") public void addArtefact(java.lang.Class artefact)
artefact
- The artefact to add
@SuppressWarnings("rawtypes") public void addOverridableArtefact(java.lang.Class artefact)
artefact
- An overridable artefact
public void configChanged()
@SuppressWarnings("rawtypes") public java.lang.Class[] getAllArtefacts()
@SuppressWarnings("rawtypes") public java.lang.Class[] getAllClasses()
public GrailsClass getArtefact(java.lang.String artefactType, java.lang.String name)
Gets 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 GrailsClass getArtefactByLogicalPropertyName(java.lang.String type, java.lang.String logicalName)
type
- The artefact typelogicalName
- The logical name
public 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
artefactType
- The type ID of the artefact, i.e. "TagLib"featureID
- The "feature" ID, say a URL or tag name
public ArtefactHandler getArtefactHandler(java.lang.String type)
type
- The artefact handler type
public ArtefactHandler[] getArtefactHandlers()
Obtain a list of all the artefact handlers
public ArtefactInfo getArtefactInfo(java.lang.String artefactType)
Obtain all the class information about the artefactType specified
artefactType
- An artefact type identifier i.e. "Domain"
@SuppressWarnings("rawtypes") public ArtefactHandler getArtefactType(java.lang.Class theClass)
theClass
- The class
public GrailsClass[] getArtefacts(java.lang.String artefactType)
Get an array of all the GrailsClass instances relating to artefacts of the specified type.
artefactType
- The type of artefact to retrieve, i.e. "Controller"
@SuppressWarnings("rawtypes") public java.lang.Class getClassForName(java.lang.String className)
className
- The name of the class
public java.lang.ClassLoader getClassLoader()
public groovy.util.ConfigObject getConfig()
public java.util.Map getFlatConfig()
public org.springframework.context.ApplicationContext getMainContext()
null
until the application is fully
initialised. This context contains all the application artifacts,
plugin beans, the works.
public Metadata getMetadata()
Get 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.
public org.springframework.context.ApplicationContext getParentContext()
@SuppressWarnings("rawtypes") public org.springframework.core.io.Resource getResourceForClass(java.lang.Class theClazz)
theClazz
- The Grails class
public boolean hasArtefactHandler(java.lang.String type)
Test whether an artefact handler exists for a given type
type
- The type of the handler
public void initialise()
@SuppressWarnings("rawtypes") public boolean isArtefact(java.lang.Class theClazz)
Call this to find out if the class you have is an artefact loaded by grails.
theClazz
- A class to test
@SuppressWarnings("rawtypes") public 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
artefactType
- A string identifying the artefact type to check fortheClazz
- The class to check
public boolean isArtefactOfType(java.lang.String artefactType, java.lang.String className)
Check 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 check
public boolean isInitialised()
public boolean isWarDeployed()
public void rebuild()
public void refresh()
public void refreshConstraints()
public void registerArtefactHandler(ArtefactHandler handler)
Register a new artefact handler
handler
- The new handler to add
public void setMainContext(org.springframework.context.ApplicationContext context)
Groovy Documentation