I just finished a large refactoring of the Savant dialect code in order to add support for dialect dependencies. Since it is always ideal to break down pieces of functionality into logical units and then introduce well defined dependencies, I went ahead and did that with Savant dialects.
I was thinking of using traditional getter/setter or constructor DI for this thing, but the more that I thought about it, the more it didn’t seem to fit. In order for those types of systems to work you need a rather complex configuration and usually some id mechanism to identify dependencies. You can also use type DI that does all of the work based on the types of parameters passed to constructors and JavaBean properties. Dialects shouldn’t be required to define dependencies on a specific class since they might not have that class in their classpath. Likewise, a large configuration file seemed to be messy and would really clutter things up (although it might work in the future if I need to give that a shot).
Instead, I added a method that takes a Map, which contains the dependencies to the Dialect interface. This seems best and most practical for now. Now I just have to tackle the versioning problem and then get back to writing dialects. Hopefully now with all this refactoring and dialect dependencies support, new dialects will be much easier to unit test.