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, ...
- 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).
hi
ReplyDeletedoes anyone know if there is a way to programmaticly generate the java model from a folder containing java source code?
Cheers B
Hi,
ReplyDeleteHere is an example of code showing how to programmatically create a java model from java source code :
// Create a discoverer for a Java project
DiscoverJavaModelFromJavaProject javaDiscoverer = new DiscoverJavaModelFromJavaProject();
// Parameters of the discoverer
Map javaDiscoveryParameters = new HashMap();
javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILENT_MODE,true);
javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROWSE_RESULT,false);
// Execute the discoverer (javaProject is a IJavaProject)
javaDiscoverer.discoverElement(javaProject, javaDiscoveryParameters);
// Get the result model
Resource javaModel=(Resource) javaDiscoveryParameters .get(DefaultDiscoverer.PARAMETER_TARGET_RESOURCE)
If you need help, you can post your questions directly on the MoDisco forum :
http://www.eclipse.org/forums/index.php?t=thread&frm_id=21&
Hi Fred,
ReplyDeleteI used your example and got it to work in a simple EclipseApp setup...
Unfortunatly there is a problem with the
javaDiscoverer.discoverElement(javaProject, javaDiscoveryParameters);
part:
line 187 from the "DiscoverJavaModelFromJavaProject" class
===resource.getContents().add(model);===
keeps throwing an Exception:
java.lang.ArrayStoreException: org.eclipse.gmt.modisco.java.emf.impl.ModelImpl
and after that in line 218 inside the catch
"JavaActivator.getDefault()" returns null...
do you have an idea why this could be the case?
Thanx in advance
Cheers
Björn
Fred, thanks for this blog. Is it possible to do something similar for sql. In other words is there ECore definition for all sql language.
ReplyDeleteI have need to reverse engineer oracle sql code and convert it to a different model(piglatin). Is it doable.
Hi Ganesh,
ReplyDeleteYes it is possible to do something similar for sql, but it is not provided by MoDisco ... yet.
There are two things to do:
1) Define an ECore model for sql. Depending on what you want to reverse-engineer (schema, queries or data), the model will not be the same. You can find here a basic metamodel for Database Schema : http://www.emn.fr/z-info/atlanmod/index.php/Ecore#RelationalDBSchema_1.0
Or you can reuse the KDM model which contains a Data Package defining classes such as RelationalSchema, RelationalTable, UniqueKey, ReferenceKey, etc). This model is defined by the OMG and an implementation is provided by MoDisco (http://wiki.eclipse.org/MoDisco/Components/KDM).
2) Develop a discoverer to create a model from existing source code. If you want to create a model from the schema definition, you have two possibilities: parse the schema definition (using xText for example ?) or use JDBC to get the schema definition directly from an instance of the database.
If you develop such a component, it would be great if you could contribute it to MoDisco ;-)
Thanks for the prompt response. I would like to model sql queries and generate pig latin/hadoop code from it.
ReplyDeleteI will definitely contribute to modisco if i am successful. Can you refer to a simple example for the two steps you mentioned in this blog.
So you need a IJavaProject, do you need any way to simulate that and execute it outside Eclipse?
ReplyDeleteHi Fred, could you help me by providing me the java metamodel because i need it to create a model for a java application that i have its source code.
ReplyDeletethanks
Mahmoud
Good creation ,thanks for good info
ReplyDeleteJava Online Course Hyderabad
very informative blog and useful article thank you for sharing with us , keep posting Ruby on Rails Online Training Hyderabad
ReplyDeleteThank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
ReplyDeleteinternships provider in khammam
internships in khammam for cse students 2019
ReplyDeleteThank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
paid summer internships in kurnool
internships in kurnool for bba students
java internship in guntur
paid internships in Guntur
internships for freshers in vijayawada
project internships in vijayawada
Kocaeli
ReplyDeleteDenizli
Bartın
Kocaeli
Adana
XZE3
C9B0E
ReplyDeleteNevşehir Şehir İçi Nakliyat
Kayseri Şehir İçi Nakliyat
Iğdır Parça Eşya Taşıma
Ünye Petek Temizleme
Niğde Lojistik
Ankara Şehir İçi Nakliyat
Bursa Evden Eve Nakliyat
Karapürçek Boya Ustası
Bursa Lojistik
EAEE4
ReplyDeleteWabi Coin Hangi Borsada
Kırıkkale Parça Eşya Taşıma
Kastamonu Parça Eşya Taşıma
Edirne Şehir İçi Nakliyat
Kocaeli Şehirler Arası Nakliyat
Balıkesir Evden Eve Nakliyat
Bursa Parça Eşya Taşıma
Kayseri Şehir İçi Nakliyat
Batman Evden Eve Nakliyat
0CF5A
ReplyDeleteyozgat ücretsiz sohbet siteleri
en iyi ücretsiz sohbet siteleri
telefonda sohbet
kilis bedava görüntülü sohbet sitesi
Muğla Canli Sohbet Bedava
elazığ bedava görüntülü sohbet
urfa sohbet siteleri
çankırı en iyi ücretsiz sohbet uygulamaları
batman canlı sohbet odaları
Respect and that i have a dandy supply: Where To Buy Houses That Need Renovation total home renovation
ReplyDelete