Skip to main content



      Home
Home » Newcomers » Newcomers » Loading classes provided by plugins
Loading classes provided by plugins [message #165426] Sat, 12 August 2006 09:58 Go to next message
Eclipse UserFriend
Originally posted by: jochen.wuttke.gmx.de.invalid

Hi,

I have the following problem:

I have a plugin that defines an extension point. The extension point basically
gives me the name of the class that implements the extension.
At runtime I obviously would like to instantiate those classes. But how do I
do this?

Using the default system classloader does not find the class.
Using IConfigurationElement.createExecutableExtension() does not find the
class (and I'm not sure if that would be the right way anyway).

So how do I get the class to load? Do I need to specify an additional
classpath somewhere?

Thanks for any help
Jochen
Re: Loading classes provided by plugins [message #165462 is a reply to message #165426] Sun, 13 August 2006 06:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jochen.wuttke.gmx.de.invalid

To make this more precise and rephrase the question:
The idea behind the extension point in my plugin is to basically use the
"Template Method" pattern to perform the actual work. So all I want is to get
actual implementations for an abstract interface from those plugins attaching
to the extension point.

From a lot of searching through google I get the impression that it is not
possible to directly load a class provided by an extending plugin.
Does anybody have tips how else I can do what I need?

Thanks


Jochen wrote:
> Hi,
>
> I have the following problem:
>
> I have a plugin that defines an extension point. The extension point
basically
> gives me the name of the class that implements the extension.
> At runtime I obviously would like to instantiate those classes. But how do I
> do this?
>
> Using the default system classloader does not find the class.
> Using IConfigurationElement.createExecutableExtension() does not find the
> class (and I'm not sure if that would be the right way anyway).
>
> So how do I get the class to load? Do I need to specify an additional
> classpath somewhere?
>
> Thanks for any help
> Jochen
Re: Loading classes provided by plugins [message #165598 is a reply to message #165462] Mon, 14 August 2006 14:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Jochen" <jochen.wuttke@gmx.de.invalid> wrote in message
news:PM00041AE3DE75F205@84-74-35-113.dclient.hispeed.ch...
> To make this more precise and rephrase the question:
> The idea behind the extension point in my plugin is to basically use the
> "Template Method" pattern to perform the actual work. So all I want is to
> get
> actual implementations for an abstract interface from those plugins
> attaching
> to the extension point.
>
> From a lot of searching through google I get the impression that it is not
> possible to directly load a class provided by an extending plugin.
> Does anybody have tips how else I can do what I need?

The general pattern is this:

Plug-in A exposes an extension point "foo", and also exports a public
interface or class declaration "IFoo".
Plug-in B declares in its plugin.xml that it depends on plug-in A and that
it extends "foo", and gives the name of a class "Foo" that implements IFoo.
Plug-in A's code uses the plug-in registry to find extensions of "foo".
For each one, it calls createExecutableExtension, which in the case of
plug-in B, causes Foo to be loaded from B.
Plug-in A now can access the instance of Foo that was loaded from B, but
only as an IFoo; it has no way to cast it to Foo, since the Foo class is not
visible to A's classloader
Re: Loading classes provided by plugins [message #165768 is a reply to message #165598] Tue, 15 August 2006 05:16 Go to previous message
Eclipse UserFriend
Originally posted by: jochen.wuttke.gmx.de.invalid

Walter Harley wrote:
> "Jochen" <jochen.wuttke@gmx.de.invalid> wrote in message
> news:PM00041AE3DE75F205@84-74-35-113.dclient.hispeed.ch...
>> To make this more precise and rephrase the question:
>> The idea behind the extension point in my plugin is to basically use the
>> "Template Method" pattern to perform the actual work. So all I want is to
>> get
>> actual implementations for an abstract interface from those plugins
>> attaching
>> to the extension point.
>>
>> From a lot of searching through google I get the impression that it is not
>> possible to directly load a class provided by an extending plugin.
>> Does anybody have tips how else I can do what I need?
>
> The general pattern is this:
>
> Plug-in A exposes an extension point "foo", and also exports a public
> interface or class declaration "IFoo".
> Plug-in B declares in its plugin.xml that it depends on plug-in A and that
> it extends "foo", and gives the name of a class "Foo" that implements IFoo.
> Plug-in A's code uses the plug-in registry to find extensions of "foo".
> For each one, it calls createExecutableExtension, which in the case of
> plug-in B, causes Foo to be loaded from B.
> Plug-in A now can access the instance of Foo that was loaded from B, but
> only as an IFoo; it has no way to cast it to Foo, since the Foo class is not
> visible to A's classloader

Thanks, got it to work now.
Previous Topic:Is this newsgroup supposed to look flat in a newsreader?
Next Topic:DirectShow support?
Goto Forum:
  


Current Time: Mon Nov 10 06:34:02 EST 2025

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

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

Back to the top