John
John

Reputation: 1

Java Plugin Development

I'm developing a java application that has 20 plugins, each plugin's have some similar GUI menu item's and menu event's but they store data in different table's in a database. Currently I'm creating separate GUI, event and model classes for each plugin by copying and pasting in diffrent class files.

Is it wise to develop separate GUI, event and model classes for each plugin's and duplicate similar methods to other plugin's?

I need your advice on how to create a generic GUI, event and model interface for all the plugin's without making my application uneasy to maintain.

Thank you.

Upvotes: 0

Views: 839

Answers (1)

Guus Bosman
Guus Bosman

Reputation: 214

We have a plug-in system in our product, and ran into the same issue. Many of the plug-ins share a lot of code. We ultimately decided on the following:

  1. Define clean Interfaces (PluginABC implements MyProductInterface). These interfaces don't require a specific implementation but...
  2. We provided a AbstractPlugin that Plugins can extend. This AbstractPlugin provides a ton of standard functionality that is useful for most plug-ins.

Example:

public interface MyProductInterface {
   public void doIt();
}

public class MyPlugin implements MyProductInterface extends AbtractPlugin {
  public doIt() {
    // ...
    usefulMethodForMostPlugins();
    /// ...
  }
}

public abstract class AbstractPlugin {
   public usefulMethodForMostPlugins() ...
}

Upvotes: 1

Related Questions