Hi Jim,
I think you can achieve this by defining a class with a property which is then set in the application descriptor. You can then run the method on startup by using init-method.
A little example from my SpringXMLDB code
Code:
<bean id="uploadProcessor" class="com.lakeside.springxmldb.processor.XMLDBAutoLoader" depends-on="xmldatabase" init-method="init">
<property name="xmldbManageDao"><ref bean="xmlManageXMLDBDao"/></property>
<property name="collectionManageDao"><ref bean="collectionManageXMLDBDao"/></property>
<property name="initDirectory"><value>/WEB-INF/resources/content</value></property>
<property name="collection"><value>/db/tilesnews/items</value></property>
</bean>
Code:
public class XMLDBAutoLoader extends XMLDBUploaderProcessor {
protected Resource initDirectory;
protected String collection ="/db";
/**
* @param initDirectory The initDirectory to set.
*/
public void setInitDirectory(Resource initDirectory) {
this.initDirectory = initDirectory;
}
/**
* @param collection The collection to set.
*/
public void setCollection(String collection) {
this.collection = collection;
}
/**
* run the upload directory and recursively upload the directory resource
* specified to the xml database
* @throws IOException if the resource cannot be found
*/
public void init() throws IOException {
if (initDirectory.exists()) {
//load the initial directory
this.uploadDirectory(initDirectory.getFile(), collection, true);
}
else {
throw new IOException("resource can not be found at " + initDirectory);
}
}
}
When the application context is started up this will cause init-method to run and load the file specified in the resource which will be loaded from the WAR.
The init-method is used to run methods after properties have been set and the context is loaded.
Alternatievely u could move all the properties from your properties files to
the XML applicationContext.xml and specify in XML with
Code:
<property name="mappings">
<props>
<prop key="key1">propvalue</prop>
<prop key="key2">propvalue</prop>
<prop key="key3">propvalue</prop>
</props>
</property>