pooling with Windsor

Posted by AlonEl on Stack Overflow See other posts from Stack Overflow or by AlonEl
Published on 2010-05-03T15:43:32Z Indexed on 2010/05/03 15:48 UTC
Read the original article Hit count: 400

Filed under:
|
|

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");
    }
}

© Stack Overflow or respective owner

Related posts about castle-windsor

Related posts about windsor