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.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to