I'm learning spring (via "Spring in Action") and to that end I put together a simple app. While the DI works, the aspect does not. Following is my code, anyone see what is wrong?
Code:package learn.spring.implementations; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; @Aspect public class Audience { public Audience() {} @Pointcut("execution(* *.perform(..))") public void performance() {} @Before("performance()") public void takeSeats() { System.out.println("Audience is taking their seats"); } }Code:package learn.spring.implementations; import learn.spring.interfaces.Performer; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class Performance { public static void main(String[] args){ ApplicationContext context = new FileSystemXmlApplicationContext("src/learn/spring/config/learn-spring.xml"); Performer performer = (Performer) context.getBean("musician"); performer.perform(); } }Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:annotation-config /> <aop:aspectj-autoproxy /> ... </beans>


Reply With Quote
