Last updated by admin 4 years ago
Runtime Configuration
Grails automatically configures itself at runtime using the conventions within the classes and Spring. The class that performs the runtime configuration is called org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator which takes a GrailsApplication and produces a bunch of bean references which can be used to create a Spring application context.The GrailsRuntimeConfigurator class does many things including, but not limited to:- Configuring the data source
- Setting up the Hibernate session factory
- Creating the handler mappings for the Spring MVC servlet
- Setting up any Quartz scheduled tasks
- Configuring Grails service classes for transaction demarcation
ApplicationContext parent = new ClassPathXmlApplicationContext("applicationContext.xml"); DefaultGrailsApplication application = (DefaultGrailsApplication)parent.getBean("grailsApplication", DefaultGrailsApplication.class); GrailsRuntimeConfigurator config = new GrailsRuntimeConfigurator(application,parent); ApplicationContext appCtx = config.configure(new MockServletContext());



