対以内に私は内とターゲットポイントカット指定の間で異なる理解できませんでした。 例を見て:春AOPは、ターゲット指示
@Component
public interface Icamera {
public void snap() throws Exception;
}
@Component
class Camera implements Icamera{
public void snap() throws Exception {
System.out.println("SNAP!");
}
}
@Aspect
@Component
public class Logger {
**@Pointcut("within(com.test.aop.Icamera)")**
public void cameraSnap() {
}
@Before("cameraSnap()")
public void beforeAdvice() {
System.out.println("Before advice ...");
}
@After("cameraSnap()")
public void afterAdvice() {
System.out.println("After advice ...");
}
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
Icamera camera=context.getBean(Icamera.class);
camera.snap();
}
}
出力は次のようになります。 SNAP! しかし、あなたは内の代わりにターゲットを使用する場合、出力は次のとおりです。 アドバイスする前に... SNAP!アドバイスの後 ...