| Loading classes provided by plugins [message #165426] |
Sat, 12 August 2006 09:58  |
Eclipse User |
|
|
|
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 #165768 is a reply to message #165598] |
Tue, 15 August 2006 05:16  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.13273 seconds