EMF簡(jiǎn)介
What is EMF?
EMF的全稱是Eclipse Modeling Framework. 它是Eclipse MDA(Model Driven Architecture)的一個(gè)重要組成部分,是Eclipse中許多項(xiàng)目的基礎(chǔ)( e.g, GEF), EMF可以將模型轉(zhuǎn)換成高效的,正確的,和易于定制的Java代碼。EMF項(xiàng)目的最初目標(biāo)是要實(shí)現(xiàn)OMG(Object
Management Group)的MOF規(guī)范(Meta Object
Facility)。在項(xiàng)目的進(jìn)行中EMF的開(kāi)發(fā)人員根據(jù)大量的實(shí)踐經(jīng)驗(yàn)對(duì)MOF規(guī)范進(jìn)行了再加工,提取出了一些核心的元素集(MOF
2.0 中稱為EMOF(Essential MOF))。可以說(shuō)EMF 是MOF核心子集的java高效實(shí)現(xiàn),在EMF 中MOF核心子集的實(shí)現(xiàn)稱為Ecore。
EMF的組成
當(dāng)前EMF由三個(gè)部分組成:
1.EMF.Core(EMF的核心或基礎(chǔ)),包括一個(gè)用于描述模型的meta model,稱為Ecore,它實(shí)現(xiàn)了MOF的核心元素集。還包括一些runtime
support,如:模型改變通知(org.eclipse.emf.common.notify
包中定義了一些接口用于實(shí)現(xiàn)這個(gè)機(jī)制),模型持久化(默認(rèn)是XMI
serialization),高效的Reflective
API for manipulating EMF objects generically.
2.EMF.Edit:include generic reusable classes for building
editors for EMF models. It provides:
(1).Content
and label provider classes, property source support, and other convenience
classes that allow EMF models to be displayed using standard desktop (JFace)
viewers and property sheets.
(2).
A commond framework, including a set of generic commond implementation classes
for building editors that support fully automatic undo and redo.
3.EMF.Codegen:用于產(chǎn)生EMF模型的java代碼。
What is EMF
model?
我們知道model是通過(guò)它的meta model來(lái)描述的,那么EMF model的meta model 是什么呢?在Eclipse中EMF model 的meta model稱為Ecore, Ecore model是自描述的(self-description),所以Ecore model本身也是一個(gè)EMF model.
How to get an EMF
model?
有幾種方式可以得到一個(gè)EMF
model:
1.
通過(guò)文本編輯器直接編輯一個(gè)model文件(XMI格式)。
2.
通過(guò)Annotated Java code。
3.
XML schema
4.
Rose class model.