【正文】
,帶來(lái)了前述的代碼混亂和代碼分散問(wèn)題,導(dǎo)致系統(tǒng)代碼不易讀,不易修改,易產(chǎn)生不一致,重用性差,不易修改和升級(jí)等一系列問(wèn)題。這些系統(tǒng)廣泛應(yīng)用在對(duì)時(shí)間有較高要求的環(huán)境中,如汽車,飛機(jī),核反應(yīng)堆等的控制中,這些系統(tǒng)的失敗輕則導(dǎo)致經(jīng)濟(jì)財(cái)產(chǎn)損失,重則生命丟失?,F(xiàn)在面向方面編程還在研究過(guò)程中,面向方面的軟件開(kāi)發(fā)方法的研究也剛剛起步,但是它們代表了未了軟件開(kāi)發(fā)的方向,Grady Booch預(yù)言AOP將崛起[4]?,F(xiàn)在已經(jīng)開(kāi)始研究在需求、設(shè)計(jì)等其他開(kāi)發(fā)階段如何有效地分離關(guān)注點(diǎn),目標(biāo)是要在整個(gè)軟件開(kāi)發(fā)過(guò)程應(yīng)用面向方面技術(shù),從而形成面向方面的軟件開(kāi)發(fā)(AOSD, Aspect Oriented Software Development)。已經(jīng)有很多分離關(guān)注點(diǎn)的方法,這些方法可以統(tǒng)稱為面向方面編程(AOP, Aspect Oriented Programming)[2],雖然在這個(gè)概念提出之前,已經(jīng)有很多這方面的研究。通過(guò)分離關(guān)注點(diǎn),開(kāi)發(fā)人員可以只關(guān)注感興趣的部分。系統(tǒng)有信息描述如何將這些模塊可控地組合起來(lái)形成結(jié)構(gòu)和行為明確的系統(tǒng)。解決問(wèn)題需要分離關(guān)注點(diǎn),將不同的關(guān)注點(diǎn)分離成模塊,而這些模塊可以單獨(dú)實(shí)現(xiàn)。OOP中用混入類來(lái)處理橫切,但是基本類需要顯式調(diào)用混入對(duì)象的方法,即操作的邏輯由基本類控制,且好的系統(tǒng)設(shè)計(jì)師要考慮當(dāng)前和將來(lái)可能的需求以避免打補(bǔ)丁,但是預(yù)知將來(lái)的需求是困難的,這樣系統(tǒng)設(shè)計(jì)師陷入了“應(yīng)該寧可設(shè)計(jì)不足還是寧可過(guò)分設(shè)計(jì)”的兩難境地。這些非功能單元彌散在整個(gè)系統(tǒng)中,導(dǎo)致了代碼分散(code scattering);并且與功能單元混雜在一起,導(dǎo)致了代碼糾纏(code tangling)。系統(tǒng)變成一系列相互協(xié)作的對(duì)象,類的封裝性隱藏了實(shí)現(xiàn)的細(xì)節(jié);類的繼承性實(shí)現(xiàn)了重用;多態(tài)性使得不同對(duì)象接收到相同消息時(shí)產(chǎn)生不同的動(dòng)作。s Studies 58Statement of Originality 59Acknowledgments 61第一章 緒論 研究背景 軟件開(kāi)發(fā)思想就是抽象與分解,從過(guò)程化、結(jié)構(gòu)化分解編程,到現(xiàn)在主流的面向?qū)ο缶幊?,開(kāi)發(fā)典范(paradigm)發(fā)生了很大變化,唯一不變的就是抽象與分解的思想,只是抽象的種類和質(zhì)量、分解的方法發(fā)生了變化。 pointcut and advice are derived from feature, thus pointcut and advice are parts of aspect。 summarizes the researches in AOM domain。并分析了如何將這個(gè)方法應(yīng)用于實(shí)時(shí)系統(tǒng)開(kāi)發(fā)。在這個(gè)方法中,方面繼承自類,切入點(diǎn)和通知繼承自特征,這樣切入點(diǎn)和通知是方面的一部分,方面與基本類的關(guān)系用橫切依賴表示。闡述了實(shí)時(shí)系統(tǒng)中的主要實(shí)時(shí)需求,以及與實(shí)時(shí)系統(tǒng)有關(guān)的UML框架集。本文分析介紹了AspectJ、組合過(guò)濾器、多維關(guān)注點(diǎn)分離和自適應(yīng)編程等典型的分離關(guān)注點(diǎn)的方法。實(shí)時(shí)系統(tǒng)是面向方面技術(shù)很好的應(yīng)用場(chǎng)所,因?yàn)樵趯?shí)時(shí)系統(tǒng)中,有很多非功能需求,且這些非功能需求往往橫切整個(gè)系統(tǒng)。如日志、性能問(wèn)題、安全、上下文相關(guān)錯(cuò)誤處理、QoS監(jiān)測(cè)等等,這些方面分散在整個(gè)系統(tǒng)中,并且與系統(tǒng)的功能代碼糾纏在一起,這樣降低了模塊的可追蹤性、模塊的可重用性、系統(tǒng)的可維護(hù)性等一系列問(wèn)題,所以需要分離并模塊化這些非功能關(guān)注點(diǎn)。碩士學(xué)位論文面向方面的實(shí)時(shí)系統(tǒng)開(kāi)發(fā)方法摘要現(xiàn)代軟件開(kāi)發(fā)都要把整個(gè)系統(tǒng)按功能分解為小的單元,然后開(kāi)發(fā)這些小單元,這些小的單元隱藏內(nèi)部實(shí)現(xiàn),對(duì)外提供接口,最后組合這些單元為整個(gè)系統(tǒng),實(shí)現(xiàn)整個(gè)系統(tǒng)的功能。但是系統(tǒng)中有的方面是橫切整個(gè)系統(tǒng)的非功能關(guān)注點(diǎn),無(wú)法很好地封裝在單個(gè)模塊中。面向方面編程在實(shí)現(xiàn)上分離和模塊化橫切關(guān)注點(diǎn),面向方面建模在軟件開(kāi)發(fā)的其它階段用一致的方法來(lái)詳述、可視化、構(gòu)造和文檔化方面相關(guān)制品,這樣在整個(gè)軟件開(kāi)發(fā)過(guò)程可以使用面向方面技術(shù)。在實(shí)時(shí)系統(tǒng)中關(guān)鍵的就是時(shí)間要求了,這些時(shí)間要求散布在整個(gè)系統(tǒng)的功能部件里,帶來(lái)了代碼混亂和代碼分散問(wèn)題。比較完整的介紹了面向方面建模領(lǐng)域的研究。提出了一個(gè)新的擴(kuò)展UML進(jìn)行面向方面建模的方法,它以合適的語(yǔ)義表達(dá)了AspectJ和AspectC++的元素和織入機(jī)制。切入點(diǎn)的圖符可以表達(dá)多個(gè)方面在相同連接點(diǎn)的橫切行為,通知以一致的方式建模結(jié)構(gòu)橫切和行為橫切,通過(guò)在順序圖上新加一個(gè)通知發(fā)出焦點(diǎn),并將通知表示為消息,這樣可以清晰建模通知在何時(shí)何處怎樣影響系統(tǒng)的行為。關(guān)鍵詞:面向方面編程;面向方面軟件開(kāi)發(fā);實(shí)時(shí)系統(tǒng);UMLAbstractUsing modern software development methodology, developers first depose system into small units, which hide the internal implementation and provide only external interfaces, then implement these units, at last pose these units to get a full system and realize required functions. But there are some nonfunctional concerns which crosscut whole system and can’t be well encapsulated into a single module, such as logging, performance analysis, security, context related error handling, QoS monitoring, etc. These aspects are scattered and tangled in whole system, decreasing software traceability, reusability, adaptability. So these nonfunctional concerns should be separated and modularized. AspectOriented Programming (AOP) separates and modularizes crosscutting concerns at implementation stage. AspectOriented Modeling (AOM) specifies, visualizes, constructs and documents aspect related artifacts in a consistent way at other stage of software development. Thus whole software development process can use aspectoriented technique. Realtime systems are well places to apply aspectoriented technique, for there are lots of nonfunctional requirements in realtime system, which scattering in whole system. The codes related with timing are mixed with other codes, resulting in code scattering and tangling. This article considers various techniques to separate crosscutting concerns, namely AspectJ, AspectC++, Composition Filters, Hyperspace and Adaptive Programming。 analyses realtime systems timing requirements and UML profiles for realtime systems. This article proposes a new technique to modeling aspectoriented constructs and mechanisms by extending UML, which can represent constructs and weaving mechanism of AspectJ and AspectC++ with appropriate semantics. In this method, aspect is subclass of class。 relationship between aspects and base class is represented by special crosscut dependency. The notation of pointcut can express crosscutting behavior of many aspects at same join point. Advice can model structural crosscutting and behavior crosscutting in a uniform way. By adding a new block, advice sending focus, in sequence diagram and regard advice as message, this method can clearly model where and when and how advices affect system behavior. The article also examines how this technique can be practiced in realtime systems development.Keywords: AOP;AOSD;realtime systems;UML目錄摘要 IAbstract II目錄 VContents VII第一章 緒論 1 研究背景 1 2 3 研究?jī)?nèi)容 4第二章 分離關(guān)注點(diǎn)的方法 5 AspectJ 5 AspectC++ 7 組合過(guò)濾器 8 Hyperspace 13 多維關(guān)注點(diǎn)分離 13 Hyperspace 15 Hyper/J 16 17第三章 實(shí)時(shí)系統(tǒng)軟件設(shè)計(jì) 21 實(shí)時(shí)系統(tǒng)概念 21 實(shí)時(shí)需求 21 實(shí)時(shí)UML擴(kuò)展 23 通用資源建模 25 通用時(shí)間建模 30 實(shí)時(shí)系統(tǒng)建模工具 34第四章 面向方面建模 35 UML的擴(kuò)展機(jī)制 35 表示連接點(diǎn) 36 36 37第五章 實(shí)時(shí)方面建模 39 AOP元素表示 39 39 40 表示方面 41 舉例 41 用況實(shí)現(xiàn)模塊化 44 在類圖中加入方面 45 47 其它 50結(jié)論 51參考文獻(xiàn) 53攻讀碩士學(xué)位期間發(fā)表的論文 58獨(dú)創(chuàng)性聲明 59致謝 61ContentsAbstract IIContents VIIChapter1 Introduction 1 Background 1 Necessity 2 AspectOriented Technique in Realtime Systems 3 Structure of this Thesis 4Chapter2 Approaches to Separate Concerns 5 AspectJ 5 AspectC++ 7 Composition Filters 8 Hyperspace 13 MDSOC 13 Hyperspace 15 Hyper/J 16 Adaptive Programming 17Chapter3 Realtime Systems Software Design 21 Concepts of Realtime System 21 Timing Requirements 21 UML Extension for Realtime System 23 General Resource Modeling 25 General Timing Modeling 30 Tools for Realtime System Modeling 34Chapter4 AspectOriented Modeling 35 UML Extension Mechanism 35 Join Point Representation 36 Use Case Modularity Using AOSD 36 AspectOriented Modeling Using UML 37Chapter5 Realtime Aspect Modeling 39 Modeling Constructs of AOP 39 Modeling Pointcut 39 Modeling Advice and Introduction 40 Modeling Aspect 41 Example 41 Modularizing Implementation of Use Case 44 Adding Aspect to Class Diagram 45 Adding Aspect to Sequence Diagram 47 Others 50Summary and Future