|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GrailsApplication
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.
initialise()
,
ArtefactHandler
Method Summary | |
---|---|
void |
addArtefact(Class artefact)
Adds the given artefact, attempting to determine type from |
GrailsClass |
addArtefact(String artefactType,
Class artefactClass)
Registers a new artefact |
GrailsClass |
addArtefact(String artefactType,
GrailsClass artefactGrailsClass)
Registers a new artefact |
void |
addOverridableArtefact(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 |
Class[] |
getAllArtefacts()
Retrieves all java.lang.Class instances considered Artefacts loaded by the Grails class loader |
Class[] |
getAllClasses()
Retrieves all java.lang.Class instances loaded by the Grails class loader |
GrailsClass |
getArtefact(String artefactType,
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" |
GrailsClass |
getArtefactByLogicalPropertyName(String type,
String logicalName)
Retrieves an artefact by its logical property name. |
GrailsClass |
getArtefactForFeature(String artefactType,
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(String type)
Returns the ArtefactHandler for the given type |
ArtefactHandler[] |
getArtefactHandlers()
Obtain a list of all the artefact handlers |
ArtefactInfo |
getArtefactInfo(String artefactType)
Obtain all the class information about the artefactType specified |
GrailsClass[] |
getArtefacts(String artefactType)
Get an array of all the GrailsClass instances relating to artefacts of the specified type. |
ArtefactHandler |
getArtefactType(Class theClass)
Returns the ArtefactHandler for the given class or null |
Class |
getClassForName(String className)
Retrieves a class for the given name within the GrailsApplication or returns null |
ClassLoader |
getClassLoader()
Returns the class loader instance for the Grails application |
groovy.util.ConfigObject |
getConfig()
Returns the ConfigObject instance |
Map |
getFlatConfig()
Returns the flatten ConfigObject for use from Java classes |
ApplicationContext |
getMainContext()
Returns the Spring context for this application. |
Map |
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. |
ApplicationContext |
getParentContext()
Returns the Spring application context that contains this application instance. |
Resource |
getResourceForClass(Class theClazz)
Retrieves a Resource instance for the given Grails class or null it doesn't exist |
boolean |
hasArtefactHandler(String type)
Test whether an artefact handler exists for a given type |
void |
initialise()
Initialise this GrailsApplication |
boolean |
isArtefact(Class theClazz)
Call this to find out if the class you have is an artefact loaded by grails. |
boolean |
isArtefactOfType(String artefactType,
Class theClazz)
Check if the specified artefact Class has been loaded by Grails already AND is of the type expected |
boolean |
isArtefactOfType(String artefactType,
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()
This method will rebuild the constraint definitions |
void |
registerArtefactHandler(ArtefactHandler handler)
Register a new artefact handler |
void |
setMainContext(ApplicationContext context)
Sets the main Spring context for this application. |
Methods inherited from interface org.springframework.context.ApplicationContextAware |
---|
setApplicationContext |
Field Detail |
---|
static final String WORK_DIR
BuildSettings.WORK_DIR
instead.
static final String PROJECT_WORK_DIR
BuildSettings.PROJECT_WORK_DIR
instead.
static final String PLUGINS_DIR
BuildSettings.PLUGINS_DIR
instead.
static final String GLOBAL_PLUGINS_DIR
BuildSettings.GLOBAL_PLUGINS_DIR
instead.
static final String PROJECT_RESOURCES_DIR
BuildSettings.PROJECT_RESOURCES_DIR
instead.
static final String PROJECT_CLASSES_DIR
BuildSettings.PROJECT_CLASSES_DIR
instead.
static final String PROJECT_TEST_CLASSES_DIR
BuildSettings.PROJECT_TEST_CLASSES_DIR
instead.
static final String APPLICATION_ID
static final String ENVIRONMENT
Environment.KEY
instead.
static final String ENVIRONMENT_DEFAULT
Environment.DEFAULT
instead.
static final String ENV_DEVELOPMENT
Environment.DEVELOPMENT
instead.
static final String ENV_APPLICATION
Environment.APPLICATION
instead.
static final String ENV_PRODUCTION
Environment.PRODUCTION
instead.
static final String ENV_TEST
Environment.TEST
instead.
static final String CONFIG_CLASS
static final String DATA_SOURCE_CLASS
static final String PROJECT_META_FILE
Method Detail |
---|
groovy.util.ConfigObject getConfig()
Map getFlatConfig()
ClassLoader getClassLoader()
Returns the class loader instance for the Grails application
Class[] getAllClasses()
Class[] getAllArtefacts()
ApplicationContext getMainContext()
null
until the application is fully
initialised. This context contains all the application artifacts,
plugin beans, the works.
void setMainContext(ApplicationContext context)
ApplicationContext getParentContext()
getMainContext()
.
Class getClassForName(String className)
className
- The name of the class
void refreshConstraints()
void refresh()
void rebuild()
Resource getResourceForClass(Class theClazz)
theClazz
- The Grails class
boolean isArtefact(Class theClazz)
Call this to find out if the class you have is an artefact loaded by grails.
theClazz
- A class to test
boolean isArtefactOfType(String artefactType, 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
boolean isArtefactOfType(String artefactType, 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
GrailsClass getArtefact(String artefactType, 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"
ArtefactHandler getArtefactType(Class theClass)
theClass
- The class
ArtefactInfo getArtefactInfo(String artefactType)
Obtain all the class information about the artefactType specified
artefactType
- An artefact type identifier i.e. "Domain"
GrailsClass[] getArtefacts(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"
GrailsClass getArtefactForFeature(String artefactType, 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
GrailsClass addArtefact(String artefactType, 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
GrailsClass addArtefact(String artefactType, GrailsClass artefactGrailsClass)
Registers a new artefact
artefactType
- The type ID of the artefact, i.e. "TagLib"artefactGrailsClass
- The GrailsClass of the artefact.
void registerArtefactHandler(ArtefactHandler handler)
Register a new artefact handler
handler
- The new handler to addboolean hasArtefactHandler(String type)
Test whether an artefact handler exists for a given type
type
- The type of the handler
ArtefactHandler[] getArtefactHandlers()
Obtain a list of all the artefact handlers
void initialise()
boolean isInitialised()
Map 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.
GrailsClass getArtefactByLogicalPropertyName(String type, String logicalName)
type
- The artefact typelogicalName
- The logical name
void addArtefact(Class artefact)
artefact
- The artefact to addboolean isWarDeployed()
void addOverridableArtefact(Class artefact)
artefact
- An overridable artefactvoid configChanged()
ArtefactHandler getArtefactHandler(String type)
type
- The artefact handler type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |