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? > Thanks Andrew! This worked perfectly. I owe you one. Truthfully, I think this concept of using a Module to instantiate more than one of the same type of object should be emphasized more in the docs, or maybe in the wiki. I guess if you think of the Module somewhat analogous to what you do with spring's xml file it starts to click with me. For the most part I want to use annotations etc, but when you need more fine grained control a Module could/would be the place to go next? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
