pooling with Windsor
- by AlonEl
I've tried out the pooling lifestyle with Windsor.
Lets say I want multiple CustomerTasks to work with a pool of ILogger's.
when i try resolving more times than maxPoolSize, new loggers keeps getting created.
what am i missing and what exactly is the meaning of min and max pool size?
the xml configuration i use is (demo code):
<component id="customertasks" type="WindsorTest.CustomerTasks, WindsorTestCheck" lifestyle="transient" />
<component id="logger.console" service="WindsorTest.ILogger, WindsorTestCheck" type="WindsorTest.ConsoleLogger, WindsorTestCheck" lifestyle="pooled" initialPoolSize="2" maxPoolSize="5" />
Code is:
public interface ILogger
{
void Log(string message);
}
public class ConsoleLogger : ILogger
{
private static int count = 0;
public ConsoleLogger()
{
Console.WriteLine("Hello from constructor number:" + count);
count++;
}
public void Log(string message)
{
Console.WriteLine(message);
}
}
public class CustomerTasks
{
private readonly ILogger logger;
public CustomerTasks(ILogger logger)
{
this.logger = logger;
}
public void SaveCustomer()
{
logger.Log("Saved customer");
}
}