• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Load Serialized Plugins?

 
Jeronimo Backes
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application must work with plugins, where the main project is formed by a set of plugins whose implementation I don't know, they just implement a Interface called Plugin (original, huh?)

Every plugin has these two methods:

public void savePlugin(File f); wich is responsible for saving it in a file that my project specified.

AND

public PluginLoader getPluginLoader(); wich returns a Abstract class with the single method open(File f);


Then, when I save my project, I do that:



It saves myProject as expected, and every instance of Plugin used by it.


Now the problem arises:

Imagine that I have a plugin called Foo. Foo has its own implementation of a class FooLoader extending PluginLoader and implementing the method open(File f). That class is returned by getPluginLoader() and it knows how to load a saved file containing a Foo instance.

So, when I try to load a saved project, i do that:



And I got a ClassNotFoundException. I know it is because the jvm can't find the class FooLoader inside the jar that contains the plugin Foo. The Foo plugin is loaded by getting the main class inside the jar that contains it.

What can I do to deserialize FooLoader?
 
Jeronimo Backes
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's it:



Now, I can save my project with:



And that's the end of two days of pain!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic