Hi Axelle,

did you read the samples of MyBatis-Guice? I honestly don't understand
why you have to map the configuration in a custom DOM when you could
use directly the bound properties.

Have a look at how a basic sample[1] works and stop feeling pain. Just
use Names.bindProperties and load your JDBC configs. Use a build
profile if you need to include different configs depending on the
environment you are deploying the application.

HTH,
-Simo

[1] 
http://code.google.com/p/mybatis/source/browse/sub-projects/mybatis-guice/trunk/src/test/java/org/mybatis/guice/sample/SampleBasicTest.java

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/



On Mon, Mar 12, 2012 at 5:55 PM, Axelle Ziegler
<[email protected]> wrote:
> Hello,
>
>  Is there any way to use an injected Properties object as an argument
> to Names.bindProperties ?
>
>  Basically our configuration files are injected in a module and we
> need to retrieve them in another module to configure our database
> provider. However, MyBatis-Guice uses Named properties so it means we
> have to create bindings using the content of the Properties object.
>
>  Currently we add a provider for each properties as follow :
>
>    @Provides
>    @Named( "JDBC.username" )
>    String username( @AccountDatabaseProperties final Properties
> databaseConfiguration ) {
>        return databaseConfiguration.getProperty( "JDBC.username" );
>    }
>
> but that means we have to add one such line for each new property
> name. We could of course simply hold a static list of the property
> names to avoid code duplication, but it would be much more efficient
> to use Names.bindProperties to perform this work, however it seems to
> mean we have to load our properties file in the database configuration
> module. Does anyone see a possible workaround ? Am I missing
> something ?
>
> Thanks in advance,
>
> --
> 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.
>

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