Grails Architecture
General Architecture
Grails is an open source web application framework which uses the Groovy programming language (which in turn is based on the Java platform). It is intended to be a high-productivity framework by following the “coding by convention” paradigm, providing a stand-alone development environment and hiding much of the configuration detail from the developer. Grails’ choice of Groovy and all the other components it uses makes it a very compelling platform for high-traffic and complex applications.
The commons package
The core Grails classes that make up the foundation of Grails can be found in the org.codehaus.groovy.grails.commons package. The classes within this package deal with the conventions and most implement the interface org.codehaus.groovy.grails.commons.GrailsClasswhich defines methods for retrieving various representations of the class name based on the convention.
The classes themselves are loaded into an instance of org.codehaus.groovy.grails.commons.GrailsApplication the default implementation for which can be found here.
The DefaultGrailsApplication class defines two constructors one which takes an array of Spring resources. The resources are a set of the set of .groovy files that resides within the grails-app directory and are loaded by the Spring applicationContext.xml file found in the WEB-INF directory. The DefaultGrailsApplication class also defines a constructor that takes an array of classes which is mainly used in test cases for example:
GroovyClassLoader gcl = new GroovyClassLoader();
Class domainClass = gcl.parseClass("class Test { Long id; Long version; }" );
Class controller = gcl.parseClass("class TestController { def list = {} }");
GrailsApplication app = new DefaultGrailsApplication( new Class[] {
domainClass, controller } );
Utility Classes for the commons package
There are a number of utility classes for working with the commons package. The classorg.codehaus.groovy.grails.commons.GrailsClassUtils provides methods for evaluating the conventions of classes and retrieving different naming representations. Since 0.5 these convention evaluation methods are removed and are available on GrailsApplication via theDeveloper - Artefact API.
org.codehaus.groovy.grails.io.support.GrailsResourceUtils provides methods for working with Grails resources before they are loaded into classes (ie the .groovy files themselves and where they reside in the app structure).
The org.codehaus.groovy.grails.commons.GrailsResourceLoader class is an instance of groovy.lang.ResourceLoader. This class is set on the GroovyClassLoader instance and ensures that classes can be loaded from Spring Resource instances.
source:wiki



Comments
Post a Comment