Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [Epsilon] Standalone: Deprecated EmfModel constants
[Epsilon] Standalone: Deprecated EmfModel constants [message #722827] Tue, 06 September 2011 20:04 Go to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 155
Registered: October 2009
Senior Member

Hello,

Recently while working in my standalone implementation the following method started showing deprecated warnings:
protected EmfModel createEmfModel(String name, String model, String metamodel, boolean readOnLoad, boolean storeOnDisposal) throws EolModelLoadingException, URISyntaxException {
    EmfModel emfModel = new EmfModel();
    StringProperties properties = new StringProperties();
    properties.put(EmfModel.PROPERTY_NAME, name);
    properties.put(EmfModel.PROPERTY_METAMODEL_FILE, metamodel);
    properties.put(EmfModel.PROPERTY_MODEL_FILE, model);
    properties.put(EmfModel.PROPERTY_IS_METAMODEL_FILE_BASED, "true");
    properties.put(EmfModel.PROPERTY_READONLOAD, readOnLoad + "");
    properties.put(EmfModel.PROPERTY_STOREONDISPOSAL, storeOnDisposal + "");
    emfModel.load(properties, null);
    return emfModel;
}


in the PROPERTY_METAMODEL_FILE and PROPERTY_MODEL_FILE fields.

Can you tell me the new fields I should use? Or should I just @Supreswarnings for the mean time?

Regards,

Horacio


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: [Epsilon] Standalone: Deprecated EmfModel constants [message #722912 is a reply to message #722827] Wed, 07 September 2011 07:40 Go to previous messageGo to next message
Louis Rose is currently offline Louis Rose
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Horacio,

We've deprecated the PROPERTY_MODEL_FILE and PROPERTY_METAMODEL_FILE keys in favour of PROPERTY_MODEL_URI and PROPERTY_FILE_BASED_METAMODEL_URI respectively. If you'd like to avoid the deprecation warnings, you'll need change the method like so:

protected EmfModel createEmfModel(String name, URI model, URI metamodel, boolean readOnLoad, boolean storeOnDisposal) throws EolModelLoadingException, URISyntaxException {
    EmfModel emfModel = new EmfModel();
    StringProperties properties = new StringProperties();
    properties.put(EmfModel.PROPERTY_NAME, name);
    properties.put(EmfModel.PROPERTY_FILE_BASED_METAMODEL_URI, metamodel);
    properties.put(EmfModel.PROPERTY_MODEL_URI, model);
    properties.put(EmfModel.PROPERTY_IS_METAMODEL_FILE_BASED, "true");
    properties.put(EmfModel.PROPERTY_READONLOAD, readOnLoad + "");
    properties.put(EmfModel.PROPERTY_STOREONDISPOSAL, storeOnDisposal + "");
    emfModel.load(properties, null);
    return emfModel;
}


Note that the model and metamodel parameters are now of type org.eclipse.emf.common.util.URI. To construct a URI, you can use one of the static methods on the URI class, such as:

URI#createFileURI
URI#createPlatformResourceURI

Finally, in case you're curious, you can see more information on the keys and values that can be used to load an EMF model with Epsilon in the Javadoc for the EmfModel class:

http://dev.eclipse.org/viewcvs/viewvc.cgi/trunk/plugins/org.eclipse.epsilon.emc.emf/src/org/eclipse/epsilon/emc/emf/EmfModel.java?view=markup&root=Modeling_EPSILON

Hope that helps,
Louis.
Re: [Epsilon] Standalone: Deprecated EmfModel constants [message #726382 is a reply to message #722912] Sat, 17 September 2011 18:55 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 155
Registered: October 2009
Senior Member

Thanks for the information Louis,

So basically no more loading models from a string path Very Happy. I recall having some issues with URIs and files in the eclipse workbench... I will update my implementation, do some tests and post my findings.

Horacio


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: [Epsilon] Standalone: Deprecated EmfModel constants [message #726384 is a reply to message #726382] Sat, 17 September 2011 19:54 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 155
Registered: October 2009
Senior Member

Louis,

As models are now loaded using org.eclipse.emf.common.util.URI uris, is there a plan to migrate all uses of Epsilon URI class to this one? Particularly, the IEolExecutableModule.parse() method can accept an URI but of the java.net.URI class. I know the parse method also accepts a String path argument but personally I would like to keep all my references as URIs.

Thanks,

Horacio


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: [Epsilon] Standalone: Deprecated EmfModel constants [message #726747 is a reply to message #726384] Mon, 19 September 2011 12:37 Go to previous message
Louis Rose is currently offline Louis Rose
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Horacio,

Horacio wrote on Sat, 17 September 2011 15:54
As models are now loaded using org.eclipse.emf.common.util.URI uris, is there a plan to migrate all uses of Epsilon URI class to this one? Particularly, the IEolExecutableModule.parse() method can accept an URI but of the java.net.URI class. I know the parse method also accepts a String path argument but personally I would like to keep all my references as URIs.


I agree that this inconsistency is undesirable, but unfortunately it's not something that we're likely to change...

Because some of our users execute Epsilon programs outside an Eclipse environment (either via ANT or as a truly standalone Java program), the Epsilon language engines cannot depend on EMF (as some parts of EMF require an Eclipse platform to be available). In short, this means that we cannot use EMF URIs for any part of the language engines, such as the parse methods of the various Epsilon modules.

Another approach that would introduce consistency is for Epsilon to use java.net.URIs everywhere, but this is also problematic. EMF provides its own implementation of URI in order to add new functionality, such as the platform:/resource and platform:/plugin forms of a URI. If we were to change Epsilon's EmfModel class to use java.net.URIs, we would have difficulty supporting these forms of URI.

So, unfortunately it seems we will be stuck with this inconsistency until such a time that the java.net.URI class is modernised (which I can only hope happens soon).

I hope this has at least provided some explanation for why this inconsistency exists!

Cheers,
Louis.


Previous Topic:[EuGENia] Nodes with images
Next Topic:Java/ANT/Epsilon Problem: failed to create task or type epsilon.loadModel
Goto Forum:
  


Current Time: Thu Oct 23 14:43:51 GMT 2014

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

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