城市獵人
在一網情深的日子里,誰能說得清是苦是甜,只知道確定了就義無反顧
posts - 1, comments - 7, trackbacks - 0, articles - 89
導航
BlogJava
首頁
新隨筆
聯系
聚合
管理
<
2014年12月
>
日
一
二
三
四
五
六
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的文章
我的評論
我的參與
最新評論
留言簿
(3)
給我留言
查看公開留言
查看私人留言
文章分類
(90)
AJAX-DWR/EXT/JQUERY(1)
EJB3(5)
Glassfish(2)
Hibernate(1)
ibatis(2)
java(12)
javascript(4)
linux(3)
mysql(1)
oracle(28)
others
PowerDesigner(1)
Solaris(2)
spring(5)
struts(2)
struts2(2)
weblogic(1)
分錄(2)
心得體會(1)
模式(12)
網絡筆試題集(1)
錯誤集(1)
錘煉(1)
文章檔案
(90)
2012年8月 (1)
2011年12月 (1)
2011年11月 (1)
2011年8月 (2)
2011年3月 (1)
2010年6月 (1)
2009年9月 (1)
2009年8月 (4)
2009年7月 (2)
2009年6月 (1)
2009年4月 (5)
2009年3月 (3)
2009年1月 (2)
2008年12月 (8)
2008年11月 (5)
2008年10月 (7)
2008年9月 (3)
2008年8月 (6)
2008年7月 (33)
2008年5月 (3)
收藏夾
(12)
Ext
Hibernate
Ibatis(2)
J2EE(1)
J2SE(4)
Jquery
Mysql
Oracle(1)
Spring
strtus
Struts2(3)
Weblogic
下載地址(1)
設計模式
軟件工程
搜索
最新評論
1.?re: AOP之靜態代理和動態代理
@AloneAli不好意思,弄錯了。代理模式是種模式。。。不是裝飾者模式。
--AloneAli
2.?re: AOP之靜態代理和動態代理
實質就是裝飾者模式?
--AloneAli
3.?re: struts與jquery整合[未登錄]
學習下!
--力
4.?re: struts與jquery整合
很好,很強大,謝謝了
--f
5.?re: struts與jquery整合
thanks
--ami
AOP之靜態代理和動態代理
Posted on 2009-08-02 11:31
sailor
閱讀(925)
評論(2)
編輯
收藏
所屬分類:
spring
一、靜態代理:
靜態代理要求代理對象和被代理對象實現同一個對象。
IUserService:
package
com.swjs.aop.serivce;
import
java.util.List;
/** */
/**
*
@author
jason
*
*/
public
interface
IUserService
{
List getUserList();
}
被代理類UserService:
package
com.swjs.aop.serivce;
import
java.util.List;
/** */
/**
*
@author
jason
*
*/
public
class
UserService
implements
IUserService
{
public
List getUserList()
{
System.out.println(
"
get Userlist
"
);
return
null
;
}
}
代理類:
package
com.swjs.aop.serivce;
import
java.util.List;
/** */
/**
*
@author
jason
*
*/
public
class
SecureProxy
implements
IUserService
{
private
IUserService userService;
public
SecureProxy(IUserService userService)
{
super
();
this
.userService
=
userService;
}
public
List getUserList()
{
System.out.println(
"
身份檢查
"
);
userService.getUserList();
System.out.println(
"
事務提交
"
);
return
null
;
}
}
測試類:
package
com.swjs.aop.serivce;
/** */
/**
*
@author
jason
*
*/
public
class
StaticProxyTest
{
/** */
/**
*
@param
args
*/
public
static
void
main(String[] args)
{
IUserService userService
=
new
UserService();
SecureProxy proxy
=
new
SecureProxy(userService);
proxy.getUserList();
}
}
顯示結果:
身份檢查
get Userlist
事務提交
二:動態代理
接口
public
interface
IUserService
{
public
void
getUserList(
int
start,
int
limit);
}
業務方法:
public
class
UserService
implements
IUserService
{
public
void
getUserList(
int
start,
int
limit)
{
System.out.println(
"
start:
"
+
start
+
"
limit:
"
+
limit );
System.out.println(
"
get user List
"
);
}
}
處理器:
public
class
SecureHandler
implements
InvocationHandler
{
private
IUserService service;
public
SecureHandler(IUserService service)
{
super
();
this
.service
=
service;
}
public
Object invoke(Object proxy, Method method, Object[] arg)
throws
Throwable
{
System.out.println(
"
trac begin
"
);
System.out.println(arg.length);
for
(
int
i
=
0
; i
<
arg.length; i
++
)
{
System.out.println(arg[i]);
}
method.invoke(service, arg);
System.out.println(
"
trac end
"
);
return
null
;
}
}
測試類:
public
class
DynamicProxyTest
{
public
static
void
main(String[] args)
{
IUserService service
=
new
UserService();
SecureHandler handler
=
new
SecureHandler(service);
IUserService serv
=
(IUserService)Proxy.newProxyInstance(service.getClass().getClassLoader(),
service.getClass().getInterfaces(), handler);
serv.getUserList(
0
,
10
);
}
}
顯示結果:
trac begin
2
0
10
start:
0
limit:
10
get user List
trac end
Feedback
#
re: AOP之靜態代理和動態代理
回復
更多評論
2014-12-05 17:03 by
AloneAli
實質就是裝飾者模式?
#
re: AOP之靜態代理和動態代理
回復
更多評論
2014-12-05 17:11 by
AloneAli
@AloneAli不好意思,弄錯了。代理模式是種模式。。。不是裝飾者模式。
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
AOP之靜態代理和動態代理
spring 生命式事務管理配置
spring aop總結
Spring事務配置的五種方式
配置Spring的方法(轉)
Powered by:
BlogJava
Copyright © sailor
主站蜘蛛池模板:
国产精品免费AV片在线观看
|
妞干网免费视频在线观看
|
亚洲成av人在片观看
|
亚洲日本VA中文字幕久久道具
|
a级毛片在线免费
|
久久国产亚洲电影天堂
|
在线免费播放一级毛片
|
亚洲AV成人片色在线观看
|
无码精品人妻一区二区三区免费看
|
亚洲免费电影网站
|
亚洲性天天干天天摸
|
亚洲欧美自偷自拍另类视
|
成年美女黄网站18禁免费
|
亚洲国产精品18久久久久久
|
宅男666在线永久免费观看
|
女bbbbxxxx另类亚洲
|
久久久久亚洲AV综合波多野结衣
|
亚洲一区二区三区高清在线观看
|
曰曰鲁夜夜免费播放视频
|
亚洲熟伦熟女专区hd高清
|
国产午夜免费秋霞影院
|
中文字幕亚洲不卡在线亚瑟
|
国内精品免费久久影院
|
久久亚洲春色中文字幕久久久
|
日本免费人成在线网站
|
亚洲乱码av中文一区二区
|
亚洲国产精品成人
|
全部免费毛片在线播放
|
亚洲一卡2卡3卡4卡5卡6卡
|
亚洲一区二区三区乱码A
|
av永久免费网站在线观看
|
亚洲国产日韩在线成人蜜芽
|
欧洲精品免费一区二区三区
|
一区二区三区在线免费观看视频
|
亚洲一区精品无码
|
4399好看日本在线电影免费
|
精品特级一级毛片免费观看
|
亚洲VA中文字幕无码毛片
|
亚洲综合精品网站
|
麻豆国产精品免费视频
|
农村寡妇一级毛片免费看视频
|