dependency-injection

Plugin Architecture/Dependency Injection Question

Hello, I'm trying to figure out an architecture for plugins, but I've never worked with that. Essentially, my Program supports multiple database backends, but only one at a time. my idea was now to create a new Assembly (".DataCore") that contains all my Repository Interfaces (IFooRepository, IBarRepository) and a IDataPlugin Interface...

Guice configuration error

I'm trying to use Google Guice with the @Inject and @Singleton properties as follows: I have: A Module with an empty configure() method. An interface IFoo A class Foo (implementing IFoo), annotated with @Singleton, with a parameter-less constructor annotated with @Inject. This is the single annotated constructor. The classes, constr...

Runtime implementation substitution with Ruby

Dependency Injection frameworks in Ruby have been pretty much declared unnecessary. Jamis Buck wrote about this last year in his LEGOs, Play-Doh, and Programming blog post. The general accepted alternative seems to be using some degree of constructor injection, but simply supplying defaults. class A end class B def initialize(option...

How exactly dependency injection is implemented internally in Spring.net?

I'm just curious to know about this.When i heard about Spring.net and tried some sample codes of DI i found it cool and eventually i was curious to know how it works and implemented internally? Even though have the src along with the framework i'm not yet good enough to find out where and how it is done. Is this something to do with Re...

DI object graph building - separating logic and construction graph

Sorry if this is a really basic question but it's been really getting to me. I really like the idea of DI, it really helps me with my testing but I have hit a bit of a brick wall I think. So I have two types: Table TableManager Now the table object has a constructor on it like this: Table(ITableCommandRunner tableRunner, IQu...

Programmatically set a specific bean object - Spring DI

In my program I need to programmatically configure an ApplicationContext. Specifically, I have a reference to an instance of MyClass and I want to define it as a new bean called "xxyy". public void f(MyClass mc, ApplicationContext ac) { // define mc as the "xxyy" bean on ac ??? ... ... // Now retrieve that bean MyClass bean =...

Spring: How to programmatically define FactoryBean

I want to programmatically setup a FactoryBean on an existing ApplicationContext. There are a lot of examples on how to define a bean programmatically (e.g.: http://www.carlobonamico.com/blog/2008/01/22/how-to-dynamicallyprogrammatically-define-spring-beans/), but they do not work when I try to define a factory bean ...

What is the best way to resolve an object?

I've written a resolver so I can have a very primitive DI framework. In the framework I allow for a dependency resolver to specify what default types to load if nothing is specified or registered. However, the way I do the default loading has got me wondering. I'm not sure I'm doing it the best way it could be done. Example: T LoadD...

Spring: Nested application contexts

I have a hierarchy of application contexts. The bean that is defined in the parent context depends on a bean that is defined in the child. Here's how it looks like: public class X { public static class A { public B b; public void setB(B b) { this.b = b; } } public static class B { } public static...

Is there a way to detect and debug circular references when using StructureMap?

Lately I've been using a larger number of smaller objects, because they are simpler and easier to reuse. Most of the time there isn't any problem injecting these objects into one another using StructureMap (great tool, btw). But occasionally, I f*** up, and I get myself a nice circular reference in the guise of a stack overflow excepti...

Can Autofac do automatic self-binding?

I know some DI frameworks support this (e.g. Ninject), but I specifically want to know if it's possible with Autofac. I want to be able to ask an Autofac container for a concrete class, and get back an instance with all appropriate constructor dependencies injected, without ever registering that concrete class. I.e., if I never bind it ...

Is it normal to have a long list of arguments in the constructor of a Presenter class?

Warning acronym overload approaching!!! I'm doing TDD and DDD with an MVP passive view pattern and DI. I'm finding myself adding dependency after dependency to the constructor of my presenter class as I write each new test. Most are domain objects. I'm using factories for dependency injection though I will likely be moving to an IoC cont...

MVP : other constructor's parameters than view and model ?

Hi all, I'm experimenting with implementing a lightweight mvp framework with Delphi 2009. Views are passive but supports databinding (via an interface property). I'm facing a dilemna: I've several very similar views/presenter/model triad, ie : order form and a customer form = behavior and logic is the same but the datasource for data...

Setter insection using named session instance strategy with structure map

Hello. I'm using Structure map and want to inject instance (constructed by container) into controller's property. Instance should be named and stored in http session context container. In the previous version of my application I've used custom DI framework and it was easy enough to make such things: public class MyController : Controll...

Inject WCF proxy with credentials using StructureMap

I have a service proxy generated by svcutil which generated an interface(IStudentContract) and a concrete type implementing (StudentContractClient). I'd like to have instances of StudentContractClient injected into my classes via StructureMap. My proxy also needs to have credentials supplied as seen in this passing unit test: ...

MVVM and StructureMap usage

I have quite a large number of parent-detail ViewModels in my MVVM application. Something like this: SchoolsViewModel +- SchoolViewModel +- LessonViewModel +- PupilsViewModel +- PupilViewModel +- TeacherViewModel +- PupilsViewModel +- PupilViewModel +- LessonsViewMo...

Is there an open source .NET web form project using DI/IoC?

I am currently trying to get my head round DI and IoC. Blogs and article are all well and good but I'd like to see some real working source code however I am currently stuck with web forms at work for the time being and most open source projects that I know of that are implementing these kind of development practices seem to be based on ...

Object's property is changed in the Map even without using put()?

Hi I got the code from a book: public class Container { Map<String, Object> components; public Container() { components = new HashMap<String, Object>(); Properties properties = new Properties(); try { properties.load(new FileInputStream("components.properties")); for (Map.Entry entry : properties.en...

Ninject: Howto setup Bindings based upon Dependency Chain

Ok Dependency Ninja's, here's one for you... I want to change the way Ninject builds a dependency based upon the type I'm requesting from the Kernel. I have a DbConnectionFactory class with the following constructors: public DbConnectionFactory() : this(MyDatabase.ConnectionString) { } public DbConnectionFacto...

Why does the dependency injection fail in my CF factory object?

I get this error Element INSTANCE is undefined in VARIABLES. I do not see the reason for the error! This is my factory <cfcomponent output="true" displayname="ObjectFactory"> <cffunction name="init" access="public" output="true" returntype="ObjectFactory"> <cfset variables.instance = structNew() /> <cfreturn this /> </cffu...