Community
Participate
Working Groups
From bug 197178. To ensure that client's content and label adapters are loaded, the platform should force load the adapters we are looking for (IElementContentProvider, IElementLabelProvider, etc), before calling #getAdapter(...). To be efficient, a viewer should keep track of which adapters it has loaded for which classes, to avoid having to call loadAdapter each time an adapter is required.
From bug 197179 comment 18: What do you think about that other strategy to move the burden of calling loadAdapter() to the actual model objects? - the model objects must be adaptable anyways, and inside their getAdapter() method they usually do Platform.getAdapterManage().getAdapter(). What if that were replaced by loadAdapter() in all the model objects? It just needs to be documented that all extenders are responsible for loading their adapters themselves. Which is exactly the case right now -- extenders are responsible for activating, and they do so in early startup or plugin activator. It would just be recommended that this should be done in the actual model objects. IAdapterManager.loadAdapter() is not more expensive than getAdapter(), so Performance would remain the same. The only potential issue I can see is that other plugins might ask for other adapters (e.g. Property Pages, etc.) -- replacing getAdapter() by loadAdapter() would mean that such adapter factories would always get loaded. But that might actually be desired. Thoughts? > "loadAdapter(...)" on. I think this cache would be relatively small. You mean something like that - note that the cache needs to be indexed by the combination of adaptable class and adapter type: Class clazz = element.getClass(); Set classesAdapted = adapterLoadSet.get(clazz); if (classesAdapted == null) { classesAdapted = new HashSet(); adapterLoadSet.add(classesAdapted); } if (!classesAdapted.contains(adapterType)) { classesAdapted.add(adapterType); Platform.getAdapterManager.loadAdapter(element, adapterType); } Object o = element.getAdapter(adapterType);
I think there's a problem with putting the burden on IAdaptables. If a class simply subclasses PlatformObject, it does not have to override #getAdapter(...) - so we cannot enforce clients to force load adapters.
Darin, the AdapterFactoryProxy class is responsible for loading adapters. Currently it doesn't load an adapter if its bundle is not active. Isn't it better to add an option (something like load always/load only when the bundle is active) to the extension point?
I agree an option on the extension point would be a good solution. The extension point is owned by the runtime. CC'ing Pascal for comment: Would it be possible to have contributed adapters declare whether they should be agressively loaded when requested?
(In reply to comment #4) > I agree an option on the extension point would be a good solution. I filed bug 199057 to track the addition of a "forceLoad=<true|false>" tag to the org.eclipse.core.runtime.adapters extension point, for the general case; since I think the contributor of an adapter is the expert to know when it should be activated, and by such a markup it's easiest for the contributor to implement it. For the concrete case of Platform/Debug, when I'm reading through the comments in this bug my feeling is that no modification of current functionality may be needed. It looks like every extender of Platform/Debug-UI gets activated by some other means as part of Launching -- either by registering a Console handler, or by a custom Launch, or by custom debug model. So it may be sufficient for Platform/Debug to document, that contributors of debug adapter factories are responsible themselves for getting their extension activated (somehow). But I do not know the details of Platform/Debug code, and a mechanism in Platform/Debug that force loads adapters the first time they are used might make sense. I'm not sure, though, how Platform Activities/Capabilities intermix with such a feature, because the plugin which contributes the adapter might be disabled at a given time.
For now I will mark this bug as depending on bug 199057. A feature in the adapter extension would likely be the best solution. We don't intend to change this in 3.3.x - and as far as we know, all debuggers are getting their plug-ins loaded before they are displayed in the viewers (so things are working).
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.