[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt] Re: [UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY

Hi Kenn,

Thanks for the advice.

Well, it seemed that the URI "pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml" has to be resolved manually, otherwise it could not be resolved by EMF. (I always got the "MalformedURLException")

So I solved the problem like this: * I extract the "UMLPrimitiveTypes.library.uml" from the JAR file, and save it in my current project dir.
* and then register the the pathmap-URI with with the physical one(the one in my project dir), and now I was able to load the primitive type lib and get the primitive types.


Jinhui

The code looks like this:

ResourceSet RESOURCE_SET = new
RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map uriMap = RESOURCE_SET.getURIConverter().getURIMap();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("uml", new UMLResourceFactoryImpl());


Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
URIConverter.URI_MAP.put(URI.createURI("pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml"), URI.createFileURI(System.getProperty("user.dir") + "/Model_Libs/UMLPrimitiveTypes.library.uml"));


Resource resource = RESOURCE_SET.getResource(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), true);


Kenn Hussey wrote:

Jinhui,

Its sounds like a resource factory has not been registered to hande the URI you are trying load. The FAQ entry that I pointed you to shows how to do this: