Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] Refresh resources
[Texo] Refresh resources [message #1015006] Wed, 27 February 2013 02:54 Go to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi Martin,

I was wondering, if there is a possibility to force a refresh of a TexoResource ignoring the cache. For example: I open the editor, somebody else changes values in the database, I restart the editor, but the changed values are not shown. Can I force to reload the data without a cache? I thought maybe texoResource.getEObjectStore().clearCache() could do this, but it doesn't.

Best regards
Bastian
Re: [Texo] Refresh resources [message #1015031 is a reply to message #1015006] Wed, 27 February 2013 04:11 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5329
Registered: July 2009
Senior Member
Hi Bastian,
The EObjectStore has a refresh method to refresh individual objects. Would that work for you (I can expose this method
int the TexoResource api directly)?

gr. Martin

On 02/27/2013 08:54 AM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> I was wondering, if there is a possibility to force a refresh of a TexoResource ignoring the cache. For example: I open
> the editor, somebody else changes values in the database, I restart the editor, but the changed values are not shown.
> Can I force to reload the data without a cache? I thought maybe texoResource.getEObjectStore().clearCache() could do
> this, but it doesn't.
>
> Best regards Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Refresh resources [message #1015060 is a reply to message #1015031] Wed, 27 February 2013 05:36 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi Martin,

that doesn't have the effect I'm searching for. My problem is:
- I start the editor --> it loads the resources via Texo
- Somebody changes the data in the database (not in the editor)
- I close the editor.
- I restart the editor. And it loads the resources from the cache (which is good in most cases, because it accelerates the start). So the editor shows the same objects it did the last time.

I also tried resource.getEObjectStore().refresh(object) and resource.refresh(object) for all objects or only the selected one, but this doesn't make a difference. If I'd call the EntityManager on the server or restart the server, the resources are up to date (of course Smile ). Could I force this behaviour manually?

Best regards
Bastian
Re: [Texo] Refresh resources [message #1015064 is a reply to message #1015060] Wed, 27 February 2013 05:50 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5329
Registered: July 2009
Senior Member
Hi Bastian,
So the refresh does not work? (I think I have a testcase for it)
Or the refresh method does not do what you want? (I am open/interested in a different solution btw, with some polling
mechanism or so).
Or you can opt for starting with a new resource when an editor starts. This is more similar to how web apps work (to
limit the data in the browser and load frequently from the server).

gr. Martin

On 02/27/2013 11:36 AM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> that doesn't have the effect I'm searching for. My problem is: - I start the editor --> it loads the resources via Texo
> - Somebody changes the data in the database (not in the editor)
> - I close the editor.
> - I restart the editor. And it loads the resources from the cache (which is good in most cases, because it accelerates
> the start). So the editor shows the same objects it did the last time.
>
> I also tried resource.getEObjectStore().refresh(object) and resource.refresh(object) for all objects or only the
> selected one, but this doesn't make a difference. If I'd call the EntityManager on the server or restart the server, the
> resources are up to date (of course :) ). Could I force this behaviour manually?
>
> Best regards
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Refresh resources [message #1015070 is a reply to message #1015064] Wed, 27 February 2013 06:08 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi Martin,

How is the refresh method supposed to work? Should it ask the EntityManager, if there are changes on the object, or should it ask the EntityManager to ask the database (without using cached objects)? If I just refresh an object, changes in the database are not shown. Notice, that the changes n the objects aren't done via the EntityManager from the servlet.

Bastian
Re: [Texo] Refresh resources [message #1015077 is a reply to message #1015070] Wed, 27 February 2013 06:38 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5329
Registered: July 2009
Senior Member
Hi Bastian,
The refresh should read the state from the database, the entitymanager in the servlet should not be re-used/cache data
between different requests. So a refresh request to the server should use a new entitymanager without caching. On the
server there should not be caching.

Could be a bug in Texo?

On the client there are 2 caches: the resource itself maintains a list of eobjects, the eobjectstore has a cache (also
to resolve references in the correct way).

In any case, not sure how practical it is to refresh all objects explicitly... Seems that a different
(to-be-implemented) approach can make more sense. Or can you close the resource when closing the editor?

gr. Martin

On 02/27/2013 12:08 PM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> How is the refresh method supposed to work? Should it ask the EntityManager, if there are changes on the object, or
> should it ask the EntityManager to ask the database (without using cached objects)? If I just refresh an object, changes
> in the database are not shown. Notice, that the changes n the objects aren't done via the EntityManager from the servlet.
>
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Refresh resources [message #1015299 is a reply to message #1015077] Thu, 28 February 2013 01:55 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi Martin,

what do you mean with close the resource? The JSONTexoResource?
Refreshing each object isn't a very good solution, indeed Smile Most of all, because it doesn't work either. I also tried it very basically by calling the servlet in a browser. If I call http://localhost:8080/texo/jsonws/User or http://localhost:8080/texo/jsonws/User/1 after I changed the user name in the database, returns the old user. Restarting the servlet then works.
I use the latest Texo version with Eclipse 2.4.1.

Best regards
Bastian
Re: [Texo] Refresh resources [message #1015300 is a reply to message #1015299] Thu, 28 February 2013 01:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5329
Registered: July 2009
Senior Member
Okay this is indeed a bug. Can you enter a bugzilla?

Then even if refresh works, is it a good solution...? My idea with Texo is to follow a more web-like-pattern where data
is reloaded frequently in the browser and any 'dirty' objects are only detected when committing changes (optimistic
locking).

gr. MArtin

On 02/28/2013 07:55 AM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> what do you mean with close the resource? The JSONTexoResource?
> Refreshing each object isn't a very good solution, indeed :) Most of all, because it doesn't work either. I also tried
> it very basically by calling the servlet in a browser. If I call http://localhost:8080/texo/jsonws/User or
> http://localhost:8080/texo/jsonws/User/1 after I changed the user name in the database, returns the old user. Restarting
> the servlet then works.
> I use the latest Texo version with Eclipse 2.4.1.
>
> Best regards
> Bastian


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo] Refresh resources [message #1015303 is a reply to message #1015300] Thu, 28 February 2013 02:20 Go to previous message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi,

Opened it here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=401968.
At some points the resources should be up-to-date. Therefore it is useful to refresh them. But most of the time this optimistic approach is better.

Thanks for your help (think I'll have to invite you to a beer sometimes Smile)
Bastian
Previous Topic:[TEXO] javax.persistence.Temporal annotation is duplicated on generated source code
Next Topic:[Texo] HTML web interface projects?
Goto Forum:
  


Current Time: Sat Aug 23 15:19:54 EDT 2014

Powered by FUDForum. Page generated in 0.02166 seconds