views:

158

answers:

3

I am looking for a simple to use IoC container for GUI applications written in Java/Scala.

It should support Convention over Configuration, lifecycle management, configuration in code (preferably without any XML needed at all), and checking dependencies at compile-time as much as possible. Something similar to Autofac would be perfect.

+8  A: 

Sounds like you need something like Google Guice.

There used to quite a few IoC containers for Java (e.g. PicoContainer), but they've all been in the shadow of Spring for years now. Spring is likely a bit over the top for your needs, though.

Guice has restarted some healthy competition.

skaffman
That's the option I am looking at currently, but I am hoping to learn of alternatives.
Alexey Romanov
Yes, Spring is definitely way too heavy.
Alexey Romanov
Even Spring 3.0 with just spring core, and using annotation-config?
Nate
+3  A: 

Google Guice is pretty good:

http://code.google.com/p/google-guice/

You don't have any XML gunk either, you can just create module programatically and write things together in that, e.g binding an interface (TransactionLog) to an implementation class (DatabaseTransactionLog):

public class BillingModule extends AbstractModule {
  @Override 
  protected void configure() {
    bind(TransactionLog.class).to(DatabaseTransactionLog.class);
  }
}
Jon
+ 1 for Guice, and here's an interesting read on porting from Plexus to Guice-2.0 http://www.sonatype.com/people/2010/01/from-plexus-to-guice-1-why-guice/
crowne
Guice kicks Spring right in the balls
Jon
+1  A: 

PicoContainer is a highly embeddable, full-service, Inversion of Control (IoC) container for components honor the Dependency Injection pattern. The project started in 2003 and pioneered Constructor Injection auto-wiring. It is also Open Source and therefore free to use. The license is BSD and thus you can safely use this with commercial or other open source software.

stacker