Hi Richard,
We ran into the exact same problem.
One common solution you'll see on the net is to use a JNDI source to
configure your Data Source.
For example:
http://stackoverflow.com/questions/17441019/how-to-configure-jdbcrealm-to-obtain-its-datasource-from-jndi
However, in our environment we don't have JNDI and weren't going to set
it up just for Shiro. Instead we created a custom
ShiroDataSourceFactory that implements org.apache.shiro.util.Factory.
Inside the factory getInstance() method you can get configuration
details for any source and build a data source to return.
We already had a DataSource configured for our application (it reads a
properties file local to the system it is running on to find the correct
database for that server), so we retrieved that DataSource in our
factory method. Our DataSource implementation is
org.apache.tomcat.jdbc.pool.DataSource, so we can run under Tomcat with
connection pooling.
In the end, our ini file looks like this:
[main]
....
ds = com.hcs.data.dao.jdbc.util.ShiroDataSourceFactory
....
jdbcRealm.dataSource = $ds
Hope that helps!
Sincerely,
Stephen McCants
On 8/30/2013 4:32 PM, [email protected] wrote:
Hi.
I currently have a single shiro.ini file checked into source control. Some
of the parameters set in the file, however, such as the database connection
and keys, differ across different environments: production, Q/A, staging,
and production. As a result, I currently need to manually change the
shiro.ini file during deployments to each environment. This is error-prone
and reduces automation and scalability.
An alternative would be not to have shiro.ini checked into source control,
but stored locally in each environment. But then changes to the file would
still have to be manually carried across to each environment, with similar
problems. Since we are in active development, that can be often.
Is there a way to specify different environments for portions of the
shiro.ini file? (Somewhat like Maven?)
If not, what are recommended best practices that people use to handle this
situation?
Thanks for any advice!
--
View this message in context:
http://shiro-user.582556.n2.nabble.com/Best-practice-for-managing-different-shiro-ini-files-for-different-environment-tp7579099.html
Sent from the Shiro User mailing list archive at Nabble.com.
--
Stephen McCants
Senior Software Engineer
Healthcare Control Systems
1-877-877-8795 x116