2009/8/24 Rick <[email protected]> > On Mon, Aug 24, 2009 at 8:12 AM, Max Bowsher <[email protected]> wrote: > >> >> What you're doing above seems reasonable to me - you'll need to >> elaborate on "doesn't seem to work" to get help. >> > > Thanks Max for your comments... > > As far as "not working" what I end up with is "sqlSession" never being > bound. Code to illustrate:: > > For example this DOES work fine: > > //SqlSessionProvider modified with default constructor (resource file > hardcoded in Provider) > > //Module: > bind(SqlSession.class).toProvider(SqlSessionProvider.class); > > //Implementation - WORKS > @Inject > public void setSqlSession(SqlSession sqlSession) { > System.out.println("!!!!!! MyDbIbatisDao setSqlSession"); > this.sqlSession = sqlSession; > } > > ------------------ > This ends up with sqlSession never being bound: > > //SqlSessionProvider modified has constructor, takes resource file name > > //Module: > SqlSessionProvider myDbProvider = new > SqlSessionProvider("mydb-ibatis-config.xml"); > > bind(SqlSession.class).annotatedWith(Names.named("MyDB")).toProvider(myDbProvider); > > //Implementation - NEVER CALLED > @Inject > public void setSqlSession(@Named("MyDB") SqlSession sqlSession) { > System.out.println("!!!!!! MyDbIbatisDao setSqlSession"); > this.sqlSession = sqlSession; > } > > In this later case, I never see "setSqlSession" called (and obviously my > Provider get thus never called either.) > Am I declaring my setter incorrectly with the named annotation? I've even > tried with field injection and no luck either. > > @Inject @Named("MyDB") > protected SqlSession sqlSession; >
probably a silly question, but that annotation is com.google.inject.name.Named right? > -- Cheers, Stuart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
