dependency-injection

small footprint dependency injection java

I am looking for a very lightweight dependency injection framework for java. With minimum possible dependencies and minimum features. Just something along the following lines: receive a java.util.List of Classes, instantiate them and just auto-wire all the objects one into the other. ...

Best Aspect Oriented Framework for features / build performances in .net

Hi, In various projects I worked with, we had to use some AOP or dependency injection framework. We used Enterprise LIbrary, Unity and PostSharp. For now, Postsharp is my best choice when it comes to the flexibiity I get over how I generate my aspects. The only problem is the build time required once PostSharp is installed. My dev...

Is this an example of dependency injection?

Is the example below dependency injection with regard to the Worker class? From my reading about the topic over the last few hours becaue the Worker class isn't obtaining the ITool instance from a property setter or constructor it isn't an example of DI? public MainClass { static void Main(string[] args) { ITool someTool = ...

What role do delegates play in dependency injection?

In most examples of dependency injection, I see simple objects being injected, such as in the example below SecurityManager gets injected into MainApplication. However, it would seem natural to inject delegates as well, as in the example below LogHandler gets injected into MainApplication. Are delegates generally not used in dependency...

What is the best way to "adorn objects with functionality"?

I made the example below which enables a factory to pack objects with functionality, but the problem is that the functionality is divorced from the object. My ultimate goal is attach functionality such as log, and save and display which operates on the specific properties that each different object has. How would I keep the exterior a...

Events in a Dependency Injection system go which way?

Up or down? I'm a very visual person. I'm thinking of my application as a hierarchy, where the top is the root and the bottom is a leaf. I'm also under the understanding that, in DI systems, containers are ignorant of their contained objects' responsibilities/functions. Instead, the contained objects know about their context because th...

When to use Dependency Injection? When not to?

From what I understand, the trade-off here is a matter of added complexity. Maybe? It seems (always?) more decoupled to use Dependency Injection, but simpler (to many people) without it. From what I understand about everything in life, nothing is absolute, and there's a time and place for everything. I'm trying to understand the trade-...

Is there something like PostConstruct for JAXB-annnotated classes?

I need to perform certain operations on a class after it was unmarshalled (after it is constructed by JAXB, rather then by myself). Is there such a functionality in JAXB? If not, how could I achieve it? ...

Stuck trying to get Log4Net to work with Dependency Injection.

Hi folks, I've got a simple winform test app i'm using to try some Log4Net Dependency Injection stuff. I've made a simple interface in my Services project :- public interface ILogging { void Debug(string message); // snip the other's. } Then my concrete type will be using Log4Net... public class Log4NetLogging : ILogging {...

Dependency injection in NerdDinner - actually testing your repository or model

Consider a beginner dealing with Dependency Injection. We're analyzing two relevant classes in NerdDinner. DinnerRepository from the application: FakeDinnerRepository from the tests: They implement different logic, which of course is necessary, as the key idea here is to implement the IDinnerRepository, and provide different impleme...

What's a good metaphor for Dependency Injection?

A metaphor that stuck with me when programming non-DI systems is "a person playing with his/her toys". A person being an object and the person's toys being anything that object creates, stores, initializes, and manipulates. The toys can dispatch events when they reach a certain state, but they know nothing about the person using them; th...

Dependency injection and ASP.Net Membership Providers

I am in the process of creating a custom membership provider for an ASP.Net MVC website. The provider is being created as a separate class as part of a bigger library. There is a need for the back-end data store to be flexible as it could be an Xml File or SQL database. My initial thought was to create an interface for the data store and...

Prefer Dependency-Injection over Partial Mocking?

I know this SO question, but it deals with the subject in more general terms. Should I prefer using partial Mocks over Dependency Injection? My question is based on the following quote from OCMock: id aMock = [OCMockObject partialMockForObject:anObject] Creates a mock object that can be used in the same way as anObject. When a ...

DI: Handling Life of IDisposable Objects

So I'm working on my DI/IoC Container OpenNETCF.IoC and I've got a (reasonable) feature request to add some form of lifecycle management for IDisposable items in the container collections. My current thinking is that, since I can't query an object to see if it's been disposed, and I can't get an event for when it's been disposed, that I...

Mocking without IoC or Dependency Injection

Hi All, Is there a way to use mocks or fakes in your unit tests without having to use dependency injection or inversion or control? I found this syntax can be used with TypeMock Isolator (http://learn.typemock.com/). It is a comercial product though, so I was hoping that other frameworks (such as RhinoMocks) would be introducing such s...

Unity XML Config Test

We are constantly having problem with our application being broken due to the Unity configuration not being able to resolve dependencies, either the dll or namespace has been changed or is initially wrong. Can anyone point me in the right direction for writing a Test that will ensure all the Unity config files can resolve their dependen...

When to use Dependency Injection

I've had a certain feeling these last couple of days that dependency-injection should really be called "I can't make up my mind"-pattern. I know this might sound silly, but really it's about the reasoning behind why I should use Dependency Injection (DI). Often it is said that I should use DI, to achieve a higher level of loose-coupling,...

Can Dependency Injection delay creating objects required?

Hi folks, I'm playing around with some Dependency Injection (StructureMap) with my ASP.NET MVC application. Works great. Becuase StructureMap is using DI via the most gready constructor (I hope I got that concept named right), I'm under the impression that it creates an instance of an object for each argument, in the most gready constr...

Dependency injection with Unity and ASP.NET MVC

Hey folks, I'm attempting to use Unity as my IoC container, which "kinda" works. Snip from global.asax: protected void Application_Start() { //... left out for clarity //setup dependency injection with Microsoft Unity DependencyInjection(); } private void DependencyInjection() { va...

Help me with architecture to encapsulate my databases (maybe DI/IoC?)

I'm building a Windows-forms application that does some analysis that depends on 3 different databases. Two are actually geographic databases (ESRI) and one is a standard CRUD-type repository of information. Let's call them GeoRefDatabase, GeoResultDatabase, and RulesDatabase, respectively. There will be different types of analysis clas...