Annotation Interface OnRequest


@Documented @Target(METHOD) @Retention(RUNTIME) public @interface OnRequest
The annotated static methods are invoked with two optional arguments HttpServletRequest and ControllerAttributes when the controller owing them are requested. The methods are executed in the thread of the corresponding HTTP request. Thread locals set by interceptors or filters, thus, are accessible from the methods.
 @OnRequest
 static void onRequest( HttpServletRequest request, ControllerAttributes attributes ){
    // Update controller attributes here
 }
 
The arguments are optional. All of the following are also, thus, valid.
 @OnRequest
 static void onRequest(){}

 @OnRequest
 static void onRequest( HttpServletRequest request ){}

 @OnRequest
 static void onRequest( ControllerAttributes attributes ){}
 
Values set to the second argument attributes are accessible by ControllerContext.getAttributes() as follows:
 @Controller
 class MyController extends AbstractController {
     @OnRequest
     static void onRequest( HttpServletRequest request, ControllerAttributes attributes ){
         attributes.put( "name", "Cardinal" );
     }

     void method(){
         System.out.println( getAttributes().get( "name" ) ); // prints "Cardinal"
     }
 }