Actually I don't think my annotatedWith is even working for these Providers:( - I forgot to remove an older binding that was binding my Provider to SqlSessionFactory without the annotatedWith.
On Sat, Aug 22, 2009 at 6:02 PM, Rick<[email protected]> wrote: > I'm new to Guice so I'm probably missing the best approach. I have a > Provider that needs to by initialized differently depending on a > config file that it is passed. > > I'm currently doing it like this in my Module: > > SqlSessionFactoryProvider myDbProvider = new > SqlSessionFactoryProvider("db1-ibatis-config.xml"); > bind(SqlSessionFactory.class).annotatedWith(Names.named("DB_1")) > .toProvider(myDbProvider); > > SqlSessionFactoryProvider myDbProvider = new > SqlSessionFactoryProvider("db2-ibatis-config.xml"); > bind(SqlSessionFactory.class).annotatedWith(Names.named("DB_2")) > .toProvider(myDbProvider); > > > I then initialize some BaseDAOs with... > > > �...@inject > public void setSqlSessionFactory(@Named("DB_1") SqlSessionFactory > sqlSessionFactory) { > > Is this an ok approach or is there a better way to initialize a Provider? > -- Rick R --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
