Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Java Reflection Classloading Extensionpoint Defined Classes
Java Reflection Classloading Extensionpoint Defined Classes [message #334302] Mon, 02 February 2009 16:25 Go to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello,

I've an extensionpoint that at one point need an classpath and name.
Later, on extensionpoint processing, this classname is used to create an
instance of this class using Java reflections.

Everything is fine as long I'm only using classes that are defined in the
extensionpoint defining plugin or a plugin that is known by it.

When ever I'm adding classes from else where the Classloader does not know
the class. Its quite obviouse why. If I could use the bundle classloader
of the plugin consuming to the extensionpoint I'll would probaly be done.

But unfortunately IExtensionPoint.getDeclaringPluginDescriptor() is
deprecated :(
So my question is, how can I use the bundle classloader, or how else could
my problem be solved?

Thanks!
Re: Java Reflection Classloading Extensionpoint Defined Classes [message #334322 is a reply to message #334302] Tue, 03 February 2009 09:51 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello again,

its somehow so simple that it was quite imposssible to get it at the first
sight ... :)
When processing the extensionpoint at some point you get an
IConfigurationElement element. Frome here you can get the contributors
name and with this its easy to get the Bundle. With the Bundle you can
load any class that is in the bundle classpath:

String controllerClassName = element.getAttribute("InputController");
String name = element.getContributor().getName();
bundle = Platform.getBundle(name);
Class<InputController> controllerClass =
(Class<InputController>)bundle.loadClass(controllerClassName);

Jan
Re: Java Reflection Classloading Extensionpoint Defined Classes [message #334334 is a reply to message #334322] Tue, 03 February 2009 18:59 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

And you cannot use element.createExecutableExtension("InputController")?
That's what it is designed for.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Java Reflection Classloading Extensionpoint Defined Classes [message #334343 is a reply to message #334334] Wed, 04 February 2009 08:23 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Paul,

InputController is a Control. Therefor it needs be get instantiated on
creationtime of an part/editor/dialog. Also it needs constructors like a
parent Composite and a style.

Paul Webster wrote:

> And you cannot use element.createExecutableExtension("InputController")?
> That's what it is designed for.

> PW
Re: Java Reflection Classloading Extensionpoint Defined Classes [message #334355 is a reply to message #334343] Wed, 04 February 2009 14:48 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

Maybe you should change the extension point to be for a factory class
for the InputController instead. The factory could use the default ctor
to be constructed and then call a method on the factory with parent and
style to create the InputController.

That way you won't be digging into weird places to do what
createExecutableExtension is supposed to do anyway.

Jan Kohnert wrote:
> Paul,
>
> InputController is a Control. Therefor it needs be get instantiated on
> creationtime of an part/editor/dialog. Also it needs constructors like a
> parent Composite and a style.
>
> Paul Webster wrote:
>
>> And you cannot use
>> element.createExecutableExtension("InputController")? That's what it
>> is designed for.
>
>> PW
>
>
>
>

--
Thanks,
Rich Kulp
Previous Topic:Original Tasks View missing in 3.4 with Mylyn
Next Topic:Overriding IExtensionRegistry / IExtensionPoint / IExtension
Goto Forum:
  


Current Time: Fri Aug 16 23:14:41 GMT 2024

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

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

Back to the top