0

I've been asked to create a java system capable of expand itself by plugins, however i'm a little confused in how exactly should i do that, my initial idea was to create a folder in the system's root path and create a routine that would read that folder and scan for .jar files that can be recognized as plugins (inside the .jar there'll be a .xml file which will be used as the system's signature), then load the files in the classpath at runtime, well this part seems quite easy, i found a lot of material about this subject, but i can't realize how i'll make the plugin access the main system's classes and methods, my initial idea was to pass through the constructor of the plugin, the path for the main system .jar and then load the main .jar in the plugin at runtime but i'm not sure if this is the most efficient approach. Does anybody has an idea?

Paulo
  • 29
  • 2
  • Have you researched Java's SPI suite? – CAG Gonzo Oct 20 '14 at 13:37
  • I did that once before a long time ago before "modularization" wasn't really a thing yet. Basically I did what you did, only I didn't pass in the actual class but an API interface which I could simply link into both the plugin and the main application. That way the plugin could be compiled by anyone without needing the main application classes on the classpath; it only needed the shared interfaces which were in a separate jar. But nowadays there is stuff like OSGi http://en.wikipedia.org/wiki/OSGi – Gimby Oct 20 '14 at 13:51

0 Answers0