dependency-injection

Using StructureMap to create classes by a name?

How can I use StructureMap to resolve to an appropriate implementation of an interface based on a name stored in an attribute? In my project, I have many different kinds of widgets, each descending from IWidget, and each decorated with an attribute specifying the kind of associated element. To illustrate: [Configuration("header")] pub...

Best practices to build a highly configurable software product.

Hello. I am working on a software product that can substantially change behavior based on the configuration & meta-data supplied. I would like to know best practices to architect / build a highly configurable software product. Considering that there are substantial number of configuration parameters, I'd like to look at something that w...

Unity The parameter host could not be resolved when attempting to call constructor

When I attempt to instantiate my instance of the base class I get the error: a ResolutionFailedException with roughly the following error "The parameter host could not be resolved when attempting to call constructor" I'm currently not using an Interface for the base type and my instance of the class is inheriting the base type class. ...

How would one do dependency injection in scala?

I'm still at the beginning in learning scala in addition to java and i didn't get it how is one supposed to do DI there? can or should i use an existing DI library, should it be done manually or is there another way? ...

Spring.net is not injecting chained base class properties!

I am successfully injecting base class properties with spring.net with just a class that inherits from a base abstract class. Lets say Class MyClass : MyBase, and I am successfully setting a property like this: <object id="myInstantiableClass" type="myAssembly.MyClass myAssenbly" abstract="true"> <property name="MyBaseClassProperty"...

SPRING: What is AOP, Dependency Injection and Inversion Of Control in Simple English

I have tried to understand AOP, Dependency Injection and Inversion of Control SPRING related concepts but I am having hard time understanding it. Can anyone explain this in simple English ? ...

Real website/-application use cases where dependency injection was useful (excluding unit testing/mocks)?

In what concrete web project(s) (you don't have to name them by name of course), specifically what part of the web-application/website, that you have worked on, has dependency injection proven to be a good choice. Can you give concrete examples where you actually substituted one component for another with DI during the life span of the p...

Dependency Injection for objects that require parameters

All of our reports are created from object graphs that are translated from our domain objects. To enable this, we have a Translator class for each report, and have been using Dependency Injection for passing in dependencies. This worked great, and would yield nice classes structured like this: public class CheckTranslator : ICheckTr...

Testing system where App-level and Request-level IoC containers exist

My team is in the process of developing a system where we're using Unity as our IoC container; and to provide NHibernate ISessions (Units of work) over each HTTP Request, we're using Unity's ChildContainer feature to create a child container for each request, and sticking the ISession in there. We arrived at this approach after trying o...

Correctly use dependency injection

Me and two other colleagues are trying to understand how to best design a program. For example, I have an interface ISoda and multiple classes that implement that interface like Coke, Pepsi, DrPepper, etc.... My colleague is saying that it's best to put these items into a database like a key/value pair. For example: Key | Name...

Dependency Injection mechanism

The advantage of inversion of control is that it decouples objects from specific lookup mechanisms and implementations of the objects it depends on. As a result, more flexibility is obtained for production applications as well as for testing. what does it mean actually ? ...

Spring Transitive Dependency Injection

if I inject a recursive dependency through a constructor, then it gives me an exception, while if I use setter it doesn't. Why is this? ...

Why JPA injection not works on @PersistentUnit

Hello colleagues! It is continues of question ( http://stackoverflow.com/questions/2570976/struts-2-bean-is-not-created ) I'm using struts2 + toplink in my very simple web application under Tomcat. On the page I would like use iteration tag. That is why I've declared some factory (SomeFactory) that resolves collection of entities (Enti...

Dependency Injection with @Inject in Weld (JSR-299 RI). How is the corresponding @Produces found?

I have played with the JSR-299 Reference Implementation "Weld" with the purpose of using it in a stand-alone application, and I have had a look at the documentation, and marveled at the magic. My question is how the producer of a given object to be @Inject'ed is found? Either the java compiler produces hints for annotations which is ea...

Decoupling the view, presentation and ASP.NET Web Forms

I have an ASP.NET Web Forms page which the presenter needs to populate with controls. This interaction is somewhat sensitive to the page-life cycle and I was wondering if there's a trick to it, that I don't know about. I wanna be practical about the whole thing but not compromise testability. Currently I have this: public interface IS...

How do app servers inject into private fields?

I saw this question http://stackoverflow.com/questions/2021716/inject-into-private-package-or-public-field-or-provide-a-setter about how to manually inject into annotated private fields (The way is adding setters or through a constructor) But, the point is how do an application server (like glassfish, axis2, jboss, ...) is able to inj...

Injecting generics with Guice

I am trying to migrate a small project, replacing some factories with Guice (it is my first Guice trial). However, I am stuck when trying to inject generics. I managed to extract a small toy example with two classes and a module: import com.google.inject.Inject; public class Console<T> { private final StringOutput<T> out; @Inject ...

Ninject: Singleton binding syntax?

I'm using Ninject 2.0 for the .Net 3.5 framework. I'm having difficulty with singleton binding. I have a class UserInputReader which implements IInputReader. I only want one instance of this class to ever be created. public class MasterEngineModule : NinjectModule { public override void Load() { // usin...

XNA and Ninject: Syntax for dependency arguments?

I have a class with a public constructor: public MasterEngine(IInputReader inputReader) { this.inputReader = inputReader; graphicsDeviceManager = new GraphicsDeviceManager(this); Components.Add(new GamerServicesComponent(this)); } How can I inject dependencies like graphicsDeviceManager and new Gam...

How to use Ninject with XNA?

I'm having difficulty integrating Ninject with XNA. static class Program { /** * The main entry point for the application. */ static void Main(string[] args) { IKernel kernel = new StandardKernel(NinjectModuleManager.GetModules()); CachedContentLoader content = kernel.Get<CachedContentLoader>(); //...