Parameter names are available at runtime if the code is compiled with debug 
information (even in production environments, it is not uncommon for the 
release build to include this). Spring uses ASM internally to parse the names 
out of the bytecode, using its LocalVariableTableParameterNameDiscoverer. For 
Spring-based systems that always compile with debugging information, this might 
be a solid approach.
Otherwise, a fallback approach that allows referring to parameters by number 
(1-based) or index (0-based) might be a good catch-all solution that would work 
in any AOP environment.
I'd be happy to help contribute an implementation of this feature.
Bryan

Date: Tue, 9 Nov 2010 14:30:10 -0800
Subject: Re: Shiro + AspectJ - accessing variables in annotations
From: [email protected]
To: [email protected]

Hi Nassos,
This is something that we've wanted for Shiro annotations for a long time, but 
no one has built it yet.  I'm not sure off the top of my head how to go about 
doing this, but I remember seeing Spring AOP have the ability to reference 
method arguments by parameter name (this was a while ago, but I know it is 
possible).  Since that information is lost at runtime, I think is a compile 
time feature.  That, or you annotate method parameters that could be accessed 
at runtime.

I think it would be great if someone wanted to help with this!
Cheers,
Les

On Tue, Nov 9, 2010 at 5:49 AM, Nassos A. Michas <[email protected]> 
wrote:

Hello,
when using Shiro in a non-Spring webapp using the Shiro annotations and AspectJ 
(as per the Shiro sample application) is it possible to somehow have access to 
the member (or even the annotated method's) variables? For example, am I 
somehow able to write something like:
@RequiresPermission("forum:readTopic:#forumID")void readTopic(String forumID) 
{...}
or even,@RequiresPermission("forum:readTopic:#forum.forumID")
void readTopic(MyBean forum) {...}



If this is more of an AspectJ-related question please accept my apologies as 
I'm not a big AspectJ user.


Thanks!

-n-
                                          

Reply via email to