(Very small) Spring gripe… from a Swing perspective

So as I mentioned, I’m embarking on a Swing project and have chosen to use Spring as a container and for reporting via it’s AOP functionality. I’m not, however, going to use the Spring RCP tool which is basically a Spring off-shoot specifically geared to Swing development. I’ve read some posts on the Spring RCP forums, and it looks like this project is clearly pre-alpha and the API is likely to change significantly before the first release. I think I’ll wait on that.

Besides, vanilla Spring seems to be offering major benefits to Swing development already (IoC and AOP), without the specialization of the RCP project.

So what’s my gripe with Spring?

Spring allows IoC through both setter and constructor injection. What about static factory methods? I guess I’m just shocked that the folks who developed such an amazing framework would have missed this obvious need… Haven’t they read Effective Java? It’s like, item #1. Spring should allow you to use static factory methods for dependency injection. Seriously. Someone please tell me if this has been brought up before, or if I’m missing some obvious reason why this can’t (or shouldn’t) be done.

I have a second, less well-formed gripe concerning the tying of ApplicationEvent to the Spring framework. What does this class provide that the more basic java.util.EventObject doesn’t? Couldn’t we have used that rather than subclassing, thus keeping springframework out of the imports in our biz objects?

Again, I’m sure there’s someone out there who can explain why this was a better solution… please help me out.

Update — Thankfully, I’ve been politely corrected… Spring does support Dependency Injection via static factory methods.


About this entry