Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » loading a plugin dynamically
loading a plugin dynamically [message #157247] Tue, 04 May 2004 20:40 Go to next message
Neil Goldsmith is currently offline Neil GoldsmithFriend
Messages: 68
Registered: July 2009
Member
Within our application, we have a basic core class called treeItem that
lives in our core plugin that any plugin can extend. Another plugin might
come along and extend it to become something trivial like
specializedTreeItem. When you save this, the code that lives in our core
plugin will save all the treeitems to an XML File (giving each derived
treeItem a chance to write its own custom XML data as well).

When we load back this XML file, the core plugin won't understand how to
load derived tree items, so it must defer to the plugin that created it.
However, the core plugin has no reference to these other plugins because
it's wide open who can come along and derive a new tree item, the core
doesn't care and shouldn't care.

When we pull the XML data out of the file, we do something like:
Class itemClass = Class.forName(className);
object = itemClass.newInstance();

Using the className found in the XML data. Considering the className may
be in a different plugin, this will fail if the class isn't found in the
core. It looks like we will also need to keep track of the plugin within
the XML data, but with that info, how do we code the core to load the
other plugin and instantiate the class so that we can tell it to load its
XML data?

thanks
Re: loading a plugin dynamically [message #157289 is a reply to message #157247] Wed, 05 May 2004 09:11 Go to previous message
Eclipse UserFriend
Originally posted by: thomas_maeder.ch.ibm.com

You'll have to define an extension point in your core plugin. I would
allow the "derived" plugins to register factories for certain class
names. For example, each factory extension would have a "class"
attribute giving the class of items it's responsible for creating. Once
you have located the proper factory extension for a treeItem class, you
can instantiate it (see
IConfigurationElement.createExecutableExtension()) and use it to create
your tree items.

Thomas

N. G. wrote:
> Within our application, we have a basic core class called treeItem that
> lives in our core plugin that any plugin can extend. Another plugin might
> come along and extend it to become something trivial like
> specializedTreeItem. When you save this, the code that lives in our core
> plugin will save all the treeitems to an XML File (giving each derived
> treeItem a chance to write its own custom XML data as well).
>
> When we load back this XML file, the core plugin won't understand how to
> load derived tree items, so it must defer to the plugin that created it.
> However, the core plugin has no reference to these other plugins because
> it's wide open who can come along and derive a new tree item, the core
> doesn't care and shouldn't care.
>
> When we pull the XML data out of the file, we do something like:
> Class itemClass = Class.forName(className);
> object = itemClass.newInstance();
>
> Using the className found in the XML data. Considering the className may
> be in a different plugin, this will fail if the class isn't found in the
> core. It looks like we will also need to keep track of the plugin within
> the XML data, but with that info, how do we code the core to load the
> other plugin and instantiate the class so that we can tell it to load its
> XML data?
>
> thanks
>
Previous Topic:JUnit not working in 3M7
Next Topic:Java Source Attachment
Goto Forum:
  


Current Time: Mon Dec 30 17:05:33 GMT 2024

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

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

Back to the top