Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 97238 - IAdapterManager.getAdapter() can't skip plug-ins that aren't loaded
Summary: IAdapterManager.getAdapter() can't skip plug-ins that aren't loaded
Status: RESOLVED DUPLICATE of bug 82973
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-30 09:13 EDT by Jean-Michel Lemieux CLA
Modified: 2005-05-31 16:35 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Michel Lemieux CLA 2005-05-30 09:13:06 EDT
3.1 RC1

I create a new plug-in without a bundle activator, then added a view that used
the Workbench's content and label providers. The applications model elements
extend PlatformObject thus inherits the getAdapter() method that looks via the
IAdapterManager for adapters. I added a couple of IWorkbenchAdapters to the
runtime.adapters extension point. When the application is run and getAdapter()
is called on the model elements the IAdapterManager returns that there are no
adapters registered. I looked into this and found that the following line was
causing the trouble:

AdapterFactoryProxy::loadFactory
String bundleId = element.getNamespace();
if (!force && Platform.getBundle(bundleId).getState() != Bundle.ACTIVE)
  return null;

This means that the adapter factory won't be visible until the plug-in that
defines it is loaded. This is probably the only place in the Platform were a
plug-in with an extension is not loaded when it's extension is needed. The
reason this isn't a problem for most is that if you define a bundle activator
PDE adds the EclipseAutoStart directory to the manifest, thus ensuring that the
plug-in is started.

I'm not sure what the solution should be but here are some general observations:

1. PlatformObject calls IAdapterManager.getAdapter() which won't lazily load. A
Workaround is to not extend PlatformObject and instead implement my own
getAdapter() using IAdapterManager.loadAdapter() instead. This forces plug-in
activation.

2. But this begs the question, shouldn't PlatformObject just call loadAdapter()
and force the callers to decide if they don't want to load plug-ins? I get that
in most cases you *want* to load the adapter factory, and the only cases where
you don't (e.g. in the Workbench contribution code) it is calling
IAdapterManager.getAdapter() explicitly anyway.
Comment 1 John Arthorne CLA 2005-05-31 16:35:42 EDT

*** This bug has been marked as a duplicate of 82973 ***