Skip to main content



      Home
Home » Modeling » MoDisco » How to Load JavaModel (file.javaxmi)
How to Load JavaModel (file.javaxmi) [message #982753] Tue, 13 November 2012 06:46 Go to next message
Eclipse UserFriend
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 11:23 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: How to Load JavaModel (file.javaxmi) [message #983149 is a reply to message #983040] Tue, 13 November 2012 13:16 Go to previous message
Eclipse UserFriend
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: Tue May 20 00:45:48 EDT 2025

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

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

Back to the top