Did you try invocation.getInstance().getAnnotation() ? On Oct 22, 2012, at 1:15 PM, Rural Hunter wrote:
> Hi, > > I have an annotation: > @Documented > @Retention(RetentionPolicy.RUNTIME) > @Target(ElementType.METHOD) > public @interface Audit > { > String operate() default ""; > String desc() default ""; > int type(); > int idParamIndex() default 0; > } > > I put on some methods of my DAO services and advised them in AppModule: > > DAOInterface: > @Audit(type=1) > public void delete(int id) throws Exception; > > AppModule: > for (Method m : receiver.getInterface().getMethods()) > { > if (m.getAnnotation(Audit.class) != null) > { > System.out.println("advising "+m.getName()); > receiver.adviseMethod(m, advice); > } > } > > There is no problem and I can see the methods are advised by the System.out > above. But in the advise method, I can not get the Audit annotation: > public void advise(MethodInvocation invocation) > { > String methodName = invocation.getMethod().getName(); > Audit audit = invocation.getAnnotation(Audit.class); > System.out.println("method="+methodName+", audit="+audit); > invocation.proceed(); > } > > The above advise method is called and I can see the system.out is always like > this: "method=delete, audit=null". I need some information in the Audit > annotation but why I can not get the annotation instance? > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org