dependency-injection

Any DI Frameworks that convert from string to constructor Types?

I'm just wondering if there is a DI Framework for .net that handles string-to-some type conversion for me? Basically I have this constructor: public MyImplTwo(bool someParam) and a string like "true" or "1". I've tried Unity, but this throws an error saying that no constructor with the signature MyImplTwo(string) exists: container.R...

Are Consumers of ServiceLocator supposed to call ServiceLocator.Current?

I'm trying to refactor my code to use the Common Service Locator. I have a Shared Library that is used by some other components. What I don't understand is: Are these components supposed to call ServiceLocator.Current and resolve their types? In that case, how can I make sure that ServiceLocator.Current is actually set? Should I create ...

StructureMap and named instances

I'm not sure why the following doesn't work. StructureMap tells me there is no default dependency defined for SomeClassWithDependencies...um...dependencies. Can anyone shed any light on this? I want to construct the object through the entire dependency tree based on the named instances. Am I barking up the wrong tree? public class P...

Gwt-dispatch injection

To use gwt-dispatch we create an object like: private static final DispatchAsync dispatchAsync = GWT.create(DefaultDispatchAsync.class); Is there any way to do this with injection, I mean how to inject this DispatchAsync object into other classes where we need to use it. This is something related to @Inject annotation! ...

Injecting a static EJB, nonsense ?

Hello everyone, I want to write this piece of code : @Stateless public class MyEjb { @EJB private static MyOtherEjbWhichIWantStatic myOtherEjb; } It makes sense to me, that I want to inject an EJB in my class, as a static element, for various reason. Java is not very happy with that unfortunately com.sun.enterprise.contain...

A question about dependence and MVC on Cocoa

I'm a newbie in Cocoa developer, beside this I know well a lot of patterns. So far until now I understand that MVC have in mind avoid dependences between model, view and control. Well, I gave a look in some examples of controller and I found a behavior that apparently do not agree with that goal. Normally, in theses examples, I found a c...

Strategies for reverse engineering project that uses Guice?

I have tried to understand dependency injection and not quite gotten it, except I have managed to pick up the understanding that it makes it hard to understand somebody else's code. :'( Anyway, I'm not sure how to briefly describe my problem but I will try. I am currently the sole coder working on a Java project that's been worked on b...

Unity 2.0: How does it work?

Hello, I'm using Unity and would love to read a good explanation about its internal works - mostly how it builds up objects. I am aware of this nice MSDN article - Getting to Know the Unity Application Block, and it has a great drawing of the proccess, but I'm looking for a more technical and detailed explanation. Can anyone direct me...

Proper use of Windsor container inside ASP.Net / ASP.Net MvC

For a new project i am using the Windsor container to provide Dependency Injection (DI). DI should provide me with loose coupling and high testability. Since i am new to the subject of dependency injection i am having trouble wrapping my head around how to use it properly. This is what i learned for articles and googling: You should hav...

Observer pattern implementation using Spring dependency injection

I'm trying to develop an application where in the people will get notified if there is any change in the PartNumber. Its a Spring based application. Following is the code snippet. I've abstracted the storing mechanism here in SaveSubscriptionIF. The actual details of storing and retrieving are in the implementation class of this interfa...

Inversion of Control < Dependency Injection

I'm getting the feeling that there's is not such thing as inversion of control or rather the correct term is dependency injection. Am I wrong to assume this? I've been trying to define IoC for my own sake. In doing so I've learned a great deal about IoC containers and dependency injection. Just now, I read this from Martin Fowler's web...

log4Net, MVC, and dependency injection

I have an application with a few classic layers DAL, BLL, PL, and Unit Of Work. The goal is to log BL layer with MVC User info. In MVC presenter layer I made my own realization of DefaultControllerFactory for creating Service Locator. Here I register IBusinessLayer on BusinessLayerConcrete, and Controllers on themselves for their next...

What is the proper way to use Spring beans inside objects which are not managed by Spring container?

I have a Spring bean (singleton scope if it matters), lets call it FooService. And I have an object Bar which is not managed by Spring but it want to use FooService. How to implement this cooperation in the best way? (Let's assume that I don't like the solution with applicationContext.getBean()). ...

Ninject 2.0: Property Injection without attribute

Is there a way to use Property Injection in Ninject 2 without using the [Inject] attribute? This creates a dependency to Ninject in the class that will be wired using it and I prefer to avoid having unneeded dependencies to my IoC container, that's why I end up using Constructor Injection more often. I guess the same applies to Method I...

Generic interface VS generic method?

I'm writing a generic type to handle the underlying Active Directory objects such as groups, organisational units and users. I'm also using "manual" dependency injection within my generic interface. I would like to know if, in my situation, which is more appropriate: generic interface or generic method? Here's a simplified code sample ...

Adding information to my svcfile without a web-project?

I'm following this guide here: http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/09/16/integrating-structuremap-and-nhibernate-with-wcf.aspx And has now come to the end of it where i need to add : <%@ ServiceHost Language="C#" Debug="true" Service="Wcf.ComboService" Factory="Wcf.DIServiceHostFactory" %> to my svcfile, the p...

EJB3 beans deployment dependencies

I have a two Stateless EJB3 beans with bean1 depending on bean2. During deployment i get the error below 2010-07-13 12:30:43,480 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS): DEPLOYMENTS MISSING DEPENDENCIES: ...

Is dependency injection useful in the domain model when applying Domain driven design?

DDD Newbie question: I read in a blog somewhere that in a scenario where objects are closely associated with each other in a domain driven design, and where one object based on some complicated business rule is responsible for the creation of a dependent object, in such a design the usefulness of dependency injection is very limited. ...

Dependency injection: do we all need to know that?

One of my friend (he is a .NET/C++ developer, as I am) asked me: Dependency injection: do we all need to know that? Why? Could you please tell: Your opinion: do we really need to know that pattern and how to implement it? Good reference (link) that could explain "why?" Thank you a lot. P.S. I am understanding that I am asking ...

A problematic example of the IDisposable pattern?

Say you have 3 classes that implement IDisposable - A, B and C. Classes A and B are both dependent on class C. Would it be correct to say that classes A and B's typical implementation of Dispose() would be: public void Dispose() { if (m_C != null) m_C.Dispose(); } If there's an instance of A and and instance of B that share th...