|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.lang.GroovyObjectSupport org.codehaus.groovy.grails.commons.DefaultGrailsApplication
public class DefaultGrailsApplication extends groovy.lang.GroovyObjectSupport
Default implementation of the GrailsApplication interface that manages application loading, state, and artefact instances.
Upon loading this GrailsApplication will inspect each class using its registered ArtefactHandler instances. Each ArtefactHandler provides knowledge about the conventions used to establish its artefact type. For example controllers use the ControllerArtefactHandler to establish this knowledge. New ArtefactHandler instances can be registered with the GrailsApplication thus allowing application extensibility.Constructor Summary | |
DefaultGrailsApplication()
Creates a new empty Grails application. |
|
DefaultGrailsApplication(Class[] classes, java.lang.ClassLoader classLoader)
Creates a new GrailsApplication instance using the given classes and GroovyClassLoader. |
|
DefaultGrailsApplication(Resource[] resources)
Constructs a GrailsApplication with the given set of groovy sources specified as Spring Resource instances. |
|
DefaultGrailsApplication(GrailsResourceLoader resourceLoader)
|
Method Summary | |
---|---|
GrailsClass
|
addArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
Adds an artefact of the given type for the given Class. |
GrailsClass
|
addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsClass)
Adds an artefact of the given type for the given GrailsClass. |
void
|
addArtefact(java.lang.Class artefact)
|
void
|
addOverridableArtefact(java.lang.Class artefact)
|
GrailsClass
|
addOverridableArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
Adds an artefact of the given type for the given Class. |
void
|
configChanged()
|
Class[]
|
getAllArtefacts()
Returns all the classes identified as artefacts by ArtefactHandler instances. |
Class[]
|
getAllClasses()
Retrieves all classes loaded by the GrailsApplication. |
GrailsClass
|
getArtefact(java.lang.String artefactType, java.lang.String name)
Retrieves an artefact for the given type and name. |
GrailsClass
|
getArtefactByLogicalPropertyName(java.lang.String type, java.lang.String logicalName)
|
GrailsClass
|
getArtefactForFeature(java.lang.String artefactType, java.lang.Object featureID)
|
ArtefactHandler
|
getArtefactHandler(java.lang.String type)
|
ArtefactHandler[]
|
getArtefactHandlers()
|
ArtefactInfo
|
getArtefactInfo(java.lang.String artefactType)
Get the cache of classes for the specified artefact type. |
ArtefactHandler
|
getArtefactType(java.lang.Class theClass)
|
GrailsClass[]
|
getArtefacts(java.lang.String artefactType)
Returns all of the GrailsClass instances for the given artefactType as defined by the ArtefactHandler |
java.lang.Class
|
getClassForName(java.lang.String className)
Retrieves a class from the GrailsApplication for the given name. |
java.lang.ClassLoader
|
getClassLoader()
|
groovy.util.ConfigObject
|
getConfig()
|
java.util.Map
|
getFlatConfig()
|
ApplicationContext
|
getMainContext()
|
java.util.Map
|
getMetadata()
|
ApplicationContext
|
getParentContext()
Retrieves the parent ApplicationContext for this GrailsApplication. |
java.lang.Object
|
getProperty(java.lang.String propertyName)
Override property access and hit on xxxxClasses to return class arrays of artefacts. |
Resource
|
getResourceForClass(java.lang.Class theClazz)
Retrieves the Spring Resource that was used to load the given Class. |
GrailsResourceLoader
|
getResourceLoader()
|
boolean
|
hasArtefactHandler(java.lang.String type)
|
void
|
initialise()
|
java.lang.Object
|
invokeMethod(java.lang.String methodName, java.lang.Object args)
Overrides method invocation to return dynamic artefact methods. |
boolean
|
isArtefact(java.lang.Class theClazz)
Returns true if the given class is an artefact identified by one of the registered ArtefactHandler instances. |
boolean
|
isArtefactOfType(java.lang.String artefactType, java.lang.Class theClazz)
Returns true if the specified class is of the given artefact type as defined by the ArtefactHandler. |
boolean
|
isArtefactOfType(java.lang.String artefactType, java.lang.String className)
Returns true if the specified class name is of the given artefact type as defined by the ArtefactHandler. |
boolean
|
isInitialised()
|
boolean
|
isWarDeployed()
|
void
|
rebuild()
|
void
|
refresh()
Refreshes this GrailsApplication, rebuilding all of the artefact definitions as defined by the registered ArtefactHandler instances. |
void
|
refreshConstraints()
Refreshes constraints defined by the DomainClassArtefactHandler. |
void
|
registerArtefactHandler(ArtefactHandler handler)
Registers a new ArtefactHandler that is responsible for identifying and managing a particular artefact type that is defined by some convention. |
void
|
setApplicationContext(ApplicationContext applicationContext)
Sets the parent ApplicationContext for the GrailsApplication. |
void
|
setBeanClassLoader(java.lang.ClassLoader classLoader)
|
void
|
setMainContext(ApplicationContext context)
|
Methods inherited from class groovy.lang.GroovyObjectSupport | |
---|---|
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() |
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() |
Constructor Detail |
---|
public DefaultGrailsApplication()
public DefaultGrailsApplication(Class[] classes, java.lang.ClassLoader classLoader)
classes
- The classes that make up the GrailsApplicationclassLoader
- The GroovyClassLoader to use
public DefaultGrailsApplication(Resource[] resources)
resources
- An array or Groovy sources provides by Spring Resource instances
public DefaultGrailsApplication(GrailsResourceLoader resourceLoader)
Method Detail |
---|
public GrailsClass addArtefact(java.lang.String artefactType, @SuppressWarnings("rawtypes") java.lang.Class artefactClass)
artefactType
- The type of the artefact as defined by a ArtefactHandler instanceartefactClass
- A Class instance that matches the type defined by the ArtefactHandler
public GrailsClass addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsClass)
artefactType
- The type of the artefact as defined by a ArtefactHandler instanceartefactGrailsClass
- A GrailsClass instance that matches the type defined by the ArtefactHandler
public void addArtefact(@SuppressWarnings("rawtypes") java.lang.Class artefact)
public void addOverridableArtefact(@SuppressWarnings("rawtypes") java.lang.Class artefact)
public GrailsClass addOverridableArtefact(java.lang.String artefactType, @SuppressWarnings("rawtypes") java.lang.Class artefactClass)
artefactType
- The type of the artefact as defined by a ArtefactHandler instanceartefactClass
- A Class instance that matches the type defined by the ArtefactHandler
public void configChanged()
public Class[] getAllArtefacts()
public Class[] getAllClasses()
public GrailsClass getArtefact(java.lang.String artefactType, java.lang.String name)
artefactType
- The artefact type as defined by a registered ArtefactHandlername
- The name of the class
public GrailsClass getArtefactByLogicalPropertyName(java.lang.String type, java.lang.String logicalName)
public GrailsClass getArtefactForFeature(java.lang.String artefactType, java.lang.Object featureID)
public ArtefactHandler getArtefactHandler(java.lang.String type)
public ArtefactHandler[] getArtefactHandlers()
public ArtefactInfo getArtefactInfo(java.lang.String artefactType)
artefactType
- The name of an artefact type
public ArtefactHandler getArtefactType(@SuppressWarnings("rawtypes") java.lang.Class theClass)
public GrailsClass[] getArtefacts(java.lang.String artefactType)
artefactType
- The type of the artefact defined by the ArtefactHandler
public java.lang.Class getClassForName(java.lang.String className)
className
- The class name
public java.lang.ClassLoader getClassLoader()
public groovy.util.ConfigObject getConfig()
@SuppressWarnings("rawtypes") public java.util.Map getFlatConfig()
public ApplicationContext getMainContext()
@SuppressWarnings("rawtypes") public java.util.Map getMetadata()
public ApplicationContext getParentContext()
@Override public java.lang.Object getProperty(java.lang.String propertyName)
propertyName
- The name of the property, if it ends in *Classes then match and invoke internal ArtefactHandler
public Resource getResourceForClass(@SuppressWarnings("rawtypes") java.lang.Class theClazz)
theClazz
- The class
public GrailsResourceLoader getResourceLoader()
public boolean hasArtefactHandler(java.lang.String type)
public void initialise()
@Override public java.lang.Object invokeMethod(java.lang.String methodName, java.lang.Object args)
Overrides method invocation to return dynamic artefact methods.
We will support getXXXXClasses() and isXXXXClass(class)
methodName
- The name of the methodargs
- The arguments to the method
public boolean isArtefact(@SuppressWarnings("rawtypes") java.lang.Class theClazz)
theClazz
- The class to check
public boolean isArtefactOfType(java.lang.String artefactType, @SuppressWarnings("rawtypes") java.lang.Class theClazz)
artefactType
- The type of the artefacttheClazz
- The class
public boolean isArtefactOfType(java.lang.String artefactType, java.lang.String className)
artefactType
- The type of the artefactclassName
- The class name
public boolean isInitialised()
public boolean isWarDeployed()
public void rebuild()
public void refresh()
public void refreshConstraints()
public void registerArtefactHandler(ArtefactHandler handler)
handler
- The ArtefactHandler to regster
public void setApplicationContext(ApplicationContext applicationContext)
applicationContext
- The ApplicationContext
public void setBeanClassLoader(java.lang.ClassLoader classLoader)
public void setMainContext(ApplicationContext context)
Groovy Documentation