Hi Axelle, you can still use both approaches, they are not mutable exclusive: if you bind configurations via Names.bindProperties and annotate your DOM with @Named, then request inject the DOM object were needed AND build the JDBC connection using the MyBatis integration module.
HTH, all the best, -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Tue, Mar 13, 2012 at 1:39 PM, Axelle Ziegler <[email protected]> wrote: > Yes I did read the samples, and we have a working setup using it, > it just forces us to adopt a specific build and implementation pattern > for our database configuration files. > We inject the configuration files as custom DOM in all of our app > because various configuration files are used across different parts of > our application. So we could always switch back to the default mode, > but I'd rather explore other options first :) > > Thanks a lot, > > Axelle > > On Tue, Mar 13, 2012 at 1:26 PM, Simone Tripodi > <[email protected]> wrote: >> 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. >> > > -- > 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.
