Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Model caching problem
Model caching problem [message #872034] Tue, 15 May 2012 10:49 Go to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Hello,

I have a caching problem when using EGL to generate code from a model. An old model version is used to generate the code.

I tracked it down to EmfModelResourceSet.java (in org.eclipse.epsilon.emc.emf). The resourceFactory is used to create a new resource
Resource result = resourceFactory.createResource(uri);


The createResource() method (org.eclipse.epsilon.emc.emf.EmfModelResourceFactory) checks if the resource is already available (which is the case) and returns this. But this is an old version of the model...

Am I doing something wrong, and should I tell some cache that the resource got updated (in my editor, eg after saving)? Do I need to manually clear the cache? Or should Epsilon forcefully clear the resource cache?

[Updated on: Wed, 16 May 2012 11:54]

Report message to a moderator

Re: Model caching problem [message #872066 is a reply to message #872034] Tue, 15 May 2012 12:04 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Before I load the inputModel, I added this code to clear the cached version:
java.util.URI inputModel = ...;
EmfModelResourceFactory.getInstance().removeCachedResource(org.eclipse.emf.common.util.URI.createURI(inputModel.toString());


This seems to 'solve' my problem...
Re: Model caching problem [message #872504 is a reply to message #872066] Wed, 16 May 2012 08:42 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 310
Registered: January 2010
Senior Member
Maarten, thank you for your workaround Smile. In any case, before we can decide if it's a bug in Epsilon or not, we'd need to know more about how the model transformation is being launched.

Are you really using EVL for generating code, and not EGL? EVL is intended for validation, not for model-to-text transformations :-/. Perhaps you meant EWL, the Epsilon Wizard Language?
Re: Model caching problem [message #872583 is a reply to message #872504] Wed, 16 May 2012 11:54 Go to previous message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Oops typo, I use EGL of course! (I'll change my first post as well)

Here is the code on how I execute my EGL template:
    EglFileGeneratingTemplateFactory factory = createTemplateFactory();
    factory.setTemplateRoot(myEGLTemplateURI.resolve(".").toString());

    FrameStack frameStack = factory.getContext().getFrameStack();
    // Declare some variables
    frameStack.put(new Variable(VAR, value, EolNativeType.Instance));

    // My workaround for this problem
    org.eclipse.emf.common.util.URI file = org.eclipse.emf.common.util.URI.createURI(inputModel.toString());
    EmfModelResourceFactory.getInstance().removeCachedResource(file);

    File modelFile = new File(inputModel);
    EmfModel emfModel = EmfModelFactory.getInstance().loadEmfModel("name", modelFile, getMetaModel());
    factory.getContext().getModelRepository().addModel(emfModel);

     EglTemplate template = factory.load(myEGLTemplateURI);
     if (template.getParseProblems().size() > 0)
     {
        return template.getParseProblems();
     }

     template.process();


I left my workaround (disabling) for the Iterable/Iterate bug (see bug #379561) as it is kind of lengthy. It changes the ExecutorFactory/PointExecutor, so it should not influence this problem.

[Updated on: Thu, 24 May 2012 09:48]

Report message to a moderator

Previous Topic:Weird problem/observation with Sequence remove()
Next Topic:Does EuGENia support EMF generics?
Goto Forum:
  


Current Time: Thu Dec 18 21:13:38 GMT 2014

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

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