dependency-injection

Limit instance lifetime to a single iteration

I'm working on a web application that uses a couple of services to synchronize data with external resources. The application and the services share the same data layer and use Castle Windsor to implement IoC. In the web application there is the a PerWebRequest lifestyle which limits the lifetime of an instance to the lifetime of a reque...

GUI application and singleton/dependency injection

Hello, I am working on an application with a GUI using wxWidgets. I got an object used as a "model": its data has to be used to draw the ui and the ui should modify it. Let's call this class Model. The structure of the applications looks like this: A wxApp-derived object, that possesses: a wxFrame-derived object, that possesses a wx...

For a simple web application, what service locator library you prefer to use?

For a simple application that use asp.net mvc 3 and .net-4, what service locator application is preferred, with performance concern in mind? ...

Set AutoFac to use PropertiesAutowired(true) as default?

Is there a way i can set AutoFac to use PropertiesAutowired(true) to be the default for all types being registered. i.e. I dont want to use ".PropertiesAutowired(true)" all the time var builder = new ContainerBuilder(); builder.RegisterType<Logger>() .PropertiesAutowired(true) .SingleInstance(); ...

Difference between creating new object and dependency injection

What is the difference between creating a new object and dependency injection? Please explain in detail. ...

How do you make a Generic Generic Factory?

I am working on a client (Silverlight) interface to a collection of webmethod. And I am trying to avoid writing any custom code for every webmethod. So I have created a ServiceCall<TResult> to handle each call, TResult specifies the return type of the service (I use XmlSerializer to create the returned instance). The client class exposes...

WPF DI Service Locator

So I'm looking for some clarification how it would be possible to remove the service locator from my application. I have a ViewManagerService that is responsible for knowing which view is active, which views are open and creating a new view. Currently my ViewModels get an IViewManagerService injected into them via constructor injection...

Castle ILazyComponentLoader not Intercepted

I have a ILazyComponentLoader that registers any type on demand. My container also has an IModelInterceptorsSelector. When I resolve an unknown type, the ILazyComponentLoader is invoked correctly and then the IModelInterceptorsSelector is also invoked and returns the correct interceptors, but the resulting instance (which is indeed creat...

Is this design for dependency injection easy to understand?

I'm working on a project with a large existing codebase and I've been tasked with performing some re-engineering of a small portion of it. The existing codebase does not have a lot of unit testing, but I would like at least the portion I'm working on to have a full suite of unit tests with good code coverage. Because the existing codeb...

Why would I use MockRunner over normal/hand rolled dependency injection?

At our comapny, we have a service layer which takes in a some request XML, accesses various Stored Procecdures (SP's) via JDBC, processes the data and responds with some response XML. Lately people have begun to adopt MockRunner in their JUnit tests to mock the responses from the SP's. The code to setup the mocked responses from the SP...

Difference between ioc and dependency injection

Difference between ioc and dependency injection . explain dependency injection in spring. What is difference b/w JSF dependency injection and spring dependency injection.. ...

JEE6: Switching to CDI - Best resources

I have a small yet complete JEE 6 application at hand. The traditional annotations are being used: @Resource, @EJB, @Singleton, @PostConstruct, @PreDestroy, @PersistenceContext, @ManagedBean, @ManagedProperty, @RequestScope, @ApplicationScope,... I would like to evaluate whether it makes sense to introduce CDI, and to standardize ...

Why use @PostConstruct ?

In a managed bean, @PostConstruct is called after the regular Java object constructor. Why would I use @PostConstruct to initialize by bean, instead of the regular constructor itself? ...

fail for null arguments with @Inject

I've started using Spring 3 Java Config with the JSR-330 @Inject annotations. Unlike the Spring @Autowire, Spring does not fail at startup if the @Inject parameters are null. Is there a way to do this within Java Config? Edit: Just a clarification, I would like this as the default behaviour so I don't have to put @Required on every fiel...

How to convert this code so it now uses the Dependency Injection pattern?

Ok, So I have the following situation. I originally had some code like this: public class MainBoard { private BoardType1 bt1; private BoardType2 bt2; private BoardType3 bt3; ... private readonly Size boardSize; public MainBoard(Size boardSize) { this.boardSize = boardSize; bt1 = new BoardType1(b...

When implementing dependency injection, should exceptions be injected?

My team is muddling through implementing dependency injection in a PHP project using a homebaked DI container. Our first iteration of DI was perhaps taken to the extreme, and even exceptions are being injected into classes that depend on them. Is this a good practice or overkill? ...

Autofac different service resolution based on TypedParameter

Is there anyway to get autofac to resolve the service that has a concrete implementation with the constructor that matches a given parameter most specifically. By this i mean match a constructor for a child type instead of matching the constructor for the base type. For example i'd like to make the following test pass [TestFixture] pu...

ASP.NEt MVC 3 P1 Dependency Injection to Filters

I have read through Brad Wilson's series of "ASP.NET MVC 3 Service Location" (http://bradwilson.typepad.com/blog/2010/07/service-location-pt4-filters.html) and tried to get the DI work with Unity, but it would not (System.NullReferenceException). Have searched everywhere but can find nothing that takes up the subject. So, how do I resolv...

Where to store Ninject IKernel in a web application?

I am new to IOC in general and I'm struggling a little to understand whether what I am trying to do makes any sense. I have a web forms application in which I want to create one module to define some bindings for me. The bindings will be used to inject repositories into my business manager classes, allowing me to unit test the business...

Google Guice 2.0

I have a class that loads some files into a specific object that itself contains several objects that contain different fields. Exmaple: class RootItem { public SubItemType1 sub1; } class SubItemType1 { public SubItemType2 sub2; public int data1; public float data2; } class SubItemType2 { public int data3; public boolean data4; } Al...