I'v settled with some sort of "super" factory. Im not completely satisfied 
(as it looks as a work-around to me) but it does the job. Implementing my 
own "new" logic in the HttpClientFactory has the side affect that my 
HttpClient objects arn't managed by Guice, I don't want that. What I came 
up with:

    public interface ConnectionFactory {
    public Connection create(String host, int port);
    }

    public interface HttpClientFactory {
        public HttpClient create(Connection connection);
    }

    public interface HttpClientProvider {
    public HttpClient create(String host, int port);
    }
    
    public class HttpClientProviderImpl {
    private final ConnectionFactory connectionFactory;
    private final HttpClientFactory httpClientFacotry;

    @Inject
    public HttpClientProvider(...) {}

    public HttpClient create(String host, int port) {
    Connection conn = connectionFactory.create(host, port);
    HttpClient client = httpClientFactory.create(conn);
    return client;
    }
    }

This way my HttpClient and Connection only depend on the stuff they need to 
(in my opinion) depend on and all objects are still managed by Guice 
alowing me to configure other injects.

Any comments about this, besides the fact that I have basically two 
HttpClient factories? Are their better solutions?

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to