-
Notifications
You must be signed in to change notification settings - Fork 8
Home
This wiki contains three kind of information: How to use the project, how to work with the source code of the project and general information about the architecture and the internal processes.
The project can be used in two different ways. One can use the project as an Eclipse Plugin through the MainHandler
class, or address directly the main class EcoreMetamodelExtraction
.
-
When using it as a plugin, a simple dialog allows choosing a Java project which is then used to extract a metamodel. The extraction is executed with the constraints of the user properties file. To use the project this way, run the project as Eclipse Application. The menu EME in the menu bar allows choosing three options: Plain extraction of a metamodel without saving (only logger output), extraction of a metamodel followed by saving it into a file according to the selected saving strategy and the extraction combined with code generation. In this case a metamodel is extracted and saved. Then, a GenModel is generated and used to generate model code.
-
When working with the class
EcoreMetamodelExtraction
directly, it offers four simple methods to work with. The methodgetProperties()
grants access to the instance of the class ExtractionProperties, which allows to configure the extraction process programmatically (see Properties). This can also be done through editing the properties file before running the program. With the methodsextractFrom()
andextractAndSaveFrom()
the metamodel extraction is started for a givenIProject
.extractAndGenerateFrom()
also starts the metamodel extraction, but also creates a GenModel and generates the model code of the extracted metamodel.
For demo purposes the repository EME-TestProject can be used. It is a simple Java project containing code that allows to test the extraction of the different supported features. See the project README for installation hints.
The theoretical approach to the extraction is to find a mapping between the elements of the implicit model of the language Java and the elements of the Ecore meta-metamodel. Both models are very similar but not identical. That means Ecore meta-metamodel cannot be used to represent Java code hundred percent syntactically correct. Some features from the language Java cannot be extracted at all. Other features can be extracted under certain conditions. For a more detailed description about the differences see the page Model Differences.
This program extracts packages with their hierarchy, interfaces, classes, enumerations with their enumerals, inheritance and realization relations, attributes, methods with their parameters, return types and throws declarations, generic types with their type parameters, generic arguments and wildcard types.
To further understand how the project extracts Ecore metamodels from Java code, you have to look at the extraction table. It depicts the mapping between different elements of the language Java and their relating Ecore elements. The left column contains the Java elements. The right column contains the Ecore elements which are generated from the extracted features. The middle column shows another set of elements. These are the relating elements of the intermediate model. The intermediate model is an internal model which is used for the extraction. That means the project maps from Java elements to intermediate model elements and from intermediate model elements to Ecore elements.
Java Model (implicit) | Intermediate Model | Ecore Meta-Metamodel |
---|---|---|
Package | ExtractedPackage | EPackage |
Type | ExtractedType | EClassifier |
Class | ExtractedClass | EClass |
Interface | ExtractedInterface | EClass |
Enum | ExtractedEnumeration | EEnum |
Enumeral | ExtractedEnumeral | EEnumLiteral |
Attribute | ExtractedAttribute | EStructuralFeature (EAttribute / EReference) |
Method | ExtractedMethod | EOperation |
Method Parameter | ExtractedParameter | EParameter |
Method Return Type | ExtractedDataType | EClassifier / EGenericType |
Method Throws Declaration | ExtractedDataType | EClassifier / EGenericType |
Generic Type Parameter | ExtractedTypeParameter | ETypeParameter |
Generic Type Argument | ExtractedDataType | EGenericType |
Generic Type Bound | ExtractedDataType | EGenericType |
Super Type Reference | ExtractedDataType | EClass & EGenericType |
Even though the project consists out of ten packages, the general architecture can be broken down to three parts: The project parser, the intermediate model and the metamodel generator. The parser analyzes a Java project using the JDT API and extracts all the information the implicit model of the Java code contains. With these information the parser then builds an intermediate model. The generator then uses the intermediate model to build an Ecore metamodel. The Ecore metamodel is build as a tree structure out of EObjects, with a root package as container of all the elements of the metamodel. The generator also has the ability to save the generated Ecore metamodel as an Ecore file. For this process, there are several different saving strategies available.
The whole extraction process is depicted in the following diagram:
The projects main package eme
contains five subpackages: eme.parser
, eme.model
, eme.generator
, eme.properties
and eme.handlers
. The packages eme.parser
, eme.model
and eme.generator
contain the three key components which were explained before. The eme.properties
package contains the classes for the management of the properties file. The package eme.handler
contains the main handler, which allows using the project as a plugin for the Eclipse IDE and offers a simple dialog for choosing an input project.
To understand the different parts of the project, see the following pages: