java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

Plugin pattern

Open iluwatar opened this issue 9 years ago • 22 comments

Description

The Plugin design pattern allows a software application to support extension through third-party plugins, providing flexibility and scalability. This pattern is particularly useful for applications requiring dynamic and interchangeable components.

Main Elements of the Plugin Design Pattern:

  1. Plugin Interface: Defines the methods that plugins must implement.
  2. Concrete Plugins: Implementations of the plugin interface, providing specific functionality.
  3. Plugin Manager: Responsible for loading, initializing, and managing the lifecycle of plugins.
  4. Application Core: The main application that uses the plugin manager to interact with plugins.

References:

Acceptance Criteria:

  1. A Plugin Interface is defined with necessary methods that plugins must implement.
  2. At least two Concrete Plugin implementations are created, showcasing different functionalities.
  3. A Plugin Manager class is implemented to handle loading, initializing, and managing the plugins.
  4. Demonstration of the pattern in a sample application, showing dynamic loading and usage of plugins.

iluwatar avatar Jan 16 '16 11:01 iluwatar

Hello I am ready to tackle this issue. Is there any information I need to read to understand this issue?

skylermj-252 avatar Feb 10 '16 16:02 skylermj-252

@skylermj-252

This pattern is described in Patterns of Enterprise Application Architecture book.

Brief description about the pattern:

  • Separated Interface: Some behaviors implementation must be chosen dynamically based on runtime environment. Different environments include Unit Testing, Stress Testing, IoT, Production. Ex of such a requirement is ID generator, in unit testing environment in memory counter based solution should be chosen and in production DB based counter must be chosen.
  • Dynamic linking: A plugin implementation is not known during compile time. The actual implementation is chosen based on configuration at runtime, and the class is loaded using reflection. The configuration can be a text file containing full path of plugin class.
  • Reconfiguration: Reconfiguration will not require rebuild, as we have them loaded dynamically. I am thinking about a valid use case for this. I will comment as soon as I find an appropriate use case.

npathai avatar Feb 12 '16 10:02 npathai

Random thoughts on reconfiguration: Java does not allow reloading same class. So I guess reconfiguration means switching from one implementation to other. Like switching from In Memory Counter implementation to DB based counter.

npathai avatar Feb 12 '16 10:02 npathai

The best implementation approach for this pattern is to use annotations, reflection and dynamic binding in java, and Abstract Factory combined with Strategy pattern so as to give the desired flexibility. Although i am really busy presently, but i will love to render my assistance in any way.

Cheers.

On Fri, Feb 12, 2016 at 11:13 AM, Narendra Pathai [email protected] wrote:

Random thoughts on reconfiguration: Java does not allow reloading same class. So I guess reconfiguration means switching from one implementation to other. Like switching from In Memory Counter implementation to DB based counter.

— Reply to this email directly or view it on GitHub https://github.com/iluwatar/java-design-patterns/issues/351#issuecomment-183261058 .

geniusgeek avatar Feb 12 '16 10:02 geniusgeek

This issue is free for taking again.

iluwatar avatar May 17 '16 18:05 iluwatar

Here are some guidelines http://stackoverflow.com/questions/465099/best-way-to-build-a-plugin-system-with-java

iluwatar avatar Jul 01 '16 05:07 iluwatar

Hi, I see that there is a commit to this issue already but it is still open.

What are the next steps here - Work on existing commit from @npathai or write the solution from scratch?

Can the new person decide what is the right next step?

abhi-agr avatar Jul 30 '18 16:07 abhi-agr

@abhi-agr you can write the implementation from scratch or utilize @npathai's solution if you wish. Will you work on this?

iluwatar avatar Aug 01 '18 07:08 iluwatar

I am planning to work on this. But I think I need to compare different strategies - OSGI and JPF to find out the better implementation.

Let me come up with a design and later I can move to implementation

abhi-agr avatar Aug 01 '18 16:08 abhi-agr

Ok @abhi-agr

iluwatar avatar Aug 07 '18 19:08 iluwatar

Issue free again

iluwatar avatar Oct 05 '19 15:10 iluwatar

please check it.

LiHao-MS avatar May 08 '20 08:05 LiHao-MS

@jasciiz are you still working on this?

iluwatar avatar Jul 06 '20 16:07 iluwatar

This issue is free for taking again.

iluwatar avatar Oct 24 '21 15:10 iluwatar

hi, can I work on this issue?

lkpengcs avatar Mar 19 '22 03:03 lkpengcs

Yes @lkpengcs, go ahead

iluwatar avatar Jul 01 '22 15:07 iluwatar

@lkpengcs are you working on this?

iluwatar avatar Sep 21 '22 18:09 iluwatar

Sorry, I am a little busy these days and cannot work on this.

lkpengcs avatar Sep 22 '22 02:09 lkpengcs

May I try to implemented this issue?

Kaiyan1Zhang avatar Oct 16 '22 03:10 Kaiyan1Zhang

Yes @Kaiyan1Zhang

iluwatar avatar Oct 16 '22 14:10 iluwatar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 28 '22 14:11 stale[bot]