8.5.3 Ordering Interceptor Execution 3.1.10

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 8.5.3 Ordering Interceptor Execution - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 3.1.10 ## 8.5.3 Ordering Interceptor Execution Interceptors can be ordered by defining an `order` property that defines a priority. For example:

    class AuthInterceptor {  int order = HIGHEST_PRECEDENCE  …
    }
The default value of the `order` property is 0. The values `HIGHEST_PRECEDENCE` and `LOWEST_PRECEDENCE` can be used to define filters that should should run first or last respectively. Note that if you write an interceptor that is to be used by others it is better increment or decrement the `HIGHEST_PRECEDENCE` and `LOWEST_PRECEDENCE` to allow other interceptors to be inserted before or after the interceptor you are authoring:

    int order = HIGHEST_PRECEDENCE + 50// orint order = LOWEST_PRECEDENCE - 50
To find out the computed order of interceptors you can add a debug logger to `logback.groovy` as follows:
    logger 'grails.artefact.Interceptor', DEBUG, ['STDOUT'], false
You can override any interceptors default order by using bean override configuration in `grails-app/conf/application.yml`:
    beans:
      authInterceptor:
        order: 50
Or in `grails-app/conf/application.groovy`:
    beans {
      authInterceptor {
        order = 50
      }
    }
Thus giving you complete control over interceptor execution order. | Quick Reference (hide)