java - How to get method result with annotation? -


i want result of method , enqueue them activemq. hence, decided create annotation(say @enqueue("my_queue")) gets result , send my_queue.

@responsebody @enqueue("my_queue") @requestmapping("/list") public myclass list() {   return myservice.getall(); } 

and here annotation itself:

@target(value = elementtype.method) @retention(retentionpolicy.runtime) public @interface enqueue {  /** * name of queue */ string value() default "general_message_queue";  } 

so should create such annotation(a-z please)?

aspects must looking for. since you're using spring, have spring aop: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html.

with advice @afterreturning , pointcut @annotation(package.to.enqueue), you'll able access returned value each time method annotated @enqueue called: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html#aop-advice-after-returning.

you'll able send queue.


Comments