dependency-injection

Property injection with Unity causing stack overflow...

Hi all, I have been using Unity for quite a while but I have always used it with constructor injection. In an effort to reduce the number of classes I have to inject into my view models (as my commands rely on them) I thought I would try creating a concept that uses Property Injection and thus quash the requirement for the large constru...

NUnit integration programmatically with spring

Hi! I have a component based architecture framework designed and I use NUnit for isolated testing - okay so far. Now I want to enable integration tests. Therefore the tests use real implementations of the existing components. Each element of the component has a life cycle (init, start and stop) and I created a NUnit component. In the ...

Is testability alone justification for dependency injection?

The advantages of DI, as far as I am aware, are: Reduced Dependencies More Reusable Code More Testable Code More Readable Code Say I have a repository, OrderRepository, which acts as a repository for an Order object generated through a Linq to Sql dbml. I can't make my orders repository generic as it performs mapping between the Linq...

Using StructureMap, how do you explicitly trigger the reinstantiation of a object with InstanceScope.Singleton?

I have an integration test harness where I want to teardown and then re-instantiate some of the singleton-scoped objects I've registered with StructureMap, after and before each test. This way I can simulate the actual run time environment, but not have the singleton's state being passed from one test to another. Maybe this isn't a g...

Whats the relationship between Spring and javax.enterprise.inject?

I was reading a Wikipedia article about Java EE application servers here: http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Java_EE_5_certified It says that 2 APIs that Java App Services implement are: javax.enterprise.inject javax.enterprise.context These both relate to application context and dependency injection JSR-...

IoC: advantages of using a child container in web based app

I'm interested in knowing if there are any advantages to creating a child container for each request in a web based application? The tech stack I'm using includes StructureMap & ASP.NET MVC, which is not particularly relevant but included as background info. ...

Unity and web service

I had this awesome idea... but I am afraid maybe it is actually a bad idea.... we use unity for dependency injection. I make interfaces from my web services using partial classes for the purpose of mocking and web services.... What I want to do is put my web services into unity and get them via dependency injection... What do you thi...

Serializing Configurations for a Dependency Injection / Inversion of Control

I've been researching Dependency Injection and Inversion of Control practices lately in an effort to improve the architecture of our application framework and I can't seem to find a good answer to this question. It's very likely that I have my terminology confused, mixed up, or that I'm just naive to the concept right now, so any links ...

Robotlegs Vs Parsley

I am planning to start a new project in as3 and I want Dependency Injection in the project. I found that parsley and Robotlegs are two popular frameworks for implementing DI in AS3. Which is the best one among these two? My main requirements are lightweight minimal learning extensive documentation and active helping community ...

Can a plain servlet be configured as a seam component?

I created a plain servlet within a seam-gen (2.1.2) application, now I would like to use injection. Thus I annotated it with @Name and it's recognized as component: INFO [Component] Component: ConfigReport, scope: EVENT, type: JAVA_BEAN, class: com.mycompany.servlet.ConfigReport Unfortunatly the injection of the logger doesn't ...

Unity 1.2 Dependency injection of internal types

I have a facade in a library that exposes some complex functionality through a simple interface. My question is how do I do dependency injection for the internal types used in the facade. Let's say my C# library code looks like - public class XYZfacade:IFacade { [Dependency] internal IType1 type1 { get; set; ...

Dependency Injection wcf

I want inject a implementation of my Interface in the WCF but I want initialize my container of Dependency Injection in the Client of the WCF. So I can have a different implementation for each client of the my service. Help me please. ...

How do I pass dependency to object with Castle Windsor and MS Test?

I am trying to use Castle Windsor with MS Test. The test class only seems to use the default constructor. How do I configure Castle to resolve the service in the constructor? Here is the Test Class' constructors: private readonly IWebBrowser _browser; public DepressionSummaryTests() { } public Depress...

How best to Refactor code that is composed of other private objects that are created in the Constructor

Hi Guys I have the following code that was written without Tests but is actually quite well designed and loosly coupled. The CachedBindingListView constructs a number of objects namely the page provider and the Cache. As Follows. /// <summary> /// Inner data cache /// </summary> private Cache<T> InnerCache { get; set; }...

Dependency Injection and Unit of Work pattern

I have a dilemma. I've used DI (read: factory) to provide core components for a homebrew ORM. The container provides database connections, DAO's,Mappers and their resultant Domain Objects on request. Here's a basic outline of the Mappers and Domain Object classes class Mapper{ public function __constructor($DAO){ $this->D...

Dependency injection: Scoping by region (Guice, Spring, Whatever)

Here's a simplified version of my needs. I have a program where every B object has its own C and D object, injected through Guice. In addition an A object is injected into every C and D objects. What I want: that for each B object, its C and D objects will be injected with the same A object. [Edit-Start] (1) Guice supports "singlet...

Dependency injection and factory

Trying to figure out how to best handle the following scenario: Assume a RequestContext class which has a dependency to an external service, such as: public class RequestContext : IRequestContext { private readonly ServiceFactory<IWeatherService> _weatherService; public RequestContext(ServiceFactory<IWeatherService> weatherSer...

IoC - Dynamic Composition of object instances

Is there a way using IoC, MEF [Imports], or another DI solution to compose dependencies on the fly at object creation time instead of during composition time? Here's my current thought. If you have an instance of an object that raises events, but you are not creating the object once and saving it in memory, you have to register the eve...

Simple object creation with DIY-DI?

I recently ran across this great article by Chad Parry entitled "DIY-DI" or "Do-It-Yourself Dependency Injection". I'm in a position where I'm not yet ready to use a IoC framework, but I want to head in that direction. It seems like DIY-DI is a good first step. However, after reading the article, I'm still a little confused about obje...

MVC model binding to interfaces

I have created an OrderFormViewModel which looks something like public class OrderFormViewModel { public IOrderDetails { get; set; } public IDeliveryDetails { get; set; } public IPaymentDetails { get; set; } // ... etc public SelectList DropDownOptions { get; set; } // ... etc } This goes to my Create view, ...