|
|
|
|
Re: Dynamic Unawareness of an extension point [message #126841 is a reply to message #126408] |
Mon, 02 March 2009 21:32 |
Oleg Besedin Messages: 41 Registered: July 2009 |
Member |
|
|
Hi Siddharth,
I imagine there are two situations possible:
a) you cache extension registry elements for the duration of the session;
b) you cache extension registry elements between running sessions.
The approach would be different depending on either you have (a) or (b). To
see why, let's consider when handles to the registry elements become
invalid.
The registry has its own cache that gets populated by gathering information
from all plugin.xml files included in the configuration. The handles to
registry elements are formed based on that internal cache.
This internal cache is created during the initial run and re-created either
when Eclipse is run with "-clean" option, or when the running instance
detects that cache no longer fits: bundles have been added or removed,
language or some other OS option changed.
Say, you cache registry elements. The elements you get remains valid as long
as either the bundle that contributed those elements remain valid, or until
the "internal" registry cache gets regenerated.
This is where the distinction between (a) and (b) comes in. For the case (a)
as long as the originating bundle is not modified, your cached values remain
valid. The recommended approach in this case would be to create a listener
on the extension point; make the listener discard your cache on any changes;
structure code to re-create your cache lazily when it is asked to provide
information.
For the case (b) things are going to be more complicated. I am not sure it
can be done properly without using internal registry methods to determine if
it is using its internal cache and recreated it from plugin.xml files. Some
situations could be tracked by checking for "-clean" runtime option and its
derivative, but it is possible that registry internal cache would be
re-created for other reasons on startup.
So, the recommended approach:
- Do no cache registry elements between Eclipse runs
- When you cache registry elements for the duration of the session:
- Create a listener on the extension point
- Make the listener invalidate your cache
- If possible, organize the cache to be re-filled lazily
If, as you say, "we have no plans to make our extension points dynamic
aware", when you can just keep the cache for the duration of the running
session and hope the user does not run an update and choose to apply changes
(rather then restart).
Hope this helps.
Sincerely,
Oleg Besedin
"Siddharth " <siddharth.cr@in.ibm.com> wrote in message
news:c3008dbfe9b8172cb17d5d1e7a8fcce1$1@www.eclipse.org...
> Hi Oleg,
>
> Since we have no plans to make our extension points dynamic aware, as a
> work around, can we do something like the following:
>
> Do not hold on to any of the registry elements and extract all the data
> needed from them while reading the registry for the first time.
>
> Is this correct?
>
> Please help.
>
> Thanks,
> Siddharth
>
|
|
|
Powered by
FUDForum. Page generated in 0.08984 seconds