On Wed, Jan 14, 2009 at 11:02 AM, Andrew Clegg <[email protected]>wrote:

>
> 2009/1/14 Rick <[email protected]>:
>
> > The problem(?) is that SqlMapClient.class is an object I don't have
> control
> > of it's an iBATIS class that just needs a config file sent to it.
> Different
> > DAOs I use (just two for instance) need a different load of that
> > SqlMapClient class. That's waht the provider was doing was loading up the
> > SqlMapClient with info from a config file.
> >
> > So in your example above I can't really make instances of SqlMapClient.
>
> I'm still not sure I follow. Can't you do something like this inside a
> Guice module class:
>
> Reader reader = Resources.getResourceAsReader("ibatis.guiConfigXML");
> sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
> reader.close();
> bind(SqlMapClient.class).annotatedWith(Gui.class).toInstance(sqlMapClient);
>
> and then the same for the other instance of SqlMapClient?
>
> I don't think this is quite the same as the robot legs problem...
>
> Apologies if I'm missing something obvious, I've only been using Guice
> for a couple of months myself.
>
>

I see, use a Module class instead of a Provider? I never thought of that.
That's where I was getting stumped - "where to do that work that initializes
the sqlMapClient instance that I'll need."  I didn't think Modules were for
that sort of thing, but it looks pretty clean. I'm going to try that and
I'll post back how it works. Thanks a lot Andrew.

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

Reply via email to