|
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.Field Summary | |
---|---|
protected static java.util.regex.Pattern |
GETCLASSESMETH_PATTERN
|
protected static java.util.regex.Pattern |
GETCLASSESPROP_PATTERN
|
protected static java.util.regex.Pattern |
GETCLASS_PATTERN
|
protected static java.util.regex.Pattern |
ISCLASS_PATTERN
|
protected java.util.List |
allArtefactClasses
|
protected java.lang.Class[] |
allArtefactClassesArray
|
protected java.lang.Class[] |
allClasses
|
protected Metadata |
applicationMeta
|
protected ArtefactHandler[] |
artefactHandlers
|
protected java.util.Map |
artefactHandlersByName
|
protected java.util.Map |
artefactInfo
|
protected java.lang.ClassLoader |
cl
|
protected groovy.util.ConfigObject |
config
|
protected java.util.Map |
flatConfig
|
protected boolean |
initialised
|
protected java.util.List |
loadedClasses
|
protected static org.apache.commons.logging.Log |
log
|
protected org.springframework.context.ApplicationContext |
mainContext
|
protected org.springframework.context.ApplicationContext |
parentContext
|
protected org.springframework.core.io.Resource[] |
resources
|
Constructor Summary | |
DefaultGrailsApplication()
Creates a new empty Grails application. |
|
DefaultGrailsApplication(java.lang.Class[] classes, java.lang.ClassLoader classLoader)
Creates a new GrailsApplication instance using the given classes and GroovyClassLoader. |
|
DefaultGrailsApplication(org.springframework.core.io.Resource[] resources)
Loads a GrailsApplication using the given ResourceLocator instance which will search for appropriate class names |
|
DefaultGrailsApplication(Resource[] resources)
Loads a GrailsApplication using the given ResourceLocator instance which will search for appropriate class names |
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)
|
protected GrailsClass
|
addArtefact(java.lang.String artefactType, java.lang.Class artefactClass, boolean overrideable)
|
void
|
addOverridableArtefact(java.lang.Class artefact)
|
GrailsClass
|
addOverridableArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
|
protected void
|
addToLoaded(java.lang.Class clazz)
|
void
|
clear()
|
void
|
configChanged()
|
protected void
|
configureLoadedClasses(java.lang.Class[] classes)
Configures the loaded classes within the GrailsApplication instance using the registered ArtefactHandler instances. |
java.lang.Class[]
|
getAllArtefacts()
Returns all the classes identified as artefacts by ArtefactHandler instances. |
java.lang.Class[]
|
getAllClasses()
|
GrailsClass
|
getArtefact(java.lang.String artefactType, java.lang.String name)
|
GrailsClass
|
getArtefactByLogicalPropertyName(java.lang.String type, java.lang.String logicalName)
|
protected int
|
getArtefactCount(java.lang.String artefactType)
|
GrailsClass
|
getArtefactForFeature(java.lang.String artefactType, java.lang.Object featureID)
|
ArtefactHandler
|
getArtefactHandler(java.lang.String type)
|
ArtefactHandler[]
|
getArtefactHandlers()
|
protected DefaultArtefactInfo
|
getArtefactInfo(java.lang.String artefactType, boolean create)
Get or create the cache of classes for the specified artefact type. |
ArtefactInfo
|
getArtefactInfo(java.lang.String artefactType)
|
ArtefactHandler
|
getArtefactType(java.lang.Class theClass)
|
GrailsClass[]
|
getArtefacts(java.lang.String artefactType)
|
java.lang.Class
|
getClassForName(java.lang.String className)
|
java.lang.ClassLoader
|
getClassLoader()
|
groovy.util.ConfigObject
|
getConfig()
|
protected GrailsClass
|
getFirstArtefact(java.lang.String artefactType)
|
java.util.Map
|
getFlatConfig()
|
org.springframework.context.ApplicationContext
|
getMainContext()
|
Metadata
|
getMetadata()
|
org.springframework.context.ApplicationContext
|
getParentContext()
|
java.lang.Object
|
getProperty(java.lang.String propertyName)
Override property access and hit on xxxxClasses to return class arrays of artefacts. |
org.springframework.core.io.Resource
|
getResourceForClass(java.lang.Class theClazz)
Retrieves the Spring Resource that was used to load the given Class. |
boolean
|
hasArtefactHandler(java.lang.String type)
|
protected void
|
initArtefactHandlers()
Initialises the default set of ArtefactHandler instances. |
void
|
initialise()
|
protected void
|
initializeArtefacts(java.lang.String artefactType)
Clears the application returning it to an empty state. |
protected void
|
initializeArtefacts(ArtefactHandler handler)
|
java.lang.Object
|
invokeMethod(java.lang.String methodName, java.lang.Object args)
|
boolean
|
isArtefact(java.lang.Class theClazz)
|
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()
|
protected java.lang.Class[]
|
populateAllClasses()
|
void
|
rebuild()
|
void
|
refresh()
Refreshes this GrailsApplication, rebuilding all of the artefact definitions as defined by the registered ArtefactHandler instances. |
protected void
|
refreshArtefactGrailsClassCaches()
Tell all our artefact info objects to update their internal state after we've added a bunch of classes. |
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(org.springframework.context.ApplicationContext applicationContext)
|
void
|
setBeanClassLoader(java.lang.ClassLoader classLoader)
|
void
|
setConfig(groovy.util.ConfigObject config)
|
void
|
setMainContext(org.springframework.context.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() |
Field Detail |
---|
protected static final java.util.regex.Pattern GETCLASSESMETH_PATTERN
protected static final java.util.regex.Pattern GETCLASSESPROP_PATTERN
protected static final java.util.regex.Pattern GETCLASS_PATTERN
protected static final java.util.regex.Pattern ISCLASS_PATTERN
protected java.util.List allArtefactClasses
protected java.lang.Class[] allArtefactClassesArray
protected java.lang.Class[] allClasses
protected Metadata applicationMeta
protected ArtefactHandler[] artefactHandlers
protected java.util.Map artefactHandlersByName
protected java.util.Map artefactInfo
protected java.lang.ClassLoader cl
protected groovy.util.ConfigObject config
@SuppressWarnings("rawtypes") protected java.util.Map flatConfig
protected boolean initialised
protected java.util.List loadedClasses
protected static org.apache.commons.logging.Log log
protected org.springframework.context.ApplicationContext mainContext
protected org.springframework.context.ApplicationContext parentContext
protected org.springframework.core.io.Resource[] resources
Constructor Detail |
---|
public DefaultGrailsApplication()
public DefaultGrailsApplication(java.lang.Class[] classes, java.lang.ClassLoader classLoader)
classes
- The classes that make up the GrailsApplicationclassLoader
- The GroovyClassLoader to use
public DefaultGrailsApplication(org.springframework.core.io.Resource[] resources)
public DefaultGrailsApplication(Resource[] resources)
Method Detail |
---|
public GrailsClass addArtefact(java.lang.String artefactType, fied GrailsClass is not the sa java.lang.Class artefactClass)
public GrailsClass addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsClass)
public void addArtefact( java.lang.Class artefact)
protected GrailsClass addArtefact(java.lang.String artefactType, java.lang.Class artefactClass, boolean overrideable)
public void addOverridableArtefact(the artefact as defined by a java.lang.Class artefact)
public GrailsClass addOverridableArtefact(java.lang.String artefactType, java.lang.Class artefactClass)
protected void addToLoaded(java.lang.Class clazz)
public void clear()
public void configChanged()
protected void configureLoadedClasses(java.lang.Class[] classes)
classes
- The classes to configure
public java.lang.Class[] getAllArtefacts()
public java.lang.Class[] getAllClasses()
public GrailsClass getArtefact(java.lang.String artefactType, java.lang.String name)
public GrailsClass getArtefactByLogicalPropertyName(java.lang.String type, java.lang.String logicalName)
protected int getArtefactCount(java.lang.String artefactType)
public GrailsClass getArtefactForFeature(java.lang.String artefactType, java.lang.Object featureID)
public ArtefactHandler getArtefactHandler(java.lang.String type)
public ArtefactHandler[] getArtefactHandlers()
protected DefaultArtefactInfo getArtefactInfo(java.lang.String artefactType, boolean create)
artefactType
- The name of an artefact typecreate
- Set to true if you want non-existent caches to be created
public ArtefactInfo getArtefactInfo(java.lang.String artefactType)
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 ArtefactHandler getArtefactType( java.lang.Class theClass)
public GrailsClass[] getArtefacts(java.lang.String artefactType)
public java.lang.Class getClassForName(java.lang.String className)
public java.lang.ClassLoader getClassLoader()
public groovy.util.ConfigObject getConfig()
protected GrailsClass getFirstArtefact(java.lang.String artefactType)
* public java.util.Map getFlatConfig()
public org.springframework.context.ApplicationContext getMainContext()
public Metadata getMetadata()
public org.springframework.context.ApplicationContext getParentContext()
} 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 org.springframework.core.io.Resource getResourceForClass(s an artefact identified by on java.lang.Class theClazz)
theClazz
- The class
public boolean hasArtefactHandler(java.lang.String type)
protected void initArtefactHandlers()
public void initialise()
protected void initializeArtefacts(java.lang.String artefactType)
protected void initializeArtefacts(ArtefactHandler handler)
"Dynamic method getClass(artefactName) requires a single String parameter"); public java.lang.Object invokeMethod(java.lang.String methodName, java.lang.Object args)
public boolean isArtefact( java.lang.Class theClazz)
public boolean isArtefactOfType(java.lang.String artefactType, 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()
protected java.lang.Class[] populateAllClasses()
public void rebuild()
public void refresh()
protected void refreshArtefactGrailsClassCaches()
public void refreshConstraints()
public void registerArtefactHandler(ArtefactHandler handler)
handler
- The ArtefactHandler to regster
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
public void setBeanClassLoader(java.lang.ClassLoader classLoader)
public void setConfig(groovy.util.ConfigObject config)
public void setMainContext(org.springframework.context.ApplicationContext context)
Groovy Documentation