Interceptor (Grails 6.0.0)

Package: grails.artefact

## [Groovy] Trait Interceptor

- grails.artefact.Interceptor

- All Implemented Interfaces and Traits:
    DataBinder, RequestForwarder, ResponseRedirector, ResponseRenderer, ServletAttributes, WebAttributes, org.springframework.core.Ordered

      @groovy.transform.Trait
      @groovy.transform.CompileStatic
      trait Interceptor
      extends java.lang.Object
      implements DataBinder, RequestForwarder, ResponseRedirector, ResponseRenderer, ServletAttributes, WebAttributes, org.springframework.core.Ordered

  An interceptor can be used to intercept requests to controllers and URIs They replace the notion of filters from earlier versions of Grails, prior to Grails 3.0

  Authors:
    Graeme Rocher
  Since:
    3.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private java.util.Collection<Matcher>` | `matchers` | The matchers defined by this interceptor
    `private int` | `order` | The order the interceptor should execute in

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `java.util.Map<java.lang.String, java.lang.Object>` | `model`
    `org.springframework.web.servlet.ModelAndView` | `modelAndView`
    `int` | `order`
    `java.lang.String` | `view`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `boolean` | `after()` Executed after the action executes but prior to view rendering
    `` | `void` | `afterView()` Executed after view rendering completes
    `` | `boolean` | `before()` Executed before a matched action
    `` | `boolean` | `doesMatch()` Returns: Whether the current interceptor does match
    `` | `boolean` | `doesMatch(javax.servlet.http.HttpServletRequest request)` Returns: Whether the current interceptor does match
    `` | `java.util.Collection<Matcher>` | `getMatchers()` The matchers defined by this interceptor
    `` | `java.util.Map<java.lang.String, java.lang.Object>` | `getModel()` Returns: The current model
    `` | `org.springframework.web.servlet.ModelAndView` | `getModelAndView()` Obtains the ModelAndView for the currently executing controller
    `` | `int` | `getOrder()` The order the interceptor should execute in
    `` | `java.lang.Throwable` | `getThrowable()` Obtains the exception thrown by an action execution
    `` | `java.lang.String` | `getView()` Returns: The current view
    `` | `void` | `header(java.lang.String headerName, java.lang.Object headerValue)` Sets a response header for the given name and value
    `` | `Matcher` | `match(java.util.Map arguments)` Used to define a match.
    `` | `Matcher` | `matchAll()` Matches all requests
    `` | `void` | `render(java.util.Map argMap)` Overridden render method that renders the view directly inside before()
    `` | `void` | `setModel(java.util.Map<java.lang.String, java.lang.Object> model)` Sets the model
    `` | `void` | `setModelAndView(org.springframework.web.servlet.ModelAndView mav)` Sets the ModelAndView of the current controller
    `` | `void` | `setOrder(int order)` The order the interceptor should execute in
    `` | `void` | `setView(java.lang.String view)` Sets the view name

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private final java.util.Collection<Matcher> matchers

      The matchers defined by this interceptor

    - #### private int order

      The order the interceptor should execute in

  - ### Property Detail

    - #### java.util.Map<java.lang.String, java.lang.Object> model

    - #### org.springframework.web.servlet.ModelAndView modelAndView

    - #### int order

    - #### java.lang.String view

  - ### Method Detail

    - #### @groovy.transform.Generated boolean after()

      Executed after the action executes but prior to view rendering

      Returns:
        True if view rendering should continue, false otherwise

    - #### @groovy.transform.Generated void afterView()

      Executed after view rendering completes

      Parameters:
        `t` - The exception instance if an exception was thrown, null otherwise

    - #### @groovy.transform.Generated boolean before()

      Executed before a matched action

      Returns:
        Whether the action should continue and execute

    - #### @groovy.transform.Generated boolean doesMatch()

      Returns:
        Whether the current interceptor does match

    - #### @groovy.transform.Generated boolean doesMatch(javax.servlet.http.HttpServletRequest request)

      Returns:
        Whether the current interceptor does match

    - #### @groovy.transform.Generated java.util.Collection<Matcher> getMatchers()

      The matchers defined by this interceptor

    - #### @groovy.transform.Generated java.util.Map<java.lang.String, java.lang.Object> getModel()

      Returns:
        The current model

    - #### @groovy.transform.Generated org.springframework.web.servlet.ModelAndView getModelAndView()

      Obtains the ModelAndView for the currently executing controller

      Returns:
        The ModelAndView

    - #### @groovy.transform.Generated int getOrder()

      The order the interceptor should execute in

    - #### @groovy.transform.Generated java.lang.Throwable getThrowable()

      Obtains the exception thrown by an action execution

      Parameters:
        `t` - The exception or null if none was thrown

    - #### @groovy.transform.Generated java.lang.String getView()

      Returns:
        The current view

    - #### @groovy.transform.Generated void header(java.lang.String headerName, java.lang.Object headerValue)

      Sets a response header for the given name and value

      Parameters:
        `headerName` - The header name
        `headerValue` - The header value

    - #### @groovy.transform.Generated Matcher match(java.util.Map arguments)

      Used to define a match. Example: match(controller:'book', action:'*')

      Parameters:
        `arguments` - The match arguments

    - #### @groovy.transform.Generated Matcher matchAll()

      Matches all requests

    - #### @groovy.transform.Generated void render(java.util.Map argMap)

      Overridden render method that renders the view directly inside before()

      Parameters:
        argMap

    - #### @groovy.transform.Generated void setModel(java.util.Map<java.lang.String, java.lang.Object> model)

      Sets the model

      Parameters:
        `model` - The model to set

    - #### @groovy.transform.Generated void setModelAndView(org.springframework.web.servlet.ModelAndView mav)

      Sets the ModelAndView of the current controller

      Parameters:
        `mav` - The ModelAndView

    - #### @groovy.transform.Generated void setOrder(int order)

      The order the interceptor should execute in

    - #### @groovy.transform.Generated void setView(java.lang.String view)

      Sets the view name

      Parameters:
        `view` - The name of the view