package com.zlb.service;
public interface IHelloWorldService {
public void sayHello();
}
package com.zlb.service.imp;
import com.zlb.service.IHelloWorldService;
public class HelloWorldService implements IHelloWorldService{
@Override
public void sayHello() {
System.out.println("============Hello World!");
}
}
package com.zlb.aop;
import org.aspectj.lang.ProceedingJoinPoint;
public class HelloWorldAspect {
//前置通知
public void beforeAdvice() {
System.out.println("===========before advice");
}
}
<bean id="helloWorldService" class="com.zlb.service.imp.HelloWorldService"/>
<bean id="aspect" class="com.zlb.aop.HelloWorldAspect"/>
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.zlb.service.*.*(..))"/>
<aop:aspect ref="aspect">
<aop:before pointcut-ref="pointcut" method="beforeAdvice"/>
</aop:aspect>
</aop:config>
===========before advice
============Hello World!admin
===========after finally advice
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者