[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Plugin that implements its own interface, how can other plugins use this?

My example always goes back to a simple plugin like a MenuBar. If I wrote a
plugin that provides and interface AND implements it, so that other plugins
can use my plugins implementation, how would other plugins "depend" upon
mine and make calls to it? Normally, a plugin provides an extension point
via an interface. Other plugins implement that interface and the main plugin
calls into that interface to use the "unknown" implementation of plugins
implementing the interface. This is quite the reverse. What if I don't want
other plugins to implement my interface. I just want to provide a sort of
"service" that other plugins can use. Another example might be a "global
repository of data", where by my plugin provides an interface with
getAttribute(), setAttribute(), removeAttribute(). My plugin would then
implement this interface. Other plugins would use the interface (getting a
ref to my implemented plugin of the interface), so that they could all
"share" data using the interface calls since they all would get the same one
implementation ref to my plugin.

Given the above scenario, how would this be done in Eclipse? Obviously
plugins using my implementation would have to depend on my plugin, but how
does the engine pass the ref of my plugin implementation to the plugins
depending on me? Does each plugin have to "request" my plugins
implementation? I'd imagine something like:

public interface MyInterface
{
  public Object getAttribute(Object key);
  public void setAttribute(Object key, Object value);
  public boolean removeAttribute(Object key);
}

public class MyPlugin implements MyInterface
{
  // implementation of MyInterface
  ....
}

Plugin 1 (plugin.xml has dependency info to my plugin?? Does eclipse engine
handle this case automatically?)

public class SomePlugin
{
  MyInterface iface = null;

  public someMethodCalledByEclipseEngine()
  {
    iface = (MyInterface)eclipseEngine.request("MyInterfaceImpl");
  }
}

So, in the "very" generic example above, this is my most basic guess as to
how it might be done. I can't see how the eclipse engine would be able to
assign my plugin implementation of the interface directly into any plugin
depending on it. So my guess is to assume that any plugin depending on it
needs to ask the engine to find the interface and then assign it. I also
would imagine that in this type of scenario, there is no reason to specify
dependency information if the eclipse engine allows for a "global"
repository of plugins to be accessed by any other plugin. If this is not the
case, then most likely the PluginClassLoader of the dependent plugin will
need as a URL in its dependent path the PluginClassLoader of my plugin
imlementation, so that each dependent plugin classloader is able to locate
my implementation of it.

I would love to hear info on how such a scenario as this works in Eclipse,
if it can handle this automatically, and if so, how? If not, is there a way
this is done and if so, is there actually any case where it is being done in
Eclipse now?

Thank you very much.