Skip to main content



      Home
Home » Newcomers » Newcomers » Invoking plugins, plugin relationships
Invoking plugins, plugin relationships [message #147781] Mon, 10 April 2006 16:29 Go to next message
Eclipse UserFriend
Originally posted by: ecc11718.yahoo.com

Apologies if this isn't the correct place. New to Eclipse development.

Plugin A creates extension point that Plugin B extends. Extension point
Java interface's package is exposed in Runtime of Plugin A's plugin.xml.
Plugin B lists Plugin A in Dependencies of its plugin.xml. Both plugins
are independent of the Eclipse UI framework. Plugin A has defined a
contract of interactions (in the interface) it asks other plugins to
fulfill, in this case, Plugin B.

I believe both plugin.xmls and schema are satisfied. Both projects can
find the other via their respective plugin.xmls. Now I want to invoke
Plugin B, in effect, its implementation class of Plugin A's interface -- I
want to do this inside Plugin A.

Reading Eclipse documentation, "host" (A) plugins invoke "extender" (B)
plugins via the host's interface, the host oblivious to the extender's
implementation. Is that accurate? Obviously, at some point, Plugin A's
classloader would find the implementor class as specified in Plugin B's
plugin.xml, but where does this actually happen in the code? I'd like to
test Plugin B's implementation through a Plugin JUnit (for now, residing
in Plugin A).

Can someone point me to a code snippet or provide one, or direct me to
resources on this topic? I've researched this a bit online and can find no
concrete examples.

Thanks,

-Steven
Re: Invoking plugins, plugin relationships [message #147790 is a reply to message #147781] Mon, 10 April 2006 18:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Steven" <ecc11718@yahoo.com> wrote in message
news:e6507c3989bf7de11f4108e8b6ad9164$1@www.eclipse.org...
> Apologies if this isn't the correct place. New to Eclipse development.

You're in exactly the right place.


> Plugin A creates extension point that Plugin B extends. Extension point
> Java interface's package is exposed in Runtime of Plugin A's plugin.xml.
> Plugin B lists Plugin A in Dependencies of its plugin.xml. Both plugins
> are independent of the Eclipse UI framework. Plugin A has defined a
> contract of interactions (in the interface) it asks other plugins to
> fulfill, in this case, Plugin B.
>
> I believe both plugin.xmls and schema are satisfied. Both projects can
> find the other via their respective plugin.xmls. Now I want to invoke
> Plugin B, in effect, its implementation class of Plugin A's interface -- I
> want to do this inside Plugin A.
>
> Reading Eclipse documentation, "host" (A) plugins invoke "extender" (B)
> plugins via the host's interface, the host oblivious to the extender's
> implementation. Is that accurate? Obviously, at some point, Plugin A's
> classloader would find the implementor class as specified in Plugin B's
> plugin.xml, but where does this actually happen in the code? I'd like to
> test Plugin B's implementation through a Plugin JUnit (for now, residing
> in Plugin A).
>
> Can someone point me to a code snippet or provide one, or direct me to
> resources on this topic? I've researched this a bit online and can find no
> concrete examples.

The part up to where you ask "is that accurate" is accurate :-) Plug-in A,
itself, is not going to be able to see or create any of B's classes. To do
that, A would have to depend on B, which it can't, because B depends on A.

Instead, A is going to ask the platform to create a class from B on A's
behalf. That class will be visible to A only as an instance of the
interface. That is, if the interface is named IFoo, and B contains a class
Foo that implements IFoo, A will only ever see an IFoo (even though under
the covers what it has is a Foo). Foo is not available to A's classloader!

The platform method that you call to do this is
IConfigurationElement.createExecutableExtension(). You get the
IConfigurationElement from a call to IExtension; you get the IExtension from
a call to IExtensionPoint; you get the IExtensionPoint from
Platform.getExtensionRegistry().

For concrete examples, just find a plug-in that exposes an extension point,
and search its source code for createExecutableExtension(). Be aware that
since the plug-in framework is a very old part of the Eclipse code, the APIs
have changed a bit over time, so try to find a relatively new or at least
up-to-date example.

I imagine that this is documented somewhere in the online help. But
personally, I learned about it in the book "Eclipse: Building
Commercial-Quality Plug-ins" (Addison-Wesley; ISBN of the new edition:
032142672X), which I would recommend.

HTH,
-Walter Harley
BEA Systems, Inc.
Re: Invoking plugins, plugin relationships [message #147909 is a reply to message #147790] Tue, 11 April 2006 09:54 Go to previous message
Eclipse UserFriend
Originally posted by: ecc11718.yahoo.com

Thanks for your time, Walter. I appreciate the call stack decomposition
and the book recommendation; I'll be sure and check it out.

-Steven
Previous Topic:templates not work
Next Topic:Refactoring (renaming) a project
Goto Forum:
  


Current Time: Thu May 08 17:14:07 EDT 2025

Powered by FUDForum. Page generated in 0.09822 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top