how to pass request parameters to a java annotation

i am using play framework , i need to check the user's permissions with @secure annotation , but i get a problem here :

@secure(UID=???)
public static void removeFavorite(Long storyId,Long userId){

}

can any one tell me how to pass the "userId" parameter to "UID" in the annotation ?

PS : the "userId" parameter is in request scope.

many thanks!

Answers


AFAIK you can't change annotations at runtime (at least not without dynamic code generation). Additionally, annotations are static, i.e. they apply to classes or class members (fields, methods etc.) and can't be changed per instance. Thus you can't pass the userId to that annotation.

I dont know what@securedoes, but generally, you'd read the annotation at runtime and optionally check its static parameters and if those checks succeed you'd read theuserId` parameter and do whatever is appropriate when that annotation is present.


Need Your Help

Consecutive dates postgresql

sql postgresql gaps-and-islands

I need to know if there are no consecutive dates per document. I have this table:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.