eclipse-sisu / sisu-project

Sisu Inject
https://www.eclipse.org/sisu
Eclipse Public License 2.0
17 stars 15 forks source link

Binding different instances up-front with different parameters and common dependency (Bugzilla Bug 386440) #9

Open mcculls opened 2 years ago

mcculls commented 2 years ago

This issue was created automatically with bugzilla2github

Bugzilla Bug 386440

Date: 2012-08-01 18:50:16 -0400 From: Stuart McCulloch <mcculls@gmail.com> To: Project Inbox <sisu-inbox@eclipse.org>

See also: https://issues.sonatype.org/browse/SISU-64 Last updated: 2013-07-16 21:17:02 -0400

Comment 2144117

Date: 2012-08-01 18:50:16 -0400 From: Stuart McCulloch <mcculls@gmail.com>

Migrated from https://issues.sonatype.org/browse/SISU-64

I have a class like this:

@Inject public RemoteSolrServerQueryer( @SolrBaseUrl String solrBaseUrl, String solrCoreName, HttpClient httpClient )

RemoteSolrServerQueryer depends on component HttpClient which is available in the container, solrBaseUrl is a common configuration parameter.

I want to create 3 different RemoteSolrServerQueryer instances for which the only difference is solrBaseUrl.

For now I have to create a Factory or use assisted inject, what I really wish guice/sisu has is I can prepare these 3 instances in a Module because I know all the 3 solrCoreName value up front. Something like:

bind(Queryer).annotatedWith(Gav.class).to(RemoteSolrServerQueryer.class).with(solrCoreName="Gav");