J***@SITA.aero
2007-03-09 14:40:29 UTC
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.
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.