Tải bản đầy đủ (.doc) (57 trang)

KIỂM CHỨNG CÀI ĐẶT BIỂU ĐỒ TƯƠNG TÁC VỚI UML 2

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (655.82 KB, 57 trang )

ĐẠI HỌC QUỐC GIA HÀ NỘI
TRƯỜNG ĐẠI HỌC CÔNG NGHỆ

KIỂM CHỨNG CÀI ĐẶT BIỂU ĐỒ TƯƠNG TÁC
VỚI UML 2.0
KHOÁ LUẬN TỐT NGHIỆP ĐẠI HỌC HỆ CHÍNH QUY
Ngành:Công nghệ phần mềm
HÀ NỘI - 2010
ĐẠI HỌC QUỐC GIA HÀ NỘI
TRƯỜNG ĐẠI HỌC CÔNG NGHỆ
KIỂM CHỨNG CÀI ĐẶT BIỂU ĐỒ TƯƠNG TÁC
VỚI UML 2.0
KHOÁ LUẬN TỐT NGHIỆP ĐẠI HỌC HỆ CHÍNH QUY

Ngành: Công nghệ phần mềm
HÀ NỘI - 2010
Tóm tắt

 !"#$"%
&'()'(*+(!#$
%,-*"./0
1"2*3/456+7877968:
;3<-6+7=>33/$
?/@*+0"./<A
BC(D-EFGH((B?/<*IJK"+"
)L B<*M-EAB/B?-
/$ (%&1 (D*IJK"!
BN;3H((B")68"
'(B!?/M"(2?<* 1+C
6+7=%OO-/$3<O""(
N776+7%+C6+7=H1P%(


4Q1H/B$68?IJK? RJK?
6PP8F6FS8PT(L$ (%EU >
(DIJK+(+7OO-/$VW
X"-+C+7+71*--/
$ (%&E>
Mục lục
Chương 1. Mở đầu...................................................................................................................................1
1.1. Đặt vấn đề.......................................................................................................................................1
1.2. Nội dung bài toán............................................................................................................................2
1.3. Tổng quan phương pháp “kiểm chứng cài đặt biểu đồ tương tác với UML 2.0”..........................2
1.4 . Cấu trúc khóa luận.........................................................................................................................4
Chương 2. Annotaions , Aspects và UML 2.0.............................................................................................5
2.1. Annotations.....................................................................................................................................5
2.2. Aspect..............................................................................................................................................7
2.3. UML 2.0.........................................................................................................................................10
2.4. Xây dựng máy trạng thái từ biểu đồ trình tự...............................................................................16
2.5. Tổng kết chương...........................................................................................................................18
Chương 3 . Xây dựng cộng cụ tự động sinh Aspect từ máy trạng thái....................................................19
3.1. Biểu đồ trình tự và các đoạn gộp.................................................................................................20
3.2. Sinh Aspect từ biểu đồ trình tự...................................................................................................21
3.3. Kết luận.........................................................................................................................................23
Chương 4. Thực nghiệm.........................................................................................................................23
4.1. Xây dựng công cụ ........................................................................................................................24
4.2. Kiểm chứng một số giao thức thực tế.........................................................................................27
4.3. Kết luận.........................................................................................................................................44
Chương 5. Kết luận.................................................................................................................................45
Phụ lục .......................................................................................................................................................47
Phụ lục A : Tài liệu XMI mô tả biểu đồ trình tự.....................................................................................47
Danh mục các ký hiệu, từ viết tắt
Từ viết tắc Diễn giải

AOP 6+79877
FSM Y7T7J7
OOP 8 Z7877
XML 7R7+ "7J/(K(7
XMI RJKJ7S77
UML I[7J7""(7
Chương 1. Mở đầu
1.1. Đặt vấn đề
P<-<C$O!"W
>+EC%?G&$O1!B$O$?G&
$O*B$OL$"3(MU+\<
-<NMMMC"L-C%?@
""H%3J%'()QN<-<"N<-
]N;3+ 2Q<-$C.
N<-
^-?"+\4Q<-<?'(
*"<>'('(*HU_(*
"(`(2H((?4?B/B??/
?/ *aE3?- !"Q
"<;'()bM?!U"/?c+0
".+'(*+(!?M"<-Q
/d--".(%*2('("3?E(
><+$+0".?24M" %-EG(?
M/! N4*21-
".+3(<+$+0e>a--&".
?/$5d7[:\c5d":fgh
#$"/7BMB/Bee
U/<H((/<F\c"M+.Q
/,/7M$H((Q)/<
JO44Q/$""(+E".

MUB$!!M!2N4*2?MMi
<;'() %'(*j
-PM(eE'(Q(H$(
k/0MO4/4elQ+
?/7M$(( U/<FB?
/01c<>%2/0(
1
(1$b2?m/4e+Q((Q
1*?/</'(*%(1*M7e
U (/<d-/</e1*"3
1.2. Nội dung bài toán
#$"%<;'()'(*
d*2M!(1/$
"2/$<*F3/M"(2?<(E2B
1  /$   H1"2 *  3/4
568:NO "/$U%QE
=/0>
FB2?%$O3EU ,<
*IJKU ,<&=`T(/6+7+?e+
7C=/>nM-O
6+7G (D(?;6+7=6+7/(
1*4#1*?6+7+%/U
$< ".B(M !/o+
P-O4Q "1C6+7
/$<OPlugin Protocol Verification Generator %+
6+7/$U$ , (D(IJK
1.3. Tổng quan phương pháp “kiểm chứng cài đặt biểu đồ tương tác với UML 2.0”
F /M"(2p#SqJ N^rPk asN Ft IJK N^8 FuN Fv ^wJ
JxJyfzhC* 1/$UIJK0?
/M"(2C14/$%+E$

56n:

f6{nh

P/M"(2M?'(B%+E!`
9 J3mGA/%+E$1
9 NmM/ (D>?U (D767
IJKaE3?$< ,IJKzA"H*<O/<
-
2
9 d-%+6+7+-6+7+
+(M"("a+0O6+7*MZ7
B
9 6+7+MZ7F$"? !/o"3M
%1$<A(*(c(OQ6+9
7a(?(/H".
9 F"-(RJS(Q<OC()m$
B
G/M"(2H?<C'(B!H6+7
+BlZ7;H3["7k$/$
aB/B7IJKz|?N(/-"U?")+0O<%
%"?"6+7+M +/%1$
>;!(
b+/(&<IJKz|3?H!(e"(&
j6+7+j/(+3A<OdkG<O
dk<CL(;3U$ ,IJKz|
n l(3("% (L(IJKz|? (D
 ,<O6"I7"z|}|U6"I7"z|}|"(?
(D+(!3RJST(M?"!<B
EQ (D(%5YTJ:K2*H+

<9(-O4G (D (Di"T+
3M"'(*6+7Gn pChecking Interface
Interaction Protocols Using Aspect-Oriented Programmingyf~hC1
/$$+0O68b  <<O
%+6+73(""-(RJS< (D(IJKz|1
<OPlugin Protocol Verification Generator(PPVGQ<D
3
− n3}`4"-(RJS?"!<B

− n3z`R %%+6+7GYTJ`T0OYTJG
+GH?(-GYTJ?O1U6+9
3
7  MH?<Z9?(7G
M*H<9(6+7
1.4 . Cấu trúc khóa luận
Ni"Q/M"(2!(e+(`
Chương 23-(+?6+7=?68?IJKz?
F1<* /B$1 +0O/M"(2Q<
1 
Chương 3<O+6+7G< (D*IJK
Chương 4U<O%+6+7B/$%+E
$
Chương 5/B"(2Q/M"(23H$(1"
4
Chương 2. Annotaions , Aspects và UML 2.0
2.1. Annotations
NM"/-6+-(> BB?*2A
<+* l)/-1 U4QQ
6+
2.1.1. Khái niệm annotaions

6+
}
3H("%7J7"U&
"-(%E?c*MN•2~??U% B
MM7cRJK"€TTaU&"-("%2c$&
<l)?1 <EMN•?3% *
7M D`H+W* ?H+W?  "(?
J7/<"•+H(&"-(•%+E>GcGB6+
Bd-
2.1.2. Ưu điểm của annotations
6+"%/‚(23)?$ƒ"("4
-?3"%+E"4Q+
− F>`P*"3H M!„O4
− a1
− F!(".>`"2*?e>
!+".>K. A/( Hc>4(
'(BM A"2*H".>"
&"./Mc(?/M/@?!(>*(H69
+"%\".e'(*!(*Q/( Hc
PW" HcM "2*H%+E!(*+"e
cPB(;1">e4?(%4URJK*
".m > Ae1("&"-(@ 
− rO1`d-;cRJKeE
>? %3(LGRJK+EM6SX
1"-b8JUT6Rj"%Ab;6+*…
!(
1
`††Z+(†+† /+†("†Z†Z88†+"
5
2.1.3. Cấu trúc annotaions

J%+cW+(`
@interface tên_annotations {
// các các thành phần
}
N+"+ B+EQM
F<>+;%e4
1*"++? B+E?1$?UM/" !/o%i"-
ae%MQ1**+H
3Mac+(`
‡Hˆ+5‰+E+EŠ:FHˆˆ
d4O`+0O+1$
@Override
public String toString()‹
  return super.toString() +"Testing annotation name: 'Over-
ride'";
}
6+Hc+0O,/•c1$T
Œ"H1$Q"3
2.1.4. Target annotions
6+!?M!("+?<m2B
F7+*"+<;/M"(2T(?<+*
"+
F7+e4/(M43""++nD"
− ‡F75•"77F7FŽ•:•uO !/oB(EQ"++
− ‡F75•"77F7YS•Kb:•NMO"W(%
4
− ‡F75•"77F7J•F^8b:•NMO$%7
6
− ‡F75•"77F76€6J•F•€:•u  O   <  +E  Q 
7+

− ‡F75•"77F7N8PTF€INF8€:•uO+(+
− ‡F75•"77F7K8N6Kˆd6€S6nK•:•u  O      B  c
1
− ‡F75•"77F76PP8F6FS8PˆFŽ•:•K*(H E"%e
4
d4O`
@Target(ElementType.METHOD)
public @interface Test_Target {
public String dosomething();
}
6+HcWe1$?3
4"+75:a+0O+*HM31$
d4O`
@Test_Target(“test”)
Public void test(){
// do something
}
aE3+?B(McW;"E
*MmMe"EMP+A4OH?Mm
MeE"%1$PB(+0OMe%"++
U% B*+2".
2.2. Aspect
2.2.1. Lập trình hướng khía cạnh AOP
d

H

<

"


(

68"

7

(



H





H

H H

<




"




/H

1

(

"

H



HH

<

+((

68 <

+(/

(

"

•

1


<

1

 @

H

<’1

<



<9(/

?7

/7


7
H

H

((




H

(

<

/<

#<



1



"

–6+7—5




"

–"

—˜




"

@

'(H

("1

<

1

:?



–6+7—

(



H(

1



H




H

1

`6+7977P1



1



H?

H

(1

HH’/H

+

1N

6+7(

H


<



H

<

?H@



"(

 H





H



+

(

J<




 H

@


H



H"

6+7™77

H

/H

1







H"7


"



H

<

1




68D~ 3`
− •



H(

(H







H


(



H

(
− R

H

H





H

H H


− F<

1



H


H


F* Hc68-7 3`
− #H

1





H"7


− N(H

<

</H

'(

+







N(Q68fšh`
− J<(





H

(`68







H

<





 H





H

<

H

(H



@



?7

<(





H

"H'(H


H

("1


<

1


− bH’



H

H

<

`dH

H

@1



H



H


H’


@





6+71



/<

'(H



H

(#H


<(1



H


<

?

6+7H



+7

/H

1

(





H+



H

@

7



− N7

H

"

'(H



H

/H

1"`J<

H

/H

<



•

H




H(

(H





1"?H





H(

(1""

<

<H

/

/@PH

( 

+




H(

(1"

H

 

+7



<



H


"

H

(

H


<

d1

68?1

H

/H

H

<



H

H

"



'(H




H


/H



H(

(1"1



H

7
− F

+

(



<

1`N

6+7"




<(H H

?1

/H

1


"<

˜•

"

H

(<

'(

H



+

(




687



+

(



<

188
8
2.2.2. AspectJ
6+7="%A%Q"2*3/468e-)
$O=H68XM6+7=e-
<9(M!'(-$OX1"`
/0"›".?D %M?E(M-('(?7„?*".
6+7=!(GZ9?(?7fœh
=+"cW1*?ZM"%">)?
/A%"3?/A%EP>Z9+Mc
$@l-EH=9M"4+(`
− =9/A
− =9(2(%4
− =9(2"-
("2Z +0OcW7
(+)%ZM&Z9MNeQ
(+(`

f7+++7[7h((975f+h:`(97[•
d4O`
public pointcut test() : call(String Start()) || call(boolean end());
JCAGZ9)7NM("7` 7[7
93Z9?[79+(MP?67"C+
-%Z9) A%(
67""+(`
− n7[7`a-3Z9
− 6(`a-+(Z9
− 6[[7`a-+(Z9
6+7=gM(A%1+36+7=3M?%
ž 2"MM+0O+=g%Z9F<>
+>cW%7+F7
+McW"3?1$U%
/F/M"(2Q<?<+0O+cW1$
9
d3%+cW1$PM+e3%
1$M#M6+7+cW1$M3+(`
‡FHˆ+FHˆ1ˆ$5+E+E:
d4O`
pointcut test() : call(@Implement * m());
d4OH?(/4/%3$5: e A
+‡S"77)
2.3. UML 2.0
2.3.1. khái niệm về UML
IJK5I[7J7"K(7:"%<&(\-OM?
'(M?"-(%-E?j<
*-&-E/IJKH(%"/‚(2<
-E!C/$<(-E"3$
IJK"%'()-3E

'(*IJK+0O(B/›-(D)<
B/BQT0OIJK+eMM
XB?/&@B/B?H(\B/B/Be
Q
P&O44-B/BQIJK"`
− N(!>;3%"-()+0O?M›W%
<&<*'(?*2)ML<*M›
W
− N(!1BU/@A%A%/-E"„
− #<O(%<&"2*O'(*
− N(!%1+A4$-(&<&<*M
− k@+Qc><O3E
− ^.+A$1/-"" +?[79
Ÿ/+?7+7+
− F4BE!
IJKz|3(L-< (Dd3
+A%<%"??"]"(
10
-">+0Ob3?<+<%+E (D
*IJKz|
2.3.2. Biểu đồ trình tự UML
J% (D*m%%%&%"E#4
'()Q (D"m*<-57++7:0
&EPMjm*1&E?(+
%>OM*Q-EN (D*
$%"E (X ,>•$FO>
M3GH(E3 (D? (Dm+L<-&
E/><'(N<- (X ,>
l"3jH5 (c<-:E"&&>•
$-EFO>;&">2 />+

"Q (Db3"%4O (D(
Hình 2.3.2a: Quá trình đăng nhập ATM
FB7?<+3-(Q (D(IJKz|
I"z|CM+L/$ (X (D(a(H"
11
e4 (D?UHe4%/(?
/(+0O%IJKz|f}hJ%/((
!%3 (D?cc4E'(-Q
(Db3?"</(
Hình 2.3.2b mô tả một khung cơ bản
d3 (D(?M!}z"%cW`"?? 7/?
?+7'?+?7?"?7?+7?++7?"PHBmMš
"+0OQB(M"`"??" 7/T(<+* š
"
2.3.2.1. Alt
JO4"*/B+")LMB"¡(&
U(*<-N+B +<*ML5[
7"+7:pB(*y54O`B(<( $*<}g¢•U<
}|¢:
12
^*z~z} (D*+0O"
2.3.2.2. Opt
J/B5+;):+0O<*%*+?
+0(/-!c•B(/<*+/<T;)
+0O<%-1p[7y5B(*:54O`B(M41g
H *Hz &:
Ne4Q/B;)1E3/BB?G
MmM%/< iMp7"+7y
13
Hình 2.3.2.2 biểu đồ dùng opt

2.3.2.3. Loop
a</ +%*"U"U"FIJKz|<*M%
(D"U"U"CB;3(/-Q/Bi"U
14
Hình 2.3.2.3 biểu đồ sử dụng loop
2.3.2.4 . Break
N/( 7/;<O<*MG+/+
Hình 2.3.2.4 Biểu đồ sử dụng break
15
d34OH?//(/- "7‰("+*-
4+(Q% 7/P"?B((/-"e*% 7/
-/<-% 7/-B*<
-/ H/<-&
2.4. Xây dựng máy trạng thái từ biểu đồ trình tự
2.4.1. Cấu trúc dữ liệu mô tả biểu đồ trình tự
J% (D*D(?MM'(
)>+E?<-L&>+E?%?
]/H( (D*<+(`
− FH"3C(D1*1$3H%>+E
− N<-L&>+E<Q
%1$"31$AC(D1*J%1$
H?c?++E
Hình 3.1.1 : Altova Umodel mô tả thành phần trong biểu đồ trình tự.
a25YTJ:(HM!((&"-(<
 (D*^'()">+E<
-L&>+E
n,-4"-(RJS?"3<>+E<-
&>+EUK3K[7K7<%>+E
class Lifeline {
private String id, className, name;

private boolean isMultiObject;
16
String objectName;
/////
}
F"-(RJS?%>+EcW£"[7"7MM
'()`
9  BQ>+E
9 7<HQ>+E
aE31$L&>+EU<'("3J7++7
K3U+(`
public class Message implements Comparable<Message>{
private String id, name;
private String sendEventId, receiveEventId;
String className;
Lifeline from, to;
String sourceState, targetState;
//////////
}
F"-(RJS?<<-U£7++7?3%
<-M4+(`
9 <Q<-
9 7<HQ<-
9 +7•7S<(D?1 l(<-
9 777•7S<1BQ<-
9 [<- l(DG>+E
9 F<-/BeA>+E
9 +(7T7 B l(Q<-
9 7T7 B/BeQ<-
17

2.4.2. Xây dựng máy trạng thái(FSM)
F (D*?<-/B(?e<$
)Q<-d-<Q<
(F?(4"<
-bM?+<$3+(Q<
-bM?+D&"-(+(`
− +7++Q
− 77++<-
− [+T7(HQ
− "+T7+2(EQ
F(2`
nzšz`F(2fzh
Stt tên Mô tả
} ( F"-(RJS
z (( JZ+B(/<< ".
~ N 3-
1. #A    [+?  +7+?  77+?   [+T7?
"+T7
z a)["7RJS?"!B`
<-??]
~ b(-G<-?77+
~} PB("<-(E*H
/Be"+T7+
3.2. PB("<- l(?H
(D[+T7
~~ PB("<-(?"(&
"-(
2.5. Tổng kết chương
F1?<C* %+E/-1 +?
6+7=?+6+7=?IJK? (D*IJKza"

18
/M"(2Q<aO<O+6+7%aD><j
* (21 
Chương 3. Xây dựng cộng cụ tự động sinh Aspect từ máy trạng thái
19

×