8.5.3 Ordering Interceptor Execution 6.0.0

(Quick Reference) # 8.5.3 Ordering Interceptor Execution Version: 6.0.0 ## 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. Interceptor execution order is determined by sorting the `order` property in an ascending direction and executing the lowest numerically ordered interceptor first. 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

    // or

    int 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)