????applicationContext.xml????
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
4     xsi:schemaLocation="
5             http://www.springframework.org/schema/beans
6             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7             http://www.springframework.org/schema/aop
8             http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
9             http://www.springframework.org/schema/context
10             http://www.springframework.org/schema/context/spring-context-3.0.xsd">
11     <aop:aspectj-autoproxy/>
12     <!-- ???????? LogAspect-->
13     <bean id="logAspect" class="com.test.LogAspect"/>
14     <!-- ???????? -->
15     <bean name="test" class="com.test.TestServiceImpl"></bean>
16     <!-- AOP???? -->
17     <aop:config>
18         <aop:aspect id="simpleApect" ref="logAspect">
19             <!-- ????????? -->
20             <aop:pointcut expression="execution(* com.test..*(..))" id="simplePointCut"/>
21             <!-- ?????? -->
22             <aop:before method="beforeShow" pointcut-ref="simplePointCut"/>
23             <aop:after method="afterShow" pointcut-ref="simplePointCut"/>
24             <!-- <aop:after-returning method="afterReturn" pointcut-ref="simplePointCut"/> -->
25             <aop:after-throwing method="doAfterThrowing" pointcut-ref="simplePointCut" throwing="ex"/>
26         </aop:aspect>
27     </aop:config>
28 </beans>
?????????????
1 package com.test;
2
3
4 import java.util.ArrayList;
5 import java.util.List;
6
7 import org.springframework.context.support.ClassPathXmlApplicationContext;
8
9 public class TestMain{
10         public static void main(String[] args) {
11             //???BeanFactory
12             ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext("applicationContext.xml");
13             TestService test = (TestService)factory.getBean("test");
14             List l = new ArrayList();
15             l.add("param1");
16             l.add("param2");
17             l.add("param3");
18             //???ò??????
19             test.test("ok"??1??l);
20         }
21 }
?????????????????????????????????????????xml???÷?????????о?...??????????????????????????з??????ν???????????????????????
??????????????????Spring????У?Spring????????Spring AOP??????