- 介绍
基于Eclipse的模型框架。它是Eclipse MDA(Model Driven Architecture)的一个重要组成部分,是Eclipse中许多项目的基础( e.g, GEF), EMF可以将模型转换成高效的,正确的,和易于定制的Java代码。
官网地址:http://www.eclipse.org/modeling/emf/
The EMF project is a modeling framework and code generation facility for building tools and other applications based on a structured data model. From a model specification described in XMI, EMF provides tools and runtime support to produce a set of Java classes for the model, along with a set of adapter classes that enable viewing and command-based editing of the model, and a basic editor
- 创建一个EMF工程
首先,你选用的Eclipse需要支持EMF开发才可以。
- 使用快捷键Ctrl+N,找到菜单Eclipse Modeling Framework
- 选择Empty EMF Project,填入工程名称,然后finish
- 选择model目录,按Ctrl+N,选择菜单Ecore Model,修改文件名为bowling.ecore,finish
- 如下图,双击bowling这个几点就会打开Properties视图,修改Name为bowling,修改Ns Prefix为org.suren.example.bowling,修改Ns URI为http://org/suiren/example/bowling
- 在bowling节点上右键新建一个EClass的Child,然后修改Name为Player
- 在Player节点上新建EAttribute,Name为name,EType为EString;再新建dateOfBirth,EType为EDate
- 在bowling节点上新建League,新增name;再新增一个EReference,EType选择为Player,Containment设置为true,Upper Bound为-1
[caption id="attachment_2507" align="alignnone" width="364"] bowling.ecore[/caption]
- 生成代码
- 参考
http://eclipsesource.com/blogs/tutorials/emf-tutorial/
http://eclipsesource.com/blogs/tutorials/getting-started-with-the-emf-client-platform/
标签:代码生成,EMF,http,Eclipse,emf,bowling,model From: https://blog.51cto.com/suren/5764517