This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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?
The art of being crazy is to NEVER commit the crazyness of being normal.