• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

controller superclass method invocation in spring 3.0

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a abstract superclass controller as below:


There is another controller which extends this class and has a request mapping specified for one of its methods:


Now the issue here is that when dispatcher servlet redirects the request to the specific method (populateBeta in this case), i need to check for some request parameters modified in a separate interceptor class first.
So essentially i have to invoke the throwInterceptorExceptionForRedirection() method before the normal execution of populateBeta() begins.

The reason to eliminate the explicit call in the controller method is because i have multiple controllers & their mapped methods. All controllers extend the BaseController.
It would be great to have throwInterceptorExceptionForRedirection() executed before any URL mapped methods are invoked by the applicationcontext directly.

using point cuts as an option doesnt help as i need the HttpServletRequest object in throwInterceptorExceptionForRedirection().

Any suggestion/help?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, you can try using filter with url pattern "/*" & you still have access to the request object. Let me know if you something better & specific in Spring for the mentioned task.
Apart from this I could really understand why exactly are using InterceptorExceptionForRedirection() ?.
Regards
 
Yogesh Mashalkar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mudassar,

cannot use filters as i am using the @ExceptionHandler annotation which is applicable only for the specific class(BetaController in this case). this annotation handles all exceptions in all the controllers.
but i am already invoking a interceptor on the "/*" url pattern, which essentially does some loading stuff. if any exception occurs there i am setting a flag in the request object which i can access in the controller.

when the flag is true i am deliberately throwing an exception in the controller, which is handled by the @ExceptionHandler annotation. thats the reason i need to invoke the throwInterceptorExceptionForRedirection() before any other invocations in the controller

i am achieving this but have to add throwInterceptorExceptionForRedirection() call as the first line of all child controllers, since i do not know a way to make spring invoke it automatically for every controller

below is the complete BaseController class:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic