dependency-injection

Dependency Injection in XPCOM

Hi, One of my XPCOM components make use of other XPCOM components. As I was testing it, I found it cumbersome cos of the dependencies. Then I thought of using Dependency Injection to pass in the other components in my constructor. I wasn't successful. Is it possible to pass in references of other components into your constructor? var ...

How to inject MessageSource to a View extending AbstractView

I have a view class that extends AbstractExcelView public class ExportExcelParticipantsView extends AbstractExcelView { ... } I would like to inject a MessageSource to this bean. Is this possible? I use a ResourceBundleViewResolver to resolve views (in this case) <bean id="resourceBundleViewResolver" class="org.springframework.web...

Where do I put dependency creation for a Presenter class in a Passive View architecture?

I've just refactored out a new domain class from a presenter class but I can't figure out where to instantiate it. This is part of a larger ongoing refactoring effort with a poorly maintained legacy project. The Presenter is currently being created by the view's OnLoad event and the view is passed as a parameter in the constructor. All...

Windsor castle Injecting properties of constructed object

Some dependency injection containers enable you to inject configured services into an already constructed object. Can this be achieved using Windsor, whilst taking account of any service dependencies there may be on the target object? ...

Why does my Ninject DI application fail with an ActivationException?

I'm new to IoC/DI frameworks. The first one I am trying is the Ninject framework. It seems straightforward, but I can't get my console application to run. I keep getting an ActivationException stating: "Error activating MainWindow: the StandardProvider returned an instance of type FutureRealisticDateManager, which is not compatible wit...

Contextual Binding with Castle Windsor

Hi all Is it possible to get Windsor to return different implementations of a service based on a seperate parameter? For example, if I have a User object which has a Role property, I would like to be able to hydrate this object differently according the the value of Role. I would like to use an IUserService to do this, but have the con...

Dependency injection and physical paths in an ASP .NET environment - howto ?

I have a website that relies on dependency injection, using Castle Windsor. I need to use a component that needs to know the path to a file. I would like to specify the path in the configuration file as a virtual path relative to the web site root directory, so I would do this: <component id="configuration.documentLoader" type="SomeMo...

Unity Best Practices with .NET Framework Classes

I am just getting started using any DI/IoC toolset and have a very basic question. I am using Unity as we will also be using a number of the Enterprise Library blocks throughout the application. The question that I have is around the dependencies to .NET framework classes. For instance, in one of the classes that I am working on curre...

Spring- How to use Spring Dependency Injection to write a Standalone Java Application

I want To write a standalone application with IOC,How do i use springs dependancy injection in there. Im using JIdea. There is spring 2.5 support but i want to use spring 3.0 here is the way i tried! I experience in using Spring MVC we can inject dependancies there in a WebApplicationContext but how do i inject dependancies in a st...

What preferred way to wire dependencies using IoC container?

I believe that most IoC containers allow you to wire dependencies with XML configuration file. What are cons and pros for using configuration file vs. registering dependencies in code? ...

MVP pattern using webforms and DI object instantiation

I am using the generic repository pattern to persist my data. On the PageLoad, I am creating a new Repository (from IRepository) object, and on PageUnload, I dispose of it. Should the MasterPage/Page be in charge of instantiating the objects to pass to the presenter or should the presenter be in charge of this? I'm more concerned wi...

Why do I need an IoC container as opposed to straightforward DI code?

I've been using Dependency Injection (DI) for a while, injecting either in a constructor, property, or method. I've never felt a need to use an Inversion of Control (IoC) container. However, the more I read, the more pressure I feel from the community to use an IoC container. I played with .NET containers like StructureMap, NInject, U...

What are the differences between Castle Windsor 1.0 RC3 and Castle Windsor 2.0?

I've been reading a bunch and playing around with Castle Windsor 1.0 RC3 lately and really like the functionality it provides. Recently 2.0 was released but for the time being I'm pretty much stuck with RC3 for the next little while. So with that in mind what are some of the glaring differences between the two versions and what are some ...

What is Spring's Minimum Dependencies for Dependency Injection?

What are the minimum dependencies required to just use Spring's dependency injection (core framework only)? I'm using Spring for a standalone application, and I'd like to minimize the number of dependencies that I have to ship with the application. I suppose I could systematically remove a Jar and see if the application breaks, but it ...

ASP.NET MVC: HTTPContext and Dependency Injection

Hello, Currently I have an ActionFilter that gets the current users name from HttpContext and passes it into the action which uses it on a service method. eg: Service.DoSomething(userName); I now have a reason to do this not at the action level but the controller constructor level. Currently I'm using structure map to create contro...

Which Dependency Injection technique should I use in dotnet?

[Revision 5/14/09: I need this to target Dotnet 2.0 because of my deployment scenario] I am new to Dependency Injection & IoC. I see that there are a plethora of containers and libraries to help the process along. What are the pros and cons of using these libraries. What is your favorite (dotnet) container and why? What about rollin...

Is it correct to have many Castle Windsor containers per application if those containers belong to different tiers?

I've been playing around with Castle Windsor lately and realized I could use it to back a container-like object I currently use already. So far I've only read information about an application having only one container instance per application. Is it correct to have many containers per application if those containers belong to different t...

How to inject an object into a WCF service

Hi, If I have a service definition/implementation like this: using System; using System.ServiceModel; namespace aspace.service { [ServiceContract(Namespace = "http://aspace.service")] public interface IUpdate { [OperationContract] ConfirmationMessage UpdatePerson(string PersonIdentifier); } } public class UpdateServ...

TDD - When introducing a class when refactoring - should that class be unit tested?

Presume you have a class which passes all its current unit tests. If you were to add or pull out some methods/introduce a new class and then use composition to incorporate the same functionality would the new class require testing? I'm torn between whether or not you should so any advice would be great. Edit: Suppose I should have ad...

We treat interfaces and implementations like we treat content and styling, so why not handle it similarly?

I've used Spring, and I've looked into Guice, and I think that these are both rather obtrusive extensions to languages. I firmly believe that programming languages themselves need to adapt to patterns more cohesive to dependency injection, testing, etc., so why not gravitate to a stylesheet based approach? By allowing multiple "stylings,...