锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国内精品久久久久久久久电影网,亚洲国产精品成人久久综合一区,亚洲va久久久噜噜噜久久http://www.aygfsteel.com/znLin/zh-cnThu, 19 Jun 2025 04:57:02 GMTThu, 19 Jun 2025 04:57:02 GMT60- Spring涓嬌鐢ˋOP鐨勭畝鍗曚緥瀛?/title>http://www.aygfsteel.com/znLin/archive/2011/03/21/346696.htmlz_clear_nz_clear_nMon, 21 Mar 2011 10:26:00 GMThttp://www.aygfsteel.com/znLin/archive/2011/03/21/346696.htmlhttp://www.aygfsteel.com/znLin/comments/346696.htmlhttp://www.aygfsteel.com/znLin/archive/2011/03/21/346696.html#Feedback0http://www.aygfsteel.com/znLin/comments/commentRss/346696.htmlhttp://www.aygfsteel.com/znLin/services/trackbacks/346696.html
1銆侀鍏堬紝鍒涘緩鎺ュ彛BookService(鍖卌om.Vy.spring.Biz)
package com.Vy.spring.Biz;
public interface BookService {
public boolean buy(String userName,String bookName,double price);
}
2銆佸垱寤烘帴鍙e疄鐜扮被BookServiceImpl(鍖卌om.Vy.spring.BizImpl)
package com.Vy.spring.BizImpl;
import com.Vy.spring.Biz.BookService;
public class BookServiceImpl implements BookService {
@Override
public boolean buy(String userName, String bookName, double price) {
// TODO Auto-generated method stub
System.out.println("涓氬姟鏂規硶buy寮濮嬫墽琛?);
System.out.println("·"+userName+"璐拱鍥句功錛?+bookName);
System.out.println("·"+userName+"澧炲姞縐垎"+(int)(price/10));
System.out.println("·"+"鍚戠墿嫻佺郴緇熶笅鍙戣揣鍗?);
System.out.println("涓氬姟鏂規硶buy緇撴潫");
return true;
}
}
3銆佹坊鍔爏pring鏀寔錛坰pring鐗堟湰涓?.5錛?br />
閫夋嫨AOP搴撳拰Spring Core鏀寔
涓嬩竴姝ヤ慨鏀箈ml鍚嶅瓧涓篴op.xml
4銆佺紪鍐檟ml鏂囦歡
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="bookServiceTarget" class="com.Vy.spring.BizImpl.BookServiceImpl"></bean>
<bean id="logAdvice" class="com.Vy.spring.BizImpl.LogAdvice"></bean>
<bean id="bookService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.Vy.spring.Biz.BookService</value>
</property>
<property name="interceptorNames">
<list><value>logAdvice</value></list>
</property>
<property name="target" ref="bookServiceTarget"></property>
</bean>
</beans>
5銆佸垱寤烘祴璇曠被test錛堝寘Test錛?br />
package Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.Vy.spring.Biz.BookService;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext context=new ClassPathXmlApplicationContext("aop.xml");
BookService bookService=(BookService)context.getBean("bookService");
bookService.buy("znLin", "spring in action", 20.00);
}
}
6銆佽繍琛屾祴璇曘佹樉紺虹粨鏋?br />
[緋葷粺鏃ュ織][2011 騫?03 鏈?21 鏃?06 鏃?21 鍒?28 縐抅buy([znLin, spring in action, 20.0])
涓氬姟鏂規硶buy寮濮嬫墽琛?br />
·znLin璐拱鍥句功錛歴pring in action
·znLin澧炲姞縐垎2
·鍚戠墿嫻佺郴緇熶笅鍙戣揣鍗?br />
涓氬姟鏂規硶buy緇撴潫
------------------------------------------------------
絎竴嬈″啓鍗氬錛屼笉浼氳緗慨鏀瑰浘鐗囷紝浠ュ悗瀛︿範錛屽啓鐨勪笉濂斤紝鐪嬭呰璋咃紒錛侊紒

]]>
主站蜘蛛池模板:
蚌埠市|
南京市|
滨海县|
美姑县|
开平市|
久治县|
竹溪县|
延津县|
榆中县|
景宁|
肃北|
军事|
盐池县|
定边县|
大邑县|
莒南县|
罗源县|
磴口县|
房山区|
屏山县|
南靖县|
平谷区|
资兴市|
青州市|
阿图什市|
岑溪市|
大埔区|
巢湖市|
贵州省|
天镇县|
洪湖市|
岐山县|
固安县|
凤阳县|
株洲县|
合川市|
堆龙德庆县|
秭归县|
武冈市|
宜都市|
浙江省|