Hi,
I have question regarding aspects. I created an aspect with @AspectJ annotation. The aspect looks like this:
The methods where it should be applied on is:Code:@Aspect @Component public class ExecutionTrackerAspect { DateTime date; Log log = LogFactory.getLog(getClass()); @Before("execution(* doTest(..))") public void executionStart() { System.out.println("Message recieved and execution is starting: " + date.toString()); } @After("execution(* doTest(..))") public void executionEnd() { System.out.println("Message recieved and execution was done: " + date.toString()); } @Pointcut("execution(* doTest(..))") public void testPointCut() { System.out.println("FAXEN"); } }
For my test the instantiation looks like this:Code:@Override public void onMessage(Message message, Channel channel) throws Exception { Job job = convertMessage(message); Thread.sleep(2000); System.out.println("received: " + job.getCommand()); doTest(); channel.basicAck(message.getMessageProperties().getDeliveryTag(), true); } public void doTest() { System.out.println("I AM DOING TESTS"); }
With the ConsumerConfiguration.classCode:ApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
My aspect-config.xml looks like this:Code:@Configuration @ImportResource("classpath:/de/sample/package/logging/aspects-config.xml") public class ConsumerConfiguration extends ServiceAMQPConfiguration { ...
If I take a look at the stack-trace I can also see this:Code:<context:component-scan base-package="de.sample.package.logging" /> <aop:aspectj-autoproxy />
The problem is, that the System.out.println("Message...."); never gets executed. Any idea?Code:2011-10-25 18:42:46,694 DEBUG [org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory] - <Found AspectJ method: public void de.sample.package.logging.ExecutionTrackerAspect.executionException(java.lang.Exception)> 2011-10-25 18:42:46,882 DEBUG [org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory] - <Found AspectJ method: public void de.sample.package.logging.ExecutionTrackerAspect.executionStart()> 2011-10-25 18:42:46,882 DEBUG [org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory] - <Found AspectJ method: public void de.sample.package.logging.ExecutionTrackerAspect.executionEnd()>


Reply With Quote