javaarchitecturecustomizationextendsplugin-architecture

My own Java application which can be customized


I'm planning to implement a process using a java app. The process has various phases. Each phase has an input and output.

So it is something like input1=>phase1=>outpu1=>phase2=>output2=>phase3=>final_output

I want to write a java application in which the users can extend any phase to implement their own functionality.

for e.g: lets say that phase1 sorts the given input. I want to let my app users create custom class which will replace the functionality of phase1. they may want to do counting instead of sorting.

Any ideas on how to do this? plugin architecture? Any examples of frameworks which work in similar way? Where to start? edit: the input is from the user. let us say my app takes a set of numbers and does sorting(phase1) then removing duplicates(phase2) and adding(phase3) and gives output. Now I want the phases to be customizable. Probably by allowing them to define their own class which does something else.


Solution

  • An idea of solution: Phase would be an interface with a process() method, which can be implemented with any algorithm. This process() method could have an Output return type and take another Output as parameter, with Output another type (class or interface). And an Executor class, which will execute the whole process, with a an execute() method using a List of Phase, using the return ouput of each Phase as an input for the next one. The only open question is: what will be the input of the first Phase?