my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes How to Load Serialized Plugins? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to Load Serialized Plugins?" Watch "How to Load Serialized Plugins?" New topic
Author

How to Load Serialized Plugins?

Jeronimo Backes
Greenhorn

Joined: Sep 20, 2004
Posts: 29
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?


The art of being crazy is to NEVER commit the crazyness of being normal.
Jeronimo Backes
Greenhorn

Joined: Sep 20, 2004
Posts: 29
That's it:



Now, I can save my project with:



And that's the end of two days of pain!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Load Serialized Plugins?
 
Similar Threads
yet another question regarding creating a runnable jar with Eclipse/Maven
Trying to build with maven => package my.external.package does not exist
How to access server configuration information from JAX-WS web service implementation?
Where to run the saved ant script of Deployable plug-ins and fragments
Casting Around In Generics