I have read a bit about DI and DI containers that manage the DI for you.
Basically you create your classes that have dependencies, and provide a way for injection using the constructor or setter methods. You then tell your DI container, which concrete classes you want to use for wiring everything together. Lastly you make a call to some kind of service locator, that resolves all the dependencies for you and gives you the complex object with just one line of code.
I have never used a concrete DI container implementation, so i wonder how a DI container handles the objects at the lowest level. These objects most likely have to be configured using concrete (coded) values, or the content of a configuration file. Take this for example:
class FooDao {
public FooDao(DBConnection db) {...}
}
class ConcreteDBConnection : DBConnection {
public ConcreteDBConnection(String url, int port, String user, String pw)
{...}
}
You would tell your DI container (using annotations, XML files, or something else), that you want to instantiate your FooDao objects with a ConcreteDBConnection object. But how do you tell your DI container the concrete values needed for your database connection? What if the concrete values need to be calculated first (encrypting locally stored database connection information for example)?
I know this is a very general question, but the articles i read about DI container were also very general and this point really confused me. A short explanation how a arbitrary popular DI framework does this would be enough to answer my question.