Using the Spring Framework in game development?

I recently got a job at a small software company and we’re working with the Java Spring Framework. Though it’s more a framework for buisness applications, maybe one could use it in games, too? The nicest thing about it is the dependency injection mechanisms (@autowire) which is just so nice. Obviously you wouldn’t use a database and stuff, but maybe you can use some aspects of it?

I googled and searched this forum, but I found absolutely NOTHING that talks about games and the Spring Framework. Does it just not make any sense? Please share your thoughts :slight_smile:

I don’t know why could someone use the @autowire in jme, jme is very “OO”, and that tag flees the context. I see spring how the better existing mvc framework, then it helps a lot when we are talking about “controllers”, but I don’t think it’s needed to use it in jme, because jme already have their cool controllers. In mvc, the controllers controls the guis / views. In jme, the guis are the nifty screens, and the controllers are the nifty screen controllers.

I think there are complications with Spring on Android for some reason, which could limit that side of game dev, but I base this on nothing and I could have just made it up so be warned :wink:



I used Spring a bit at work on web projects, and found it both simply excellent when it was working properly, but a huge pain if something was going wrong. I generally try to steer clear of these systems I have deemed use magic in an attempt to make a programmers life easier, but that’s cause I’m impatient.



I would say Google is not turning up anything since any relevant game related design patterns used within the Framework are already in common use in game development, but you would need to Google their respective names, and there is no need for the entire framework… dunno… I would be interested to hear from someone who mas more experience with Spring…


  • my 2 cents :slight_smile:

Dependency injection is nice when you need to switch components out in a configurable way. The idea of interfaces and encapsulation is a good idea in general but the sort of late-binding wiring of components together implies a really flexible architecture. Not something you see in many games.



Add to that, Java makes home grown dependency injection really easy. You don’t need Spring to define component relationships on the fly… spring just provides a lot of tools and adapters for various services, especially J2EE services. I’d bet 99% of those Spring services are not useful for games. And the dependency size hit is not free.



Just my opinion, of course. I’m a huge fan of IoC, dependency injection, and meta-programming. I even have some open source tools out there related to that stuff… and still I haven’t once added any of that to Mythruna. Arguably, there are a few places I could have used that on the server but it’s just easier to just wire that stuff up in more traditional ways and save the download size of the other jars.

I actually disagree slightly, but to be honest i’m not using Spring. Instead it’s a homegrown tool that utilizes IoC, but it also provides other tools which are a bit more focused to rapid development. We use something called jSeed, which allows for code injection into runtime classes using the proxy pattern. The benefits of this is to not concern yourself with all of the ordering of how services and classes are to be used and all the intricate details, and instead let the jSeed framework take care of these concerns for you. I/We have also used it for injecting the Nifty Controllers, which has been nice since we don’t need to pass information around in order to use these controllers.



All in all I find it to be a nice approach to starting up the game, and it has been discussed in a few other locations, most notably in the tutorials of GBui (may it rest in peace). If size is a concern, there are more light weight approaches that you can take, or simply make your own (depending on game size and features you are desiring). In the end, I think it can greatly reduce the code size of your project, which makes it more maintainable.



If interested, http://code.google.com/p/jseed/ is an open source project and hobby of mine.