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?

--~--~---------~--~----~------------~-------~--~----~
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