学习java100多天和3天的记录----简单的配置AOP等等等等
1、配置XML定义AOP
<bean id=”logAspect” class=”com.bwf.aspect.LogAspect”></bean>
<aop:config>
//切面类
<aop:aspect id=”log” ref=”logAspect” >
//切入点
<aop : pointcut id=”logPointCut” expression="execution(* com.*.*.*(..))"/>
//切入方法 pointcut-ref :切到哪写切入点(类)
<aop: before method=”logBefore” pointcut-ref=”logPointCut”/>
</aop:aspect>
</aop:config>
2、使用注解配置AOP
//用@compoment配置bean,并且用@aspect把这个类定义为切面类。
@compoment
@aspect
public class LogAspect{
Logger logger=LoggerFactory.getLogger(LogAspect.class);
//定义切入点
@pointcut(“execution(*.com.dao..*.*(..))”)
//1、引入上面的切入点,哪个类要被切入。
//2、自定义切入方法。
@Before(value=”pointcut()”)
public void logBefore(JointPoint jointPoint){
//织入方法的执行。
}