I don't think it's a really bad solution, I just read this page - http://code.google.com/p/google-guice/wiki/AvoidConditionalLogicInModules - and wanted to check there wasn't a better way to do this.
Cheers, rod. On 4 April 2010 14:33, Max Bowsher <[email protected]> wrote: > rod wrote: > > Hi, > > > > I'm sure this question must have been asked a million times but I > > can't find the answer... > > > > In my application the user can provide command line flags for various > > options, one being the type of database to use. So I have a bunch of > > implementations of my Database interface, and at the moment on startup > > I do... > > > > if ( dbType.equals("mysql") ) { > > // create mysql implementation > > } > > else if ( dbType.equals("other..") ) { > > // ... > > } > > else { > > // some other implementation... > > } > > > > The database class is then injected into components when needed. How > > is this handled with Guice? The only way I can see is to move this > > logic to my module like this... > > > > if ( dbType.equals("mysql") ) { > > bind( Database.class ).to( MySQLDatabase.class ); > > } > > > > Is there a better way? > > What's wrong with the method that you describe above that you seek to > improve upon? > > Max. > > -- "I backed my car into a cop car the other day. But he just drove on, sometimes life's ok." -- 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.
