Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Extension Point and Class Loading Error
Extension Point and Class Loading Error [message #522121] Sat, 20 March 2010 04:19 Go to next message
Eclipse User
Originally posted by: eclipse-nospam-gaurav-vaish.gmail.com

Hi,

I have created an extension point that allows an extension to specify a
class that this plugin will load. Let's call them BasePlugin (that defines
the extension point), UsePlugin (that defines the extension).

Usage is something like:

<extension point="my.point.name">
<item class="fully.qualified.name.of.ClassName" />
</extension>


In BasePlugin, I am able to get the class name (using IExtensionRegistry)
but results in ClassNotFoundException during
getClass().getClassLoader.loadClass(...).


Is there a resolution other than using
Eclipse-BuddyPolicy: registered
and
Eclipse-RegisterBuddy: id.of.base.extension


Because, say, while working with org.eclipse.ui plugin, I don't need to do
anything like that... then why for custom plugins?




Sorry for cross posting.
Thanks in advance.


--
Happy Hacking,
Gaurav Vaish
www.mastergaurav.com
Re: Extension Point and Class Loading Error [message #522135 is a reply to message #522121] Sat, 20 March 2010 02:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25910
Registered: July 2009
Senior Member
Gaurav,

Given you have "element", an IConfigurationElement, you could use this
approach to consult the class loader of the extender

Class<?> javaClass =
Platform.getBundle(element.getDeclaringExtension().getContri butor().getName()).loadClass(element.getAttribute(attributeN ame));


Gaurav Vaish wrote:
> Hi,
>
> I have created an extension point that allows an extension to specify a
> class that this plugin will load. Let's call them BasePlugin (that defines
> the extension point), UsePlugin (that defines the extension).
>
> Usage is something like:
>
> <extension point="my.point.name">
> <item class="fully.qualified.name.of.ClassName" />
> </extension>
>
>
> In BasePlugin, I am able to get the class name (using IExtensionRegistry)
> but results in ClassNotFoundException during
> getClass().getClassLoader.loadClass(...).
>
>
> Is there a resolution other than using
> Eclipse-BuddyPolicy: registered
> and
> Eclipse-RegisterBuddy: id.of.base.extension
>
>
> Because, say, while working with org.eclipse.ui plugin, I don't need to do
> anything like that... then why for custom plugins?
>
>
>
>
> Sorry for cross posting.
> Thanks in advance.
>
>
> --
> Happy Hacking,
> Gaurav Vaish
> www.mastergaurav.com
>
>
>
Re: Extension Point and Class Loading Error [message #522196 is a reply to message #522135] Sat, 20 March 2010 11:54 Go to previous messageGo to next message
Eclipse User
Originally posted by: eclipse-nospam-gaurav-vaish.gmail.com

Hey Ed!

Fantastic!

That works.


Happy Hacking,
Gaurav Vaish
www.mastergaurav.com
--------------------



"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:ho29cd$jkt$1@build.eclipse.org...
> Gaurav,
>
> Given you have "element", an IConfigurationElement, you could use this
> approach to consult the class loader of the extender
>
> Class<?> javaClass =
> Platform.getBundle(element.getDeclaringExtension().getContri butor().getName()).loadClass(element.getAttribute(attributeN ame));
>
>
> Gaurav Vaish wrote:
>> Hi,
>>
>> I have created an extension point that allows an extension to specify a
>> class that this plugin will load. Let's call them BasePlugin (that
>> defines the extension point), UsePlugin (that defines the extension).
>>
>> Usage is something like:
>>
>> <extension point="my.point.name">
>> <item class="fully.qualified.name.of.ClassName" />
>> </extension>
>>
>>
>> In BasePlugin, I am able to get the class name (using IExtensionRegistry)
>> but results in ClassNotFoundException during
>> getClass().getClassLoader.loadClass(...).
>>
>>
>> Is there a resolution other than using
>> Eclipse-BuddyPolicy: registered
>> and
>> Eclipse-RegisterBuddy: id.of.base.extension
>>
>>
>> Because, say, while working with org.eclipse.ui plugin, I don't need to
>> do anything like that... then why for custom plugins?
>>
>>
>>
>>
>> Sorry for cross posting.
>> Thanks in advance.
>>
>>
>> --
>> Happy Hacking,
>> Gaurav Vaish
>> www.mastergaurav.com
>>
>>
Re: Extension Point and Class Loading Error [message #522359 is a reply to message #522196] Mon, 22 March 2010 09:42 Go to previous message
Eclipse User
Originally posted by: richkulp.us.NOSPAM.ibm.com

Hi,

Actually IConfigurationElement provides a direct method to do this

See:

IConfigurationElement.createExecutableExtension(String propertyName)

It does all of the bundle stuff for you. It actually returns an instance
of the class, not the class itself. But that is what the extension point
system was designed for.

--
Thanks,
Rich Kulp
Previous Topic:ACTION_ARRANGE_ALL: how to execute it from custom Action?
Next Topic:How to install and use SwingX
Goto Forum:
  


Current Time: Tue Jul 22 23:53:08 EDT 2014

Powered by FUDForum. Page generated in 0.03298 seconds