I'm finding this so frustrating. DI is supposed to make my job easier, and I'm wasting way too much time on this and I have way tooo much code, when I consider how simple this is without Guice... therefor I must be missing something really simple, so I'm posting here for some help.
The bottom line is I want to different abstract daos injected with different versions of an ibatis called SqlMapClient. The SqlMapClient needs to be loaded from a config file that it finds on the classpath. This should be simple (since without DI, it's cake, I just have a static block in each type of main dao that loads the SqlMapClient.) So far here is what I'm trying and it seems way overkill... http://pastie.org/360247 Besides the fact that I'm getting an error as shown here http://pastie.org/360249 due to the annotation binding (if I remove the annotation things are ok, for at least one dao) But overall my question is that there must be a more simple way to set this up. I shouldn't need two or more concrete Provider classes that do identical things.. the only difference is the configuration name. In Spring I'd simply declare my SqlMapClient twice with a different id for each and then use the appropriate id for each bean definition I declared. It seemed a lot easier, so I'm probably missing something simple here, since overall I was finding Guice to involve less configuration than Spring. I basically want to say "For this class Foo when you inject TypeA make sure TypeA refers to this configuration when it's instantiated. When class Bar is instantiated and you inject TypeA make sure TypeA refers to a different configuration when it's instantiated." The initial paste here http://pastie.org/360247 should make it sort of clear with what I was attempting. Another thing is also a red flag I'm doing something wrong. In java if you loo at that paste you'll see I'm pushing down setSqlMapClient into the main subclasses of BaseDAO, only for the sole purpose of being able to provide an annotation to help with guice. I shouldn't need to do this. I should be able to keep the setSqlMapClient in the BaseDAO class, but if I did that I was having no way to say "use this version of the SqlMapClient" for your argument in setSqlMapClient." What am I doing wrong? Thanks for any help. I'm so frustrated because all of this time I've been spending trying to figure out just how to set all this up when it's so simple in 'plain java.' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
