views:

227

answers:

3

bean id="foo" class="com.ems.samples.spring.Foo"
property name="bar" ref="bar"/
/bean
bean id="bar" class="com.ems.samples.spring.Bar"

    public class Foo {

  private Bar bar;

  public String getMessage() {

        return "Foo" + bar.getMessage();

  }

  public void setBar(Bar bar) {

        this.bar = bar;

  }

}

public class Bar {

  public String getMessage() {


        return "Bar";

  }

}

A: 

There's Spring.net for a start, but I've no idea how it plays with asp.net mvc

Bedwyr Humphreys
thanx but i know it ,i need for asp net mvc.
tobias
Spring.NET works on ASP.NET MVC...because it's, well, .NET.
Talljoe
oh yesspring.neti saw only spring word first.
tobias
+4  A: 

There's Castle Windsor, Spring.NET, StructureMap, Unity, Ninject and possibly more... check out the MvcContrib project for samples and controller factories that support the mentioned IoC containers.

mookid8000
+2  A: 

checkout Munq.DI at munq.codeplex.com. It is a simple, fast DI container with lifetime managers specific to web development. Object can have lifetime duration of Request, Session, Cache, and Container. Additionally, there is a MunqControllerFactory and example for ASP.NET MVC. Full source included.

Matthew
i think all of DI frameworks gives poor performance.i can injection manually because the frameworks become for lazy code compiling :)
tobias
Not all DI have poor performance, but some do. check out Daniel Cazzulino's Blog postings on Funq http://www.clariusconsulting.net/blogs/kzu/archive/2009/04/17/141951.aspx. Some interesting performance information. Munq is slightly faster than Funq due to simpler Resolve functionality (no parameters). Properly used, a IOC can completely decouple class construction from the concrete instances of the class's dependencies. This allows you to inject stubs or alternate implementations for testing or different environments.
Matthew