I have a set of interfaces and then multiple
implementations of the interfaces. Only one implementation is used in a
given instance of the application.
I'm trying to create separate
projects for the common interface and each of the implementations.
However, the problem I have is that in order to implement the common interface,
each of the implementation projects needs to depend on the common interface
project. I also need to create a factory method somewhere which will return the
appropriate version of the implementation based on some parameters. It seems
logical to put this factory into the common project. However, I cannot do this
because the implementation projects depend on the common one and this creates a
circular dependency in maven.
How does one typically solve this sort of problem. I could create yet another
project which contains the factory and depends on all the other projects. Is
there a more sensible way?
<parent> +--- <common-interface> +--- <implementation-1> -> depends on
common-interface +--- <implementation-2> -> depends on common-interface
Where does the factory go? It depends on all 3 of the above.
TIA