Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » load profile(how to load a profile with a program)
load profile [message #759303] Mon, 28 November 2011 10:32 Go to next message
Hilaire  is currently offline Hilaire Friend
Messages: 20
Registered: July 2009
Junior Member

I'am developping a tool to transform UML stereotyped models to JAVA. For this I use an UML profile which contains stereotype that add attributes to classes (designed with papyrus) and wrapped in a specific plugin with an extension point (pathmap://MyProfiles/crio.profile.uml).

Now I want to load this profile within a program. I have found several topics on the subject and tried to follow these hints but it never worked. My plugin has as dependency the previous plugin and I try to load with the resourceSet.getPackageRegistry().put("pathmap://MyProfiles/crio.profile.uml",org.eclipse.uml2.uml.UMLPackage.eINSTANCE);

I also tried to register a factory
public void registerResourceFactories(ResourceSet resourceSet) {
// TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
// resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put
new XMIResourceFactoryImpl()
public Resource createResource(URI uri)
XMIResource xmiResource = new XMIResourceImpl(uri);
return xmiResource;


and the last thing I tried was to load by

final String profile = "profiles/crio.profile.uml";
URL url = getClass().getClassLoader().getResource(profile);
if (url == null)
throw new RuntimeException("Error getting crio.profile.uml");
String urlString = url.toString();
if (!urlString.endsWith(profile))
throw new RuntimeException("Error getting crio.profile.uml. Got: " +
urlString = urlString.substring(0, urlString.length() - profile.length());
URI uri = URI.createURI(urlString);org.eclipse.uml2.uml.Package package_ = null;

System.out.println("URI ="+uri+"\n");
try {

Resource resource = resourceSet.getResource(uri, true); //URI.createURI("PATHMAP://MyProfiles/crio.profile.uml")

package_ = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(

resource.getContents(), UMLPackage.Literals.PACKAGE);

} catch (WrappedException we) {




Is there somewhere a tutorial/document that explains how to do this ?


Re: load profile [message #760086 is a reply to message #759303] Thu, 01 December 2011 09:20 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member


Your problem is about the loading of an UML model with profiles by EMF, as I don't have the answer I suggest you to ask the question of the loading of your model in the UML forum (some people seems to have already asked this question). Acceleo loads the input model by using its path (and gives you the opportunity to specify which packages and resource factories you want to register but not only you can customize this behavior (you can always override the method initialize in the launcher) but you can also start an Acceleo generation with an already loaded EMF model.


Stephane Begaudeau, Obeo

Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Acceleo Documentation:
Previous Topic:plug-in and IDE error, my acceleo UI launcher is not invoking all modules
Next Topic:'.emtl' not found
Goto Forum:

Current Time: Fri Mar 31 10:29:23 GMT 2023

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

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

Back to the top