首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

XML配备AOP

2012-09-09 
XML配置AOPpackage com.zchen.aopimport org.aspectj.lang.ProceedingJoinPointimport org.aspectj.lang

XML配置AOP

package com.zchen.aop;import org.aspectj.lang.ProceedingJoinPoint;import org.aspectj.lang.annotation.Around;import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotation.Before;import org.aspectj.lang.annotation.Pointcut;public class LogInterceptor {public void myMethod(){};public void before() {System.out.println("method before");}public void aroundMethod(ProceedingJoinPoint pjp) throws Throwable {System.out.println("method around start");pjp.proceed();System.out.println("method around end");}}

?

<?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:context="http://www.springframework.org/schema/context"       xmlns:aop="http://www.springframework.org/schema/aop"       xsi:schemaLocation="http://www.springframework.org/schema/beans           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd           http://www.springframework.org/schema/context           http://www.springframework.org/schema/context/spring-context-2.5.xsd           http://www.springframework.org/schema/aop           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"><context:annotation-config /><context:component-scan base-package="com.zchen"/><bean id="logInterceptor" ref="logInterceptor"><aop:before method="before" pointcut="execution(public * com.zchen.service..*.add(..))" /></aop:aspect></aop:config></beans>

?

热点排行