EMF簡介
What is EMF?
EMF的全稱是Eclipse Modeling Framework. 它是Eclipse MDA(Model Driven Architecture)的一個重要組成部分,是Eclipse中許多項目的基礎( e.g, GEF), EMF可以將模型轉換成高效的,正確的,和易于定制的Java代碼。EMF項目的最初目標是要實現OMG(Object
Management Group)的MOF規范(Meta Object
Facility)。在項目的進行中EMF的開發人員根據大量的實踐經驗對MOF規范進行了再加工,提取出了一些核心的元素集(MOF
2.0 中稱為EMOF(Essential MOF))。可以說EMF 是MOF核心子集的java高效實現,在EMF 中MOF核心子集的實現稱為Ecore。
EMF的組成
當前EMF由三個部分組成:
1.EMF.Core(EMF的核心或基礎),包括一個用于描述模型的meta model,稱為Ecore,它實現了MOF的核心元素集。還包括一些runtime
support,如:模型改變通知(org.eclipse.emf.common.notify
包中定義了一些接口用于實現這個機制),模型持久化(默認是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:用于產生EMF模型的java代碼。
What is EMF
model?
我們知道model是通過它的meta model來描述的,那么EMF model的meta model 是什么呢?在Eclipse中EMF model 的meta model稱為Ecore, Ecore model是自描述的(self-description),所以Ecore model本身也是一個EMF model.
How to get an EMF
model?
有幾種方式可以得到一個EMF
model:
1.
通過文本編輯器直接編輯一個model文件(XMI格式)。
2.
通過Annotated Java code。
3.
XML schema
4.
Rose class model.