Extension Point and Class Loading Error [message #522121] |
Sat, 20 March 2010 08:19 |
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 06:06 |
Ed Merks Messages: 33188 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
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Extension Point and Class Loading Error [message #522196 is a reply to message #522135] |
Sat, 20 March 2010 15:54 |
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 13:42 |
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
|
|
|
Powered by
FUDForum. Page generated in 0.02724 seconds