| [news.eclipse.tools.emf] Re: Stateful vs Singleton |
Conor,
They're cached
It's called each time the descriptors are needed, but the value is cached in itemPropertyDescriptors and the code is guarded to test for null. So setting itemPropertyDescriptors to null before calling super will force it to be recomputed.Hi Ed,
Thanks for your help. How do I flush the cache? I tried changing the getPropertyDescriptors() method in my XXXItemProvider class to clear the itemProvider list but this method is still only called once when the Item Provider pattern is Singleton.
Many thanks, Conor
Ed Merks wrote:Conor,
Comments below.
Conor O'Mahony wrote:Instead of caching it, you could recompute it each time it's called.Hi,
I was looking for a way to filter the properties of my emf objects in the properties view, depending on certain conditions of the object being shown. By editing the getPropertyDescriptors() method in the xxxItemProvider class I was able to select which properties descriptors I wanted to add, but this method was only being called once per type.I figured by changing the Provider Type to Stateful instead of Singleton it would solve this problem and it did. The EMF book says that this "doubles the number of objects in the application" therefore presumably impacting performance, so my questions are -Yes, just don't cache the descriptors. Or flush the cache every thing the argument object is different from the last time.
1. Should I avoid doing this and if so is there an alternative solution?2. If I stick to this solution are there any other repercussions I should be aware of, will it change how my application currently works in any way?Not really no. Just more adapters...
I am using Eclipse 3.3 (planning to move to 3.4) EMF 2.3
Many thanks for your help, Conor