|Re: AdapterManager with multiple adapters for the same adapter type [message #539591 is a reply to message #539419]
||Fri, 11 June 2010 13:13
| Paul Webster
Registered: July 2009
Greg Babcock wrote:|
> Thanks for your reply confirming what I was experiencing.
> I think this is a major flaw in the platform adapter manager design which
> makes it useless for me because it enables a situation where one pluging can
> break another plugin. Hopefully E4 with dependency injection will provide a
> better (safer) solution.
I think it'll just be the same. The e4 solution will still be based on
the standard eclipse pattern:
1) instanceof TargetType -> return obj
2) instanceof IAdaptable -> return ((IAdaptable)obj).getAdapter(TargetType)
3) return adapterManager.getAdapter(TargetType)
(the core expression pattern is light #1 followed by #3)
If the object implements IAdaptable, it gets to decide the priority of
solutions (as it were).
But in an open-ended contribution based system, one entry can always
clobber another. There isn't a general solution, although different
ones are used in parts of Eclipse based on complexity vs predictability.
By default, Extensions are return from the IExtensionRegistry in a
non-determanistic order. Kind of a "let the system decide" option.
This is not generally a good option.
Different Example: actions tend to sort contributions by plugin id.
Then first one in wins. good: predictability. bad: priority based on
bundle ID collation :-)
Different Example: a comparator extension was recently added, to allow
the product to decide how to sort the preference nodes in the
preferences dialog tray. Delegating to the product provides it with
control ... and significant complexity.
In general, the product can exclude plugins that clobber important stuff
.... except that doesn't always work, as the plugins (like JDT) probably
need to work in Eclipse and work in a product, and if you need JDT in
your product you're stuck with it.
I'm not sure how the adapter manager decides which factory is the winner
for MyType -> TargetType, but it obviously picks one.
Powered by FUDForum
. Page generated in 0.01726 seconds