Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

REST Interceptor argument passthrough  RSS feed

 
Shawn Eion Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this is the right forum. My question is about REST interceptors. I've got the code:









The output from the debug show that permissions values inside of the ResourceImpl contains the values I'd expect (foo,bar), but inside the interceptor, they're missing. Is there a way to get the arguments in ResourceImpl to pass through to the interceptor?

Log output looks like:

15:59:55,223 INFO [stdout] (default task-9) @edu.psu.swe.fortress.poc.interceptor.FortressProtected(permissions=[])
15:59:55,229 INFO [stdout] (default task-9) @edu.psu.swe.fortress.poc.interceptor.FortressProtected(permissions=[foo, bar])

Thanks in advance.
 
Shawn Eion Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was answered in another forum and I thought I'd share.

Look at this in your filter

corresponds to the filter class (whose annotation has no values). You instead need to get the annotation on the ResourceImpl

A couple options. You could explicitly use ResourceImpl.class.getAnnotation(...). But the problem with this is that once you bind more than one class, how do you match with class corresponds to which request. For that reason, the next option is more viable.

What you do is inject ResourceInfo. This this, you can call it's getResourceMethod or getResourceClass methods to get. These methods return the matched method and class, respectively. You could then check for the annotation at the class level as well as the method leve (as we are also allowed to bind at the method level). So you might have something more like:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!