Questions tagged [ioc-container]

In object oriented languages, an inversion of control container (ioc-container) can be used for configuring and managing objects in an application.

In object oriented languages, an inversion of control container (ioc-container) can be used for configuring and managing objects in an application. The container is responsible for managing object lifecycles (creation, initialization, destruction) and configures objects by wiring them together.

Objects managed by the container obtain references to other objects (their dependencies):

  • by explicitly asking the container, using dependency lookup methods on the container
  • automatically, because the container injects the dependencies using one or more dependency injection techniques

Frameworks that provide an ioc-container support one of these methods and often both.

The following frameworks are discussed here at Stackoverflow

For .NET:

For Java:

2163 questions
1
vote
1 answer

Good or bad Unity design: Injecting the complete container or only explicit Interfaces?

This is a bad or good design question. I find it extreme convenient to always inject the complete Unity container in my modules. 1.) You never know, what resources you will need. 2.) The class constructor never needs to be changed, if you need…
Michael
  • 938
  • 1
  • 10
  • 34
1
vote
1 answer

How to use Unity in order to implement a simple component publishing engine

In our project we have implemented a simple facility to let one party publish dynamic components and yet others - to consume them. I would like to phase out our in-house implementation and take something ready off the shelf. Since our UI guys…
mark
  • 59,016
  • 79
  • 296
  • 580
1
vote
1 answer

Any DI Container where Transient is truly Transient during a nested/child container?

I have a requirement were I need some instances of my domain to remain the same during a scope of my choosing. These instances are an exception and the norm should be that all instances are new each time they are requested by the domain. (The way…
Anders
  • 17,306
  • 10
  • 76
  • 144
1
vote
0 answers

Should Dependencies Be Referenced By Interface Only?

I have been working on transitioning from procedural -> oop for a few months now. I decided to avoid jumping right into a framework. I didn't want to rely on the behind the scenes magic, so during my spare time i decided to convert an old project…
ICJ
  • 83
  • 6
1
vote
1 answer

Resolving different instances using unity container with multiple dependancies

I wanna resolve different instances with the same interface. I read something about named registrations which should probably push me in the right direction except I can't seem to fit them in a hierarchy structure. public interface…
Luuk Krijnen
  • 1,180
  • 3
  • 14
  • 37
1
vote
0 answers

Mockery "shouldReceive()->once()" throwing "called exactly 1 times" error

I am about $this->close() to giving up on Mockery in my unit tests. Here's what's going on, I am working with Laravel 5.1 and I'm trying to test my repository pattern abstraction using Mockery in PHPUnit. I've followed the tutorials, poured over the…
SacWebDeveloper
  • 2,563
  • 2
  • 18
  • 15
1
vote
1 answer

Inject different implementations into same interface then pick up right implementation in right project / assembly

We have 2 OpenLdap servers. One is the latest out of the box version. The other one is an older heavily customized version. Both implementations really follows a similar logic. Take the connection for example. Here is the interface namespace…
Shane van Wyk
  • 1,870
  • 1
  • 26
  • 62
1
vote
0 answers

Why castle.windsor injecting dll more than once

I'm using castle.windsor version 3.3 for .net 3.5. I have a weird issue, It seems my app loads dll more than once. i'm loading the assembly with: WindsorContainer().Install(FromAssembly.Named([AssemblyName]); When I check the container's nodes…
user4781762
1
vote
2 answers

Unity 2.0: How does it work?

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…
Dor Rotman
  • 1,511
  • 1
  • 15
  • 27
1
vote
1 answer

IoC container does not inject the new concrete class in app/models that extends src/models in composer package

I have an eloquent model Post in my package rowland/laravelblog which uses the repository pattern . It has some default implementations , but I want the user of my package to extend this model Post in his own application. However, since am using…
Otieno Rowland
  • 2,182
  • 1
  • 26
  • 34
1
vote
1 answer

Laravel Service Provider bypassed

I have the following Class: secretKey = 'abc'; $this->publicKey = '123'; } …
1
vote
1 answer

spring IOC, can I drop a .jar that adheres to an interface and modify the app-config.xml?

Say I have a database layer, with DTO's for each table, and a factory that returns the DTO's for each table. As long as I build to interfaces, I can re-implement the db layer and then just change my app-config.xml to use another implementation. Now,…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
1
vote
1 answer

Register Multiple Interface Implementation In LightInject IoC

I have an interface with two implementations. public interface ILogger { void Log(string message); } public class FileLogger : ILogger { public void Log(string message) {} } public class SQLiteLogger : ILogger { public void Log(string…
Ask Too Much
  • 627
  • 4
  • 19
1
vote
0 answers

Implementing Container Per Request pattern

I'm going to add in the necessary infrastructure to bind each request to its own nested container, So in this case having a Container Per Request gives us a unique session (Context Per Request), In my code I'm using the new implementation of…
Sirwan Afifi
  • 10,654
  • 14
  • 63
  • 110