Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » How to Load JavaModel (file.javaxmi)
How to Load JavaModel (file.javaxmi) [message #982753] Tue, 13 November 2012 11:46 Go to next message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 67
Registered: September 2012
Member
Hello guys bonjour, I have read two or three topics closely related to this. However, I couldn't figured out yet how to load a file .javaxmi correctly. In the bellow chunk of source code I have been tried to load a .javaxmi file which was discovered by MoDiSCO, but I haven't succeeded yet. The problem is when I try to make some Cast Operation..For instance, see the bellow code...

                JavaapplicationPackage.eINSTANCE.eClass();
		
		JavaPackage.eINSTANCE.eClass();

		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().
		put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); 

		ResourceSet resSet = new ResourceSetImpl();
		Resource resource = resSet.getResource(URI.createURI("file:/path/TestModisco.javaxmi"), true);
                resource.load(null);
                EcoreUtil.resolveAll(resSet);
                ModelImpl model = (ModelImpl)resource.getContents().get(0);

                //I always get an error during the Cast Operation...
               JavaApplication javaVari = (JavaApplication)resource.getContents().get(0);


I always get a error during the Cast Operation. Thus, I would like to know how to obtain the "classes", "methods" and even "variable declaration" after loaded the javaxmi model? Please, I'll be so glad to see an example. Thanks in advance.
Re: How to Load JavaModel (file.javaxmi) [message #983040 is a reply to message #982753] Tue, 13 November 2012 16:23 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 616
Registered: July 2009
Senior Member
Hello,

The root element of a MoDisco Java model is a model element of type Model (and not JavaApplication), so this is probably why you're getting such a cast exception.
Then, in order to know how you can access to the various model elements according to their types and/or references, I encourage you to take a deeper look into the "Java metamodel" section of the MoDisco reference documentation.

Best regards,

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: How to Load JavaModel (file.javaxmi) [message #983149 is a reply to message #983040] Tue, 13 November 2012 18:16 Go to previous message
Rafael Durelli is currently offline Rafael DurelliFriend
Messages: 67
Registered: September 2012
Member
Thanks Hugo Bruneliere, I didn't know about the documentation. Thanks again.
Previous Topic:Programmatically get kdm instance v0.10
Next Topic:Migration from EJB 2.1 to EJB 3.0
Goto Forum:
  


Current Time: Fri Dec 19 13:03:13 GMT 2014

Powered by FUDForum. Page generated in 0.01673 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software