Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Loading class from extension point
Loading class from extension point [message #1107507] Thu, 12 September 2013 10:02 Go to next message
Setya Mising name is currently offline Setya Mising name
Messages: 486
Registered: July 2009
Senior Member
Hi all,

We have an extension point which specifies class name as one of its attribute. We need to obtain the class instance from the provided class name String.

So far we only find IConfigurationElement#createExecutableExtension, but this one creates object instance instead of class instance. Actually we need something like Bundle#loadClass, but how to get reference to Bundle from IExtensionRegistry ?

Any help would be greatly appreciated.

Thanks & Regards,

Setya
Re: Loading class from extension point [message #1107968 is a reply to message #1107507] Fri, 13 September 2013 02:22 Go to previous messageGo to next message
Setya Mising name is currently offline Setya Mising name
Messages: 486
Registered: July 2009
Senior Member
Hi all,

I've found the following works:

Bundle bundle = OSGIUtils.getDefault().getBundle(element.getContributor().getName());
Class<?> clazz = bundle.loadClass(className);


But the thing is OSGIUtils is internal, so I'm open for any suggestions.


Thanks & Regards,

Setya
Re: Loading class from extension point [message #1108246 is a reply to message #1107968] Fri, 13 September 2013 11:04 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas Watson
Messages: 419
Registered: July 2009
Senior Member
Use Platform.getBundle instead:

http://help.eclipse.org/kepler/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/Platform.html#getBundle(java.lang.String)

HTH

Tom.
Re: Loading class from extension point [message #1108283 is a reply to message #1108246] Fri, 13 September 2013 12:19 Go to previous message
Setya Mising name is currently offline Setya Mising name
Messages: 486
Registered: July 2009
Senior Member
Hi Tom,

It works like a charm.

Thanks a lot for your help.


Regards,

Setya
Previous Topic:ServiceTracker and DS combined?
Next Topic:[p2] List IUs of installation plan
Goto Forum:
  


Current Time: Wed Jul 23 04:08:04 EDT 2014

Powered by FUDForum. Page generated in 0.01555 seconds