|
||||||||||
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
Field Summary | |
---|---|
static String |
APPLICATION_ID
The id of the grails application within a bean context |
static String |
CONFIG_CLASS
The name of the class that provides configuration |
static String |
ENV_APPLICATION
Constant for the application data source, primarly for backward compatability for those applications that use ApplicationDataSource.groovy |
static String |
ENV_DEVELOPMENT
Constant for the development environment |
static String |
ENV_PRODUCTION
Constant for the production environment |
static String |
ENV_TEST
|
static String |
ENVIRONMENT
Constant used to resolve the environment via System.getProperty(ENVIRONMENT) |
static String |
PROJECT_CLASSES_DIR
The name of the system property whose value contains the location, during development, of the current Grails projects resources directory |
static String |
PROJECT_RESOURCES_DIR
The name of the system property whose value contains the location, during development, of the current Grails projects resources directory |
static 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 |
static 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 | |
---|---|
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 |
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[] |
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. |
Class |
getClassForName(String className)
Retrieves a class for the given name within the GrailsApplication or returns null |
groovy.lang.GroovyClassLoader |
getClassLoader()
Returns the class loader instance for the Grails application |
groovy.util.ConfigObject |
getConfig()
Returns the ConfigObject instance |
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()
|
Resource |
getResourceForClass(Class theClazz)
Retrieves a Resource instance for the given Grails class or null it doesn't exist |
GrailsControllerClass |
getScaffoldingController(GrailsDomainClass domainClass)
Retrieves the controller that is scaffolding the specified domain class |
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 |
Methods inherited from interface org.springframework.context.ApplicationContextAware |
---|
setApplicationContext |
Field Detail |
---|
static final String WORK_DIR
static final String PROJECT_RESOURCES_DIR
static final String PROJECT_CLASSES_DIR
static final String PROJECT_TEST_CLASSES_DIR
static final String APPLICATION_ID
static final String ENVIRONMENT
static final String ENV_DEVELOPMENT
static final String ENV_APPLICATION
static final String ENV_PRODUCTION
static final String ENV_TEST
static final String CONFIG_CLASS
Method Detail |
---|
groovy.util.ConfigObject getConfig()
groovy.lang.GroovyClassLoader getClassLoader()
Returns the class loader instance for the Grails application
GrailsControllerClass getScaffoldingController(GrailsDomainClass domainClass)
domainClass
- The domain class to check
Class[] getAllClasses()
Class[] getAllArtefacts()
ApplicationContext getParentContext()
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"
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 addArtefactHandler[] 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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |