Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "MoDisco/Components/Java/Documentation/0.9"

(Discoverer Benchmark)
(User manual)
Line 1,393: Line 1,393:
  
 
*Checkout ''org.eclipse.gmt.modisco.java.generation'' into the workspace from Eclipse SVN repository, and then Create an Accelo launch configuration pointing to ''GenerateJavaExtended'' java class, and specify the input model and target folder. Use "Acceleo plugin Application" runner in launch configuration. If an error "could not load class GenerateJavaExtended" occurs, it may be caused by an already installed 'org.eclipsxe.gmt.modisco.java.generation' plugin, thus you may use "Java Application" runner (however, with this second runner, Java code formating step, launched at the end of the generation, will not work if the classpath is not completed with the required related java libraries.
 
*Checkout ''org.eclipse.gmt.modisco.java.generation'' into the workspace from Eclipse SVN repository, and then Create an Accelo launch configuration pointing to ''GenerateJavaExtended'' java class, and specify the input model and target folder. Use "Acceleo plugin Application" runner in launch configuration. If an error "could not load class GenerateJavaExtended" occurs, it may be caused by an already installed 'org.eclipsxe.gmt.modisco.java.generation' plugin, thus you may use "Java Application" runner (however, with this second runner, Java code formating step, launched at the end of the generation, will not work if the classpath is not completed with the required related java libraries.
 
Or
 
 
* It is now possible to generate java code directly from a .javaxmi Java model. Just right click on a model, and select "Generate java code from Java model". The code will be generated next to your .javaxmi file
 
[[Image:MoDisco-JavaGeneration.jpg|frame|center|Menus in Eclipse to generate source code from Java model]]
 
  
 
== Java model to KDM model transformation  ==
 
== Java model to KDM model transformation  ==

Revision as of 08:17, 27 July 2011

MoDisco
Website
Download
Community
Mailing ListForums
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse SourceProject Set File

Java Metamodel

The Java metamodel : it is the reflection of the Java language, as defined in version 3 of "Java Language Specification" from Sun Microsystems ("JLS3" corresponds to JDK 5).

The Java metamodel contains 126 metaclasses. To better understand it, this page will introduce its main features (metaclasses and links).

You could also browse the model definition, java.ecore available in sources (see source repository).

A good tip is also to see the javadoc associated to the metamodel implemented by the Eclipse team in the JDT (Java Development Tool) project. This metamodel and Java are very similar.


Main metaclasses

ASTNode

Every metaclass (apart from the Model metaclass) inherits from ASTNode. As its name indicates, ASTNode represents a graph node. ASTNode has a reference to the Comment metaclass because almost every java element can be associated to a comment (block or line comment and Javadoc). More details in the "Comment" section.

ASTNode metaclass

Model, Package, AbstractTypeDeclaration

The root element of each Java model is an instance of the "Model" metaclass. It is a translation of the concept of java application, so it contains package declarations (instances of the Package metaclass). And package declarations contain type declarations (instances compatible with the AbstractTypeDeclaration metaclass), and so on...

Model, Package & type declaration superclass

NamedElement & notion of Proxy

A lot of java elements are "named", and this name could be considered as an identifier : methods, packages, types, variables, fields, ... So all the corresponding metaclasses inherit from the NamedElement metaclass.

Another goal of this metaclass is to indicate whether an element is part of the current Java application or not (element from an external library of from the JDK). So, external elements are tagged as proxy through a dedicated attribute and can be easily filtered. For example, instruction "System.out.println" has been decomposed into three named elements (one class, one variable and one method) the definitions of which are not part of the current Java application. So attribute "proxy" of these elements has been initialized to true.

NamedElement and its hierarchy

TypeAccess, PackageAccess, SingleVariableAccess, UnresolvedItemAccess

To represent links between Java elements, metaclasses TypeAccess, PackageAccess, SingleVariableAccess and UnresolvedItemAccess were introduced. Each allows to navigate directly to a NamedElement (proxy or not) in the graph.

A TypeAccess represents a reference on a type.
TypeAccess
A PackageAccess represents a reference on a package.
PackageAccess
A SingleVariableAccess represents a reference on a variable.
SingleVariableAccess
On the contrary, references to methods are direct.
MethodInvocation

BodyDeclaration

A type declaration has different kinds of contents : fields, methods, static block, initialization block or other type declarations. All of these elements are of type BodyDeclaration metaclass.

BodyDeclaration and its hierarchy

Expressions

Like in many languages, the concept of expression exists in Java : it is a portion of code, without declarations, and its evaluation returns a value, numerical or boolean or other ... For example,
++i
is an expression and it will be translated to the concept of PrefixExpression metaclass. All types of expressions shall inherit from the Expression metaclass.
Expression and its hierarchy

Statements

An "instruction" in Java is represented by the Statement metaclass. A block of code (Block metaclass) contains a collection of statements, and a block of code may be contained by a method. Some examples of statements in java :
if, while, for, do, ...
All of their definitions use the concept of expression to separate the value from the instruction keyword.
Statement and its hierarchy

Zoom on comments

There are three kinds of comments : line comments (//), block comments (/* */) and javadoc comments (/** */). Every comment contains text fragments, but we can have more information on javadoc comments (Javadoc metaclass): they can also contain javadoc tags that are identified and collected through instances of the TagElement metaclass.

Comment and its hierarchy

Zoom on annotations

Official usage of annotations has been introduced in version 5 of the JDK. To handle them, annotation declarations are managed as type declarations (AnnotationTypeDeclaration metaclass) with specific attributes (AnnotationTypeMemberDeclaration metaclass). And annotation usages are translated into instances of the Annotation metaclass, which reference corresponding annotation declarations. And parameters are translated into instances of the MemberValuePair metaclass. Some statements also have a list of annotations.

Annotation

Zoom on generics

Version 5 of the JDK also introduced the concept of "generics". Generic types of method declarations are translated into instances of TypeDeclaration of AbstractMethodDeclaration metaclass with arguments as instances of the TypeParameter metaclass. Uses of these generics are translated into instances of the ParameterizedType metaclass which reference concrete elements (type and type arguments).

A specific case of type argument is the "wildcard" (for example "<? extends X>"). There is a specific metaclass to handle it : WildCardType.

Generics

Associated Discoverers

The main discoverer available for this metamodel : Java Discoverer

Java Discoverer

The goal of the Java Discoverer plug-in is to allow practical extractions of Java models from Java projects.

Description

This plug-in aims at analyzing Java source code compliant with version 3 of "Java Language Specification" from Sun Microsystems and providing a model describing the information found, conforming to the Java metamodel.

A Java model contains the full abstract syntax tree of the Java program: each statement such as attribute definition, method invocation or loop is described. In addition, links between elements are resolved (by resolved link we mean for instance a link between a method invocation and the declaration of this method, or between the usage of a variable and its declaration). The model can thus be seen as an abstract syntax graph (ASG).

User manual

The plug-in provides the user with a contextual menu to easily create models.

By right-clicking on a Java Project in the Eclipse Package Explorer view, you can quickly create the Java model of your application (see next Figure).

Menus in Eclipse to create model from source code

A discovery parameters dialog opens to let you specify the parameters of the discovery:

Discovery parameters dialog
  • Set SERIALIZE_TARGET to true if you want to save the model to a file
  • You can define TARGET_URI to the location of a file in your workspace. If it is not defined and SERIALIZE_TARGET is true, a model file will be created in the project.
    Beware: the file will be overwritten if it already exists!
  • You can filter the classes to analyze using regular expressions, by setting INCLUDED_ELEMENTS_REGEX and/or EXCLUDED_ELEMENTS_REGEX
  • You can specify additional dependencies (projects or libraries) that you want to analyze and add to the model, by selecting them in the dialog that opens when you click the ELEMENTS_TO_ANALYZE parameter:
Choosing the elements to analyze

Once launched, a progress dialog will appear as soon as the operation begins. Depending on the size of your application, the reverse engineering process might take some time to complete:

Progress dialog

At the end of the process, the newly created model file is added to the root of your project if you set SERIALIZE_TARGET to true:

Java model in the package explorer

And the model is opened in the default model browser if you selected Open model in editor after discovery:

Java model viewed with the MoDisco model browser

The Java XMI files (with a filename ending in "_java.xmi" by convention) can be opened in any model browser:

"Open With" on a Java model

Discoverer API

First, add the following plug-in dependencies to your project (Require-Bundle in your Manifest.MF):

  • org.eclipse.gmt.modisco.java
  • org.eclipse.modisco.java.discoverer
  • org.eclipse.modisco.infra.discovery.core

There are several Java discoverer classes that do the same discovery but on different inputs:

  • DiscoverJavaModelFromJavaProject : from an IJavaProject (defined in jdt.core)
  • DiscoverJavaModelFromProject : from an IProject
  • DiscoverJavaModelFromClassFile : from an IClassFile (defined in jdt.core)
  • DiscoverJavaModelFromLibrary : from an IPackageFragmentRoot (for jars; defined in jdt.core)

You can easily discover a Java model programmatically. For example, to discover a Java model from a Java project:

DiscoverJavaModelFromJavaProject discoverer = new DiscoverJavaModelFromJavaProject();
javaDiscoverer.discoverElement(javaProject, monitor);
Resource javaResource = javaDiscoverer.getTargetModel();

To have a monitor to pass to the discoverElement method, you can either call the discoverer in an Eclipse Job, or pass a new NullProgressMonitor if you don't need progress reporting.

Once you have the Java Resource, you can use the standard EMF API to read model elements. For example, to get the root:

Model javaModel = (Model) javaResource.getContents().get(0);

To print the list of Java classes in the model:

EList<ClassFile> classFiles = javaModel.getClassFiles();
for (ClassFile classFile : classFiles) {
    System.out.println(classFile.getName());
}

Discoverer Benchmark

Installing the benchmark

The Java discoverer benchmark is not included in the MoDisco SDK feature on the Eclipse Indigo update site. You must install it from the MoDisco update site:

Launching the benchmark

  • create a file named javabenchconfig.txt, containing the name of each Java project to benchmark (each on a separate line)
  • right-click on this file, and select Discovery > Discoverers > Java Benchmark > Benchmark Java Discover Time...
launching the benchmark
  • In the parameters dialog, set the number of iterations (parameter ITERATIONS), set SERIALIZE_TARGET to true, and then click OK
MoDisco Launching discovery org.eclipse.modisco.java.discoverer.benchmark.javaBenchmarkTime.png
  • This should create a model named javabench.xmi in your project (or the location of your choice set in TARGET_URI)
  • Right-click on this javabench.xmi model file, and select Discovery > Discoverers > Java Benchmark > Generate HTML Report :
generating the html report
  • Click OK in the parameters dialog
  • This should create two files:
    • javaDiscoveryBenchmark.html : the benchmark report in HTML, that you can view with any Web browser
    • executionTimeByProjectSize.png : a graph referenced by the HTML report, showing the discovery time as function of project size

Benchmark results

Plug-in org.eclipse.modisco.java.discoverer.benchmark implements a benchmark for the Java

Here is an abridged version of the full report generated by org.eclipse.modisco.java.discoverer.benchmark.

Execution time by project size

MoDisco JavaDiscovererBenchmark ExecutionTimeByProjectSize.png

System Information
OS name Windows 7
OS version 6.1
OS architecture x86
Number of processor cores 4
Processor name Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
Processor description x64 Family 6 Model 15 Stepping 11
Processor cache size 8192
System memory 4294967296
Results Overview
Project Average discovery time Average save time Number of model elements Total size Average file size Total lines Average lines per file XMI size
com.ibm.icu 18,69s (σ = 1.203s) 23,44s (σ = 0.611s) 508623 7,4 MiB 21,2 KiB 195347 544 114,9 MiB
org.apache.commons.codec 0,24s (σ = 0.025s) 0,58s (σ = 0.44s) 13207 173,0 KiB 7,2 KiB 5145 214 3,0 MiB
org.apache.commons.el 0,58s (σ = 0.04s) 1,32s (σ = 0.105s) 28525 419,9 KiB 7,4 KiB 14445 253 6,4 MiB
org.apache.commons.httpclient 2,50s (σ = 0.052s) 3,59s (σ = 0.435s) 82215 1,3 MiB 9,8 KiB 39847 286 17,7 MiB
org.apache.commons.logging 0,18s (σ = 0.013s) 0,24s (σ = 0.118s) 8482 125,9 KiB 9,0 KiB 4205 300 1,8 MiB
org.apache.jasper 2,44s (σ = 0.104s) 5,66s (σ = 0.126s) 115261 1,3 MiB 14,2 KiB 42278 435 26,8 MiB
org.apache.lucene.analysis 1,15s (σ = 0.089s) 1,89s (σ = 0.385s) 40297 480,4 KiB 5,9 KiB 15539 189 9,4 MiB
org.apache.lucene.core 7,90s (σ = 0.083s) 10,03s (σ = 0.222s) 219741 3,0 MiB 7,3 KiB 88999 215 48,1 MiB
org.eclipse.ant.core 0,39s (σ = 0.124s) 0,64s (σ = 0.345s) 13837 155,8 KiB 7,1 KiB 4860 220 3,0 MiB
org.eclipse.ant.launching 0,91s (σ = 0.267s) 1,00s (σ = 0.293s) 15535 191,3 KiB 4,7 KiB 6011 146 3,7 MiB
org.eclipse.ant.ui 11,48s (σ = 2.366s) 7,49s (σ = 0.417s) 129526 1,5 MiB 6,0 KiB 44719 172 33,2 MiB
org.eclipse.compare 7,41s (σ = 0.504s) 5,71s (σ = 0.397s) 111553 1,2 MiB 8,0 KiB 38972 248 25,7 MiB
org.eclipse.core.commands 0,71s (σ = 0.024s) 1,50s (σ = 0.147s) 23702 419,8 KiB 5,3 KiB 12940 163 5,2 MiB
org.eclipse.core.filebuffers 0,90s (σ = 0.051s) 0,77s (σ = 0.361s) 17921 244,7 KiB 6,3 KiB 7446 190 4,1 MiB
org.eclipse.core.filesystem 0,39s (σ = 0.026s) 0,90s (σ = 0.469s) 11756 161,2 KiB 6,2 KiB 4674 179 2,7 MiB
org.eclipse.core.jobs 0,53s (σ = 0.028s) 1,08s (σ = 0.295s) 19834 255,2 KiB 7,7 KiB 7980 241 4,6 MiB
org.eclipse.core.resources 8,84s (σ = 0.203s) 9,94s (σ = 0.222s) 185578 2,4 MiB 9,0 KiB 68846 249 44,6 MiB
org.eclipse.core.runtime 0,50s (σ = 0.079s) 1,02s (σ = 0.426s) 17946 293,7 KiB 13,4 KiB 8221 373 3,8 MiB
org.eclipse.equinox.common 0,58s (σ = 0.052s) 1,22s (σ = 0.308s) 24858 324,4 KiB 6,0 KiB 9767 180 5,4 MiB
org.eclipse.equinox.http.jetty 0,09s (σ = 0.03s) 0,15s (σ = 0.083s) 3463 36,4 KiB 5,2 KiB 1028 146 805,0 KiB
org.eclipse.equinox.http.servlet 0,15s (σ = 0.022s) 0,48s (σ = 0.36s) 5667 62,8 KiB 3,3 KiB 1813 95 1,3 MiB
org.eclipse.equinox.launcher 0,29s (σ = 0.019s) 0,63s (σ = 0.357s) 11920 115,8 KiB 23,2 KiB 3381 676 2,7 MiB
org.eclipse.equinox.p2.artifact.repository 0,67s (σ = 0.095s) 1,16s (σ = 0.461s) 20705 213,2 KiB 7,4 KiB 5811 200 5,5 MiB
org.eclipse.equinox.p2.director 0,47s (σ = 0.071s) 1,05s (σ = 0.466s) 16079 170,8 KiB 7,1 KiB 4244 176 4,2 MiB
org.eclipse.equinox.p2.engine 1,02s (σ = 0.053s) 1,65s (σ = 0.085s) 27771 324,0 KiB 5,1 KiB 8652 135 6,9 MiB
org.eclipse.equinox.p2.operations 0,32s (σ = 0.024s) 0,53s (σ = 0.366s) 7105 97,7 KiB 5,4 KiB 2640 146 1,7 MiB
org.eclipse.equinox.p2.publisher 1,51s (σ = 0.13s) 3,35s (σ = 0.038s) 54997 534,2 KiB 7,3 KiB 14637 200 14,1 MiB
org.eclipse.equinox.p2.ui 4,50s (σ = 0.66s) 3,31s (σ = 0.124s) 56459 692,1 KiB 4,9 KiB 19653 140 14,7 MiB
org.eclipse.jdt.core 1m 34s (σ = 1.018s) 1m 29s (σ = 2.533s) 1509903 15,6 MiB 13,6 KiB 441437 374 388,3 MiB
org.eclipse.jdt.debug 13,18s (σ = 0.13s) 10,48s (σ = 0.512s) 185143 2,4 MiB 5,1 KiB 74616 159 45,8 MiB
org.eclipse.jdt.launching 3,81s (σ = 0.247s) 3,26s (σ = 0.098s) 62039 815,1 KiB 7,9 KiB 23555 228 15,0 MiB
org.eclipse.jdt.ui 2m 42s (σ = 12.402s) 1m 38s (σ = 1.483s) 1526115 18,1 MiB 8,9 KiB 526466 253 416,3 MiB
org.eclipse.jface 7,23s (σ = 0.253s) 10,88s (σ = 0.49s) 220340 3,1 MiB 8,3 KiB 103283 271 49,0 MiB
org.eclipse.jface.databinding 1,77s (σ = 0.058s) 1,61s (σ = 0.111s) 30215 437,1 KiB 2,7 KiB 14013 85 7,0 MiB
org.eclipse.jface.text 6,76s (σ = 0.148s) 10,42s (σ = 0.161s) 187105 2,3 MiB 7,4 KiB 76715 236 44,7 MiB
org.eclipse.pde.api.tools 7,13s (σ = 0.428s) 10,33s (σ = 0.493s) 157138 1,8 MiB 9,4 KiB 55043 282 44,5 MiB
org.eclipse.pde.api.tools.ui 9,36s (σ = 7.169s) 3,27s (σ = 0.093s) 55066 618,1 KiB 7,2 KiB 17810 207 15,3 MiB
org.eclipse.pde.build 3,46s (σ = 0.327s) 6,85s (σ = 0.403s) 111778 1,0 MiB 11,2 KiB 28140 299 28,9 MiB
org.eclipse.pde.core 13,21s (σ = 0.509s) 14,36s (σ = 0.578s) 239752 2,6 MiB 5,2 KiB 79619 156 62,1 MiB
org.eclipse.pde.launching 1,25s (σ = 0.079s) 1,24s (σ = 0.493s) 21639 243,9 KiB 7,6 KiB 6268 195 5,4 MiB
org.eclipse.pde.ui 1m 14s (σ = 2.717s) 33,28s (σ = 0.909s) 509523 5,5 MiB 6,0 KiB 161364 174 139,9 MiB
org.eclipse.team.cvs.core 6,67s (σ = 0.599s) 6,23s (σ = 0.559s) 101008 1,2 MiB 6,5 KiB 35313 186 27,6 MiB
org.eclipse.platform 0,11s (σ = 0.088s) 0,03s (σ = 0.017s) 612 6,1 KiB 3,1 KiB 188 94 112,1 KiB
org.eclipse.team.core 3,81s (σ = 0.161s) 3,54s (σ = 0.088s) 68265 965,0 KiB 5,5 KiB 28230 159 16,1 MiB
org.eclipse.team.cvs.ui 30,51s (σ = 0.976s) 13,25s (σ = 0.017s) 201617 2,3 MiB 7,2 KiB 65317 200 54,7 MiB
org.eclipse.team.ui 19,42s (σ = 0.667s) 10,52s (σ = 0.47s) 181471 2,2 MiB 6,6 KiB 65768 191 45,5 MiB
org.eclipse.text 1,76s (σ = 0.04s) 2,70s (σ = 0.438s) 58079 785,0 KiB 6,2 KiB 25329 199 12,9 MiB
org.eclipse.team.cvs.core 6,67s (σ = 0.599s) 6,23s (σ = 0.559s) 101008 1,2 MiB 6,5 KiB 35313 186 27,6 MiB
org.eclipse.ui.browser 0,99s (σ = 0.099s) 0,76s (σ = 0.427s) 19796 227,2 KiB 4,5 KiB 7422 145 4,6 MiB
org.eclipse.ui.cheatsheets 2,72s (σ = 0.052s) 3,08s (σ = 0.1s) 50227 582,7 KiB 4,7 KiB 18173 146 12,7 MiB
org.eclipse.ui.console 1,67s (σ = 0.102s) 1,07s (σ = 0.419s) 23255 309,3 KiB 5,5 KiB 9514 169 5,3 MiB
org.eclipse.ui.editors 6,08s (σ = 0.308s) 4,91s (σ = 0.127s) 85118 1023,5 KiB 8,3 KiB 31060 252 20,6 MiB
org.eclipse.ui.forms 1,69s (σ = 0.052s) 3,28s (σ = 0.123s) 61224 623,6 KiB 7,7 KiB 21458 264 14,9 MiB
org.eclipse.ui.ide 23,19s (σ = 0.399s) 18,96s (σ = 0.371s) 326450 4,2 MiB 7,7 KiB 136921 243 81,2 MiB
org.eclipse.ui.views 0,84s (σ = 0.08s) 0,67s (σ = 0.509s) 13765 206,9 KiB 5,7 KiB 6431 178 3,1 MiB
org.eclipse.ui.views.log 1,00s (σ = 0.151s) 1,01s (σ = 0.423s) 17935 155,7 KiB 7,4 KiB 4951 235 4,6 MiB
org.eclipse.ui.workbench 43,37s (σ = 0.555s) 37,53s (σ = 0.422s) 667009 9,3 MiB 7,1 KiB 298752 222 157,9 MiB
org.eclipse.ui.workbench.texteditor 5,39s (σ = 0.418s) 5,02s (σ = 0.111s) 98975 1,2 MiB 8,1 KiB 39885 254 22,5 MiB
org.eclipse.acceleo.compatibility.ui 0,28s (σ = 0.2s) 0,09s (σ = 0.043s) 1960 20,0 KiB 10,0 KiB 532 266 497,6 KiB
org.eclipse.acceleo.profiler.editor 0,40s (σ = 0.149s) 0,13s (σ = 0.047s) 2142 22,8 KiB 3,3 KiB 751 107 500,0 KiB
org.eclipse.acceleo.profiler.edit 0,56s (σ = 0.038s) 0,21s (σ = 0.197s) 2941 42,3 KiB 4,7 KiB 1281 142 655,7 KiB
org.eclipse.acceleo.traceability 0,79s (σ = 0.08s) 1,14s (σ = 0.544s) 15974 182,6 KiB 12,2 KiB 4992 332 4,2 MiB
org.eclipse.acceleo.profiler 0,88s (σ = 0.026s) 0,25s (σ = 0.097s) 6890 95,5 KiB 5,6 KiB 3238 190 1,5 MiB
org.eclipse.acceleo.common 1,69s (σ = 1.004s) 1,27s (σ = 0.319s) 20616 255,2 KiB 8,8 KiB 8178 282 4,7 MiB
org.eclipse.acceleo.engine 1,71s (σ = 0.196s) 1,90s (σ = 0.088s) 32517 420,7 KiB 8,8 KiB 11778 245 8,2 MiB
org.eclipse.acceleo.traceability.model 1,82s (σ = 0.032s) 0,00s (σ = 0.0s) 22830 282,0 KiB 9,1 KiB 9257 298 0 bytes
org.eclipse.acceleo.ide.ui 18,88s (σ = 1.95s) 12,34s (σ = 0.033s) 170407 2,0 MiB 6,7 KiB 60601 202 50,3 MiB
org.eclipse.acceleo.model.edit 2,88s (σ = 0.146s) 1,26s (σ = 0.516s) 18678 264,1 KiB 8,5 KiB 7091 228 5,8 MiB
org.eclipse.acceleo.compatibility 5,21s (σ = 0.041s) 3,05s (σ = 0.462s) 45555 613,9 KiB 6,0 KiB 20028 194 13,1 MiB
org.eclipse.acceleo.model 5,76s (σ = 0.097s) 2,82s (σ = 0.544s) 46008 623,6 KiB 7,9 KiB 21313 269 11,1 MiB
org.eclipse.acceleo.parser 5,83s (σ = 0.077s) 5,54s (σ = 0.434s) 83502 985,8 KiB 10,8 KiB 31013 340 22,5 MiB
org.eclipse.emf.importer.ecore 0,23s (σ = 0.03s) 0,07s (σ = 0.033s) 1608 17,6 KiB 3,5 KiB 562 112 363,4 KiB
org.eclipse.emf.ant 0,27s (σ = 0.176s) 0,26s (σ = 0.205s) 3268 44,5 KiB 4,0 KiB 1806 164 721,0 KiB
org.eclipse.emf.codegen.ui 0,47s (σ = 0.218s) 0,11s (σ = 0.056s) 2620 25,0 KiB 5,0 KiB 855 171 620,0 KiB
org.eclipse.emf.databinding.edit 0,49s (σ = 0.021s) 0,21s (σ = 0.1s) 5750 89,7 KiB 3,4 KiB 2811 108 1,3 MiB
org.eclipse.emf.databinding 0,60s (σ = 0.033s) 0,74s (σ = 0.583s) 9877 137,4 KiB 3,9 KiB 4738 135 2,3 MiB
org.eclipse.emf.mapping.ecore2ecore 0,61s (σ = 0.031s) 0,11s (σ = 0.06s) 2860 45,8 KiB 3,5 KiB 1715 131 613,4 KiB
org.eclipse.emf.exporter 0,67s (σ = 0.19s) 0,71s (σ = 0.595s) 6852 74,5 KiB 5,7 KiB 2477 190 1,6 MiB
org.eclipse.emf.cheatsheets 0,75s (σ = 0.425s) 0,12s (σ = 0.034s) 2238 26,3 KiB 2,9 KiB 909 101 498,8 KiB
org.eclipse.emf.ecore.change.edit 0,77s (σ = 0.059s) 0,14s (σ = 0.078s) 3684 56,7 KiB 7,1 KiB 1933 241 844,8 KiB
org.eclipse.emf.importer 0,84s (σ = 0.119s) 0,76s (σ = 0.611s) 9700 101,2 KiB 7,2 KiB 3612 258 2,3 MiB
org.eclipse.emf.importer.rose 0,88s (σ = 0.019s) 2,03s (σ = 0.126s) 23190 221,5 KiB 10,1 KiB 7512 341 6,3 MiB
org.eclipse.emf.mapping.ecore2xml 0,91s (σ = 0.017s) 0,22s (σ = 0.101s) 6468 88,5 KiB 5,2 KiB 3155 185 1,5 MiB
org.eclipse.emf.importer.java 0,94s (σ = 0.115s) 0,86s (σ = 0.611s) 12563 135,4 KiB 12,3 KiB 3944 358 3,5 MiB
org.eclipse.emf.converter 0,99s (σ = 0.031s) 1,24s (σ = 0.68s) 11188 114,6 KiB 9,5 KiB 3991 332 2,7 MiB
org.eclipse.emf.mapping.ecore2ecore.editor 1,16s (σ = 0.12s) 0,29s (σ = 0.155s) 3834 43,5 KiB 6,2 KiB 1462 208 967,4 KiB
org.eclipse.emf.common 1,28s (σ = 0.028s) 0,00s (σ = 0.0s) 51015 632,3 KiB 11,3 KiB 22954 409 0 bytes
org.eclipse.emf.common.ui 1,31s (σ = 0.212s) 1,44s (σ = 0.704s) 19386 198,2 KiB 7,9 KiB 6995 279 4,9 MiB
org.eclipse.emf.ecore.editor 1,43s (σ = 0.321s) 0,77s (σ = 0.756s) 10393 119,8 KiB 17,1 KiB 4091 584 2,5 MiB
org.eclipse.emf.mapping.ui 1,48s (σ = 0.132s) 0,92s (σ = 0.601s) 13705 160,8 KiB 12,4 KiB 5081 390 3,7 MiB
org.eclipse.emf.mapping.ecore2xml.ui 1,56s (σ = 0.07s) 1,26s (σ = 0.708s) 11275 137,6 KiB 15,3 KiB 4672 519 2,8 MiB
org.eclipse.emf.ecore.change 1,57s (σ = 0.057s) 1,93s (σ = 0.139s) 20998 262,2 KiB 11,9 KiB 8853 402 5,1 MiB
org.eclipse.emf.codegen.ecore 13,90s (σ = 0.873s) 24,14s (σ = 1.482s) 259343 3,0 MiB 28,8 KiB 77618 732 78,9 MiB
org.eclipse.emf.ecore 17,86s (σ = 1.122s) 0,00s (σ = 0.0s) 287818 3,4 MiB 21,5 KiB 112428 702 0 bytes
org.eclipse.emf.edit.ui 2,35s (σ = 0.339s) 2,08s (σ = 0.105s) 25384 291,3 KiB 7,9 KiB 9934 268 6,5 MiB
org.eclipse.emf.ecore.edit 2,48s (σ = 0.07s) 0,84s (σ = 0.597s) 13615 194,0 KiB 8,8 KiB 6433 292 3,3 MiB
org.eclipse.emf.mapping 2,89s (σ = 0.096s) 2,15s (σ = 0.09s) 30469 397,7 KiB 7,4 KiB 13789 255 7,2 MiB
org.eclipse.emf.codegen 3,05s (σ = 0.559s) 4,39s (σ = 0.195s) 56661 687,2 KiB 8,6 KiB 23621 295 15,0 MiB
org.eclipse.emf.codegen.ecore.ui 3,10s (σ = 0.584s) 1,50s (σ = 0.707s) 20983 285,9 KiB 15,9 KiB 9199 511 5,5 MiB
org.eclipse.emf.edit 3,17s (σ = 0.066s) 3,52s (σ = 0.712s) 50579 685,6 KiB 8,7 KiB 22992 291 12,1 MiB
org.eclipse.emf.ecore.xmi 3,36s (σ = 0.071s) 4,08s (σ = 0.088s) 50396 543,1 KiB 8,8 KiB 19036 307 13,3 MiB
org.eclipse.uml2.common.edit 0,47s (σ = 0.13s) 0,14s (σ = 0.071s) 2725 30,3 KiB 2,2 KiB 1156 82 714,9 KiB
org.eclipse.uml2.codegen.ecore.ui 1,55s (σ = 0.305s) 0,22s (σ = 0.089s) 4156 65,4 KiB 4,7 KiB 2226 159 997,1 KiB
org.eclipse.uml2.common 1,64s (σ = 0.059s) 0,92s (σ = 0.634s) 14477 140,8 KiB 5,6 KiB 5711 228 3,2 MiB
org.eclipse.uml2.uml.editor 13,99s (σ = 1.21s) 1,53s (σ = 0.656s) 14495 160,6 KiB 7,6 KiB 5562 264 3,8 MiB
org.eclipse.uml2.examples.uml.ui 19,25s (σ = 4.111s) 0,90s (σ = 0.933s) 7142 87,3 KiB 4,4 KiB 2630 131 2,3 MiB
org.eclipse.uml2.uml.ecore.exporter 2,60s (σ = 0.344s) 0,14s (σ = 0.074s) 2173 19,0 KiB 4,7 KiB 608 152 530,1 KiB
org.eclipse.uml2.uml.edit 3m 58s (σ = 17.581s) 15,18s (σ = 2.331s) 153363 2,3 MiB 9,3 KiB 73323 287 40,1 MiB
org.eclipse.uml2.uml.ecore.importer 3,87s (σ = 0.313s) 0,23s (σ = 0.107s) 4026 38,6 KiB 7,7 KiB 1120 224 1,1 MiB
org.eclipse.uml2.codegen.ecore 6,33s (σ = 1.111s) 10,43s (σ = 1.277s) 97281 1,0 MiB 21,9 KiB 25180 535 34,9 MiB
org.eclipse.uml2.uml 10m 20s (σ = 15.663s) 1m 43s (σ = 6.975s) 1260305 18,6 MiB 26,1 KiB 584111 802 304,1 MiB

Java Generation

The goal of the Java Generation plug-in is to allow Java code generation from a Java model. Such a generation will fulfill some of the requirements for Legacy refactoring & migration.

Description

JavaM2T.PNG

This plug-in proposes Acceleo MTL modules for generating Java files conforming to Java models. Templates are contained in two modules :

  • Structures modules : top level templates for generating classes/method/field declarations
  • Statements modules

Java models are obtained with Java Discoverer component.

Considering a Java legacy, a minimal migration/refactoring chain will involve :

  • A Java model discovery step
  • A M2M transformation step
  • A Java generation code step with the current component

User manual

A prerequisite is a Java model. Please refer to the Java Discoverer user manual.

To launch a Java generation:

  • Add org.eclipse.gmt.modisco.java.generation in your plugin dependencies and use the GenerateJavaExtended main method with input model and target folder as parameters. The code should look like this :
GenerateJavaExtended javaGenerator = new GenerateJavaExtended(URI.createFileURI("C:/.../my.javaxmi"),
    new File("C:/.../myOutputFolder"), new ArrayList<Object>());
javaGenerator.doGenerate(null);

Or

  • Checkout org.eclipse.gmt.modisco.java.generation into the workspace from Eclipse SVN repository, and then Create an Accelo launch configuration pointing to GenerateJavaExtended java class, and specify the input model and target folder. Use "Acceleo plugin Application" runner in launch configuration. If an error "could not load class GenerateJavaExtended" occurs, it may be caused by an already installed 'org.eclipsxe.gmt.modisco.java.generation' plugin, thus you may use "Java Application" runner (however, with this second runner, Java code formating step, launched at the end of the generation, will not work if the classpath is not completed with the required related java libraries.

Java model to KDM model transformation

The goal of the "Java to KDM transformation" discoverer is to get a KDM model from a Java model. It is useful when the only available information on a java source code is contained in a Java model. Even without the source code it is then possible to get a KDM representation.

User Manual

A prerequisite is a Java model. Please refer to the Java Discoverer user manual.

Discovering a KDM code model from a Java model


Once launched, a progress dialog will appear as soon as the operation begins. Depending on the size of your java model, the transformation might take some time to complete:

Progress bar during java model transformation

At the end of the process, the newly created model files are added to the root of your project:

KDM model

And the model is automatically opened in the default model browser if you selected "Open model in editor after discovery":

KDM model in the MoDisco Model Browser

KDM Discoverer API

This discoverer can also be called programmatically (see the Java Discoverer API). Use either:

  • DiscoverKDMModelFromJavaModel
  • DiscoverKDMModelFromJavaProject
  • DiscoverKDMModelFromProject

from plug-in org.eclipse.modisco.java.discoverer

Install

You can install the Java discoverer and associated metamodel from the MoDisco update site.

Source Repository

All the source code is stored in the Eclipse public source repository:


MoDisco
Components Infrastructure: KDM · SMM · GASTM · Model Browser · Discovery Manager · MoDisco Workflow · Query Manager · Facet Manager · Metrics Visualization Builder · KDM Source Extension
Technologies: Java · JEE · EjbJar · WebApp · XML
Use Cases: Simple Transformation Chain · Model Filter
Help Installation · SVN
Project API Policy · Retention Policy · Project Plan · metrics · Accessibility Guidelines · Capabilities Disablement

Back to the top