|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Need an example of MDR usageHi I need to generate JMI interfaces from a uml1.4 xmi file exported by argo uml. The code below throws class cast exception when i try to cast umlMetaModel to ModelPackage in the for loop. Alternatively can anyone point me to a basic example of programmatic JMI interface genreation using MDR. Thanks, JS public class MyMDR { /** * @param args */ public static void main(String[] args) { MDRManager manager = MDRManager.getDefault(); MDRepository repository = manager.getDefaultRepository(); XMIReaderFactory factory = XMIReaderFactory.getDefault(); XMIReader reader = factory.createXMIReader(); RefPackage umlMetaModel; repository.beginTrans(true); try { // put the UML metamodel into MDR FileInputStream in = new FileInputStream( "/xmi/01-02-15.xml"); umlMetaModel = repository.getExtent("UML-MetaModel"); MofPackage umlPackage = null; for (Iterator it = ((ModelPackage) umlMetaModel).getMofPackage() .refAllOfClass().iterator(); it.hasNext();) { MofPackage temp = (MofPackage) it.next(); if ("UML".equals(temp.getName())) { umlPackage = temp; break; } } RefPackage umlInstance = repository.createExtent( "umlInstance", umlPackage); JMIMapper mapper = JMIMapper.getDefault(); mapper.generate(new FileStreamFactory(new File(".")), umlInstance); } catch (Exception e) { e.printStackTrace(); } } } This document is strictly confidential and intended only for use by the addressee unless otherwise stated. If you are not the intended recipient, please notify the sender immediately and delete it from your system. |
|
|
Re: Need an example of MDR usageHi Jess,
you can generate JMI interfaces from MOF models only. JMI defines MOF->Java mapping, not UML 1.4->Java mapping. One thing you could do is to convert your UML 1.4 model to a MOF model (using UML2MOF tool - see http://mdr.netbeans.org/uml2mof) - you just need to make sure your UML model conforms to UML Profile for MOF defined on the UML2MOF web page). Then you can generate JMI interfaces from that MOF model. Martin Jess.Singh@... wrote: > Hi I need to generate JMI interfaces from a uml1.4 xmi file exported by > argo uml. The code below throws class cast exception when i try to cast > umlMetaModel to ModelPackage in the for loop. > Alternatively can anyone point me to a basic example of programmatic JMI > interface genreation using MDR. > > Thanks, > JS > > public class MyMDR { > > /** > * @param args > */ > public static void main(String[] args) { > > MDRManager manager = MDRManager.getDefault(); > MDRepository repository = manager.getDefaultRepository(); > XMIReaderFactory factory = XMIReaderFactory.getDefault(); > XMIReader reader = factory.createXMIReader(); > RefPackage umlMetaModel; > repository.beginTrans(true); > > try { > // put the UML metamodel into MDR > > FileInputStream in = new FileInputStream( > "/xmi/01-02-15.xml"); > umlMetaModel = repository.getExtent("UML-MetaModel"); > > > MofPackage umlPackage = null; > for (Iterator it = ((ModelPackage) > umlMetaModel).getMofPackage() > .refAllOfClass().iterator(); it.hasNext();) { > MofPackage temp = (MofPackage) it.next(); > if ("UML".equals(temp.getName())) { > umlPackage = temp; > break; > } > } > > RefPackage umlInstance = repository.createExtent( > "umlInstance", > umlPackage); > > JMIMapper mapper = JMIMapper.getDefault(); > > mapper.generate(new FileStreamFactory(new File(".")), > umlInstance); > } catch (Exception e) { > e.printStackTrace(); > } > > } > > } > > > > This document is strictly confidential and intended only for use by the addressee unless otherwise stated. If you are not the intended recipient, please notify the sender immediately and delete it from your system. > > |
| Free Forum Powered by Nabble | Forum Help |