Skip to main content


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 14:02 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
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 06:22 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
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 15:04 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
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 16:19 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
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: Tue Mar 19 09:14:29 GMT 2024

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

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

Back to the top