Ted Husted
06-20-2005, 04:01 PM
Is anyone else using Spring on a project that
* Deploys web and non-web projects (i.e. unit tests)
* Uses multiple configuration files
The import statement is working well enough for the multiple files, but how can we use the same configuration file, including relative paths, in web and non-web projects?
We setup up a root import file, that includes the others:
<object id="Base" />
<import resource="Resources/Command/AppBase.xml"/>
<import resource="Resources/Command/AppConfig.xml"/>
<import resource="Resources/Command/AppFields.xml"/>
<import resource="Resources/Command/cmdCounty.xml"/>
<import resource="Resources/Command/cmdEvent.xml"/>
<import resource="Resources/Command/cmdFacility.xml"/>
<import resource="Resources/Command/cmdInfraction.xml"/>
<import resource="Resources/Command/cmdLog.xml"/>
<import resource="Resources/Command/cmdMandate.xml"/>
<import resource="Resources/Command/cmdMeetingReport.xml"/>
<import resource="Resources/Command/cmdProgram.xml"/>
<import resource="Resources/Command/cmdRegion.xml"/>
<import resource="Resources/Command/cmdStaff.xml"/>
<import resource="Resources/Command/cmdStatus.xml"/>
<import resource="Resources/Command/cmdStep.xml"/>
<import resource="Resources/Command/cmdTicket.xml"/>
<import resource="Resources/Command/cmdTypes.xml"/>
that we can share verbatim between web and non-web projects, but only if we use a custom singleton to load the non-web projects. The singleton includes some "kludge" code we borrowed from an early version of iBATIS:
private static string _rootDirectory =
AppDomain.CurrentDomain.BaseDirectory.Replace (@"\bin", "").Replace (@"\Debug", "").Replace (@"\Release", "");
This provides us with a consistent root reference that we can prepend to the file:
string foo = "file://" + _rootDirectory + FILE;
For iBATIS, we've since decided that this is too kludgy. Now, the practice is to use runtime properties to set the root for each project. We can then sete the root in one file
root="."
or
root ="../.."
and then maintain a consistent reference in the configuration:
<import resource="${root}/Resources/Command/cmdTypes.xml"/>
Has anyone found another way to accomplish the goal of keeping identical, multiple object configuration files for non-web and web projects?
-Ted.
* Deploys web and non-web projects (i.e. unit tests)
* Uses multiple configuration files
The import statement is working well enough for the multiple files, but how can we use the same configuration file, including relative paths, in web and non-web projects?
We setup up a root import file, that includes the others:
<object id="Base" />
<import resource="Resources/Command/AppBase.xml"/>
<import resource="Resources/Command/AppConfig.xml"/>
<import resource="Resources/Command/AppFields.xml"/>
<import resource="Resources/Command/cmdCounty.xml"/>
<import resource="Resources/Command/cmdEvent.xml"/>
<import resource="Resources/Command/cmdFacility.xml"/>
<import resource="Resources/Command/cmdInfraction.xml"/>
<import resource="Resources/Command/cmdLog.xml"/>
<import resource="Resources/Command/cmdMandate.xml"/>
<import resource="Resources/Command/cmdMeetingReport.xml"/>
<import resource="Resources/Command/cmdProgram.xml"/>
<import resource="Resources/Command/cmdRegion.xml"/>
<import resource="Resources/Command/cmdStaff.xml"/>
<import resource="Resources/Command/cmdStatus.xml"/>
<import resource="Resources/Command/cmdStep.xml"/>
<import resource="Resources/Command/cmdTicket.xml"/>
<import resource="Resources/Command/cmdTypes.xml"/>
that we can share verbatim between web and non-web projects, but only if we use a custom singleton to load the non-web projects. The singleton includes some "kludge" code we borrowed from an early version of iBATIS:
private static string _rootDirectory =
AppDomain.CurrentDomain.BaseDirectory.Replace (@"\bin", "").Replace (@"\Debug", "").Replace (@"\Release", "");
This provides us with a consistent root reference that we can prepend to the file:
string foo = "file://" + _rootDirectory + FILE;
For iBATIS, we've since decided that this is too kludgy. Now, the practice is to use runtime properties to set the root for each project. We can then sete the root in one file
root="."
or
root ="../.."
and then maintain a consistent reference in the configuration:
<import resource="${root}/Resources/Command/cmdTypes.xml"/>
Has anyone found another way to accomplish the goal of keeping identical, multiple object configuration files for non-web and web projects?
-Ted.