2
votes

First I'm new to grails as well website development.I started grails project and studying. I'm clear about grails concepts like Domain class, controller, view, agile development like this.

While executing grails run-app command, at which point does grails start execution in the framework and run (like main() method in Java)?

Which is the first entry place domain or controller or view or main.gsp in my project from where it is coming from grails framework?

3
Why do you want to know? In general, Grails is designed to respond to web requests, so where it's execution starts is rather irrelevant, in my opinion. - cdeszaq

3 Answers

2
votes
  1. When server starts up, Bootstrap.groovy is executed.
  2. For listening to each request you probably would need to define your own filter.
  3. However the very beginning of every request is the org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.
1
votes

When a request comes in, grails determines the controller and the action (based on the URL and any UrlMappings you've specified) and calls it. So from your application code's point of view, the starting point is one of your actions.

For example:

If a user requests http://abc.com/book/list, where abc.com is your site, the method def list() in your BookController.groovy is the starting point.

Internally, grails calls each closure in AppFilters.groovy (and other filters defined by you or the plugins you are using) if any before calling your controller's action. If you are developing a very simple app, those wouldn't matter.

0
votes

Grails incorporates the powerful build system Gant, which is a Groovy wrapper around Apache Ant.

When you run the command : Grails [commad-name],

Grails searches in the following directories for Gant scripts to execute:

USER_HOME/.grails/scripts
PROJECT_HOME/src/main/scripts/
PROJECT_HOME/plugins/*/scripts
GRAILS_HOME/scripts

When you execute Grails run-app command, It will execute the file RunApp.groovy file from above mentioned paths. These are groovy files, once you look into files, you will understand the code inside that.