城市獵人
在一網(wǎng)情深的日子里,誰(shuí)能說(shuō)得清是苦是甜,只知道確定了就義無(wú)反顧
posts - 1, comments - 7, trackbacks - 0, articles - 89
導(dǎo)航
BlogJava
首頁(yè)
新隨筆
聯(lián)系
聚合
管理
<
2025年5月
>
日
一
二
三
四
五
六
27
28
29
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
常用鏈接
我的隨筆
我的文章
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(3)
給我留言
查看公開(kāi)留言
查看私人留言
文章分類(lèi)
(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)
心得體會(huì)(1)
模式(12)
網(wǎng)絡(luò)筆試題集(1)
錯(cuò)誤集(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)
設(shè)計(jì)模式
軟件工程
搜索
最新評(píng)論
1.?re: AOP之靜態(tài)代理和動(dòng)態(tài)代理
@AloneAli不好意思,弄錯(cuò)了。代理模式是種模式。。。不是裝飾者模式。
--AloneAli
2.?re: AOP之靜態(tài)代理和動(dòng)態(tài)代理
實(shí)質(zhì)就是裝飾者模式?
--AloneAli
3.?re: struts與jquery整合[未登錄](méi)
學(xué)習(xí)下!
--力
4.?re: struts與jquery整合
很好,很強(qiáng)大,謝謝了
--f
5.?re: struts與jquery整合
thanks
--ami
AOP之靜態(tài)代理和動(dòng)態(tài)代理
Posted on 2009-08-02 11:31
sailor
閱讀(920)
評(píng)論(2)
編輯
收藏
所屬分類(lèi):
spring
一、靜態(tài)代理:
靜態(tài)代理要求代理對(duì)象和被代理對(duì)象實(shí)現(xiàn)同一個(gè)對(duì)象。
IUserService:
package
com.swjs.aop.serivce;
import
java.util.List;
/** */
/**
*
@author
jason
*
*/
public
interface
IUserService
{
List getUserList();
}
被代理類(lèi)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
;
}
}
代理類(lèi):
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(
"
事務(wù)提交
"
);
return
null
;
}
}
測(cè)試類(lèi):
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();
}
}
顯示結(jié)果:
身份檢查
get Userlist
事務(wù)提交
二:動(dòng)態(tài)代理
接口
public
interface
IUserService
{
public
void
getUserList(
int
start,
int
limit);
}
業(yè)務(wù)方法:
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
;
}
}
測(cè)試類(lèi):
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
);
}
}
顯示結(jié)果:
trac begin
2
0
10
start:
0
limit:
10
get user List
trac end
Feedback
#
re: AOP之靜態(tài)代理和動(dòng)態(tài)代理
回復(fù)
更多評(píng)論
2014-12-05 17:03 by
AloneAli
實(shí)質(zhì)就是裝飾者模式?
#
re: AOP之靜態(tài)代理和動(dòng)態(tài)代理
回復(fù)
更多評(píng)論
2014-12-05 17:11 by
AloneAli
@AloneAli不好意思,弄錯(cuò)了。代理模式是種模式。。。不是裝飾者模式。
新用戶(hù)注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶(hù)
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問(wèn)
管理
相關(guān)文章:
AOP之靜態(tài)代理和動(dòng)態(tài)代理
spring 生命式事務(wù)管理配置
spring aop總結(jié)
Spring事務(wù)配置的五種方式
配置Spring的方法(轉(zhuǎn))
Powered by:
BlogJava
Copyright © sailor
主站蜘蛛池模板:
全免费a级毛片免费看
|
国产免费AV片在线观看播放
|
亚洲aⅴ无码专区在线观看春色
|
久久久久久亚洲av无码蜜芽
|
男女猛烈激情xx00免费视频
|
巨胸喷奶水视频www免费视频
|
久久精品成人免费网站
|
台湾一级毛片永久免费
|
国产嫩草影院精品免费网址
|
久久亚洲AV无码西西人体
|
久久久久久亚洲精品成人
|
亚洲中文无码永久免
|
一级做a爰片久久毛片免费看
|
一级特黄aa毛片免费观看
|
午夜视频免费观看
|
亚洲乱色熟女一区二区三区丝袜
|
亚洲视频在线观看地址
|
亚洲AV无码一区二区一二区
|
国产免费阿v精品视频网址
|
国产一精品一AV一免费孕妇
|
亚洲一区二区三区无码影院
|
亚洲精品无码久久毛片波多野吉衣
|
亚洲另类自拍丝袜第五页
|
中文字幕一区二区免费
|
成人无遮挡裸免费视频在线观看
|
亚洲午夜精品第一区二区8050
|
亚洲综合男人的天堂色婷婷
|
一级做a爰片久久毛片免费陪
|
国产精品亚洲精品日韩电影
|
中文字幕在线免费看线人
|
最近2019中文字幕免费看最新
|
亚洲人成在线影院
|
MM1313亚洲精品无码久久
|
玖玖在线免费视频
|
国产伦一区二区三区免费
|
亚洲视频一区调教
|
欧洲乱码伦视频免费国产
|
美女被cao免费看在线看网站
|
亚洲精品视频免费观看
|
亚洲一卡2卡4卡5卡6卡残暴在线
|
中文字幕免费在线播放
|