锘??xml version="1.0" encoding="utf-8" standalone="yes"?>日韩一区二区不卡,国产欧美高清视频在线,免费成人在线观看http://www.aygfsteel.com/znLin/zh-cnWed, 18 Jun 2025 18:47:32 GMTWed, 18 Jun 2025 18:47:32 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緇撴潫
------------------------------------------------------
絎竴嬈″啓鍗氬錛屼笉浼氳緗慨鏀瑰浘鐗囷紝浠ュ悗瀛︿範錛屽啓鐨勪笉濂斤紝鐪嬭呰璋咃紒錛侊紒

]]>
主站蜘蛛池模板:
汪清县|
鹿邑县|
中方县|
肇州县|
许昌县|
恭城|
荣昌县|
吴江市|
获嘉县|
乌苏市|
泽州县|
临安市|
十堰市|
兴宁市|
八宿县|
宁蒗|
达日县|
夏河县|
雅安市|
皮山县|
韶关市|
慈溪市|
久治县|
瑞丽市|
九江县|
鄱阳县|
玉屏|
烟台市|
广河县|
竹溪县|
伽师县|
农安县|
新田县|
河曲县|
大英县|
承德市|
穆棱市|
高唐县|
什邡市|
黄陵县|
河西区|