• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Load Serialized Plugins?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic