How to create an EMF model from a Java application ?

本文介绍了如何通过MoDisco组件将Java源代码翻译成EMF模型,包括如何配置分析选项以增强模型的详细程度,以及如何利用此模型与其他EMF工具进行交互,实现代码规范检查、模型生成和代码再生等功能。
Is it possible to reuse EMF-based tools with Java source code ? Yes if you have your Java source code translated into an EMF model.

This is the aim of the  Java component provided by  MoDisco. This component is composed of a ECore definition of a java application and a discoverer which creates EMF models from an EClipse project containing Java source code.

The ECore definition declares all the concepts of the Java language : Package, ClassDeclaration, MethodDeclaration, Parameters, VariableDeclaration, IfStatement, Assignment, CastExpression, LineComment, ...

To create an EMF model using this metamodel, select your project and right-click on the menu "MoDisco>Discover Java model from Java project...". A wizard appears to select the analysis options :
  • You can extend the analysis to dependencies (the JAR used by the project).
  • You can use an incremental mode if you need to optimize the memory usage
  • You can limit the analysis to declaration members if you don't need a model of the instructions contained within the methods
  • You can use a filter to exclude Java classes during the analysis

The result is an EMF model which can be opened with the EMF reflexive editor or with the MoDisco generic browser. This browser allows accessing directly to instances of a specific class (for example all the MethodDeclarations) and navigating through all the references (composed or not).

This model can be used with other EMF-based tools to check architectural or coding norms, to generate other models (UML or Domain-Specific) or to regenerate an other application (if you modify the Java model, MoDisco provides templates to regenerate Java source code).
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值