On Monday 09 February 2009 16:43:09 xianwinwin wrote: > Hi all, > here's a scenario:I have some methods that before executed, they should run > an interceptor --to verify if the user is authorized to do something.
Write your own interceptor and check for your annotation. Something like this should work (I am using a custom annotation named @Secured): public String intercept(ActionInvocation actionInvocation) throws Exception { Object action = actionInvocation.getAction(); // get the action on which the interceptor is fired Class[] ca = {}; Method m = action.getClass().getMethod(actionInvocation.getProxy().getMethod(), ca); // get executed method Class c = action.getClass(); boolean classAnnotation = c.isAnnotationPresent(Secured.class); boolean methodAnnotation = m.isAnnotationPresent(Secured.class); // check if either method or class is annotated with @Secured if (classAnnotation || methodAnnotation) { ... ... Have fun :-) Piero --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org