You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anindya Bandyopadhyay <an...@gmail.com> on 2005/04/28 12:29:49 UTC

struts-config c

Hi All,

 I've developed one small application which will be used in different area 
using different database connection. I want to make properties file which 
will say all the value of *<data-source>* in *struts-config* and put the 
value in *struts-config* when tomcat starts and that's how we can get the 
right database connection every time. I'm looking for something like this:

 <data-sources>

<data-source type="org.apache.commons.dbcp.BasicDataSource">

<set-property property="driverClassName" value="$(DRIVERNAME)" />

<set-property property="url" value="$(URL)" />

 <set-property property="username" value="$(USERNAME)"/>

<set-property property="password" value="$(PASSWORD)"/>

</data-source>

</data-sources>
 And the properties file will hold all the variable values. Is there any way 
to achieve this?
 
Thanks in advance,

 Anindya

Re: struts-config c

Posted by Morris Jones <mo...@whiteoaks.com>.
Anindya Bandyopadhyay wrote:
>  I've developed one small application which will be used in different area 
> using different database connection. I want to make properties file which 
> will say all the value of *<data-source>* in *struts-config* and put the 
> value in *struts-config* when tomcat starts and that's how we can get the 
> right database connection every time. I'm looking for something like this:
[...]
> <set-property property="driverClassName" value="$(DRIVERNAME)" />

I do this in the Ant build by filtering the properties file when you 
build the .war file or copy to the webapps directory.

Here's an example from my build.xml:

     <!-- Copy any resource or configuration files -->
     <target name="resources">
         <filter token="TOMCATHOME" value="${tomcat.home}"/>
         <filter token="TESTHOST" value="${test.host}"/>
         <filter token="SOAPHOST" value="${soap.host}"/>
         <copy todir="WEB-INF/classes" includeEmptyDirs="no" 
filtering="true">
             <fileset dir="WEB-INF/src">
             <patternset>
                 <include name="**/*.conf"/>
                 <include name="**/*.properties"/>
                 <include name="**/*.xml"/>
             </patternset>
             </fileset>
         </copy>
     </target>

And in the properties file:

# Host name part of SOAP server URL
soap.server:@SOAPHOST@

etc.

Mojo
-- 
Morris Jones
Monrovia, CA
http://www.whiteoaks.com
Old Town Astronomers: http://www.otastro.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org