YES! thank you so much this really helps!
Piero Sartini-3 wrote:
>
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/howto-implement-a-%40before-annotation---tp21915451p21916477.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]