ApplicationContext: initializing with a list of files
Hello out there!
I've asked this before on the SourceForge list, but it seems to be pretty much dead. I'm completely new to Spring so I may be getting at this from an entirely wrong angle. Here's my app scenario. I'm keeping several XML files in WEB-INF/data. At startup, those files should each be digested into object hierarchies and registered with a manager objects.
I see more or less how I could define, in applicationContext.xml, a bean for each of the hierarchies that gets initialized through a factory method. Then I could set a property of the manager bean with the list of the hierarchy beans.
What I don't like about this, is that I'd have to explicitly, repetitively, and errorpronely define all the beans. I'd rather like to
have a declarative way to achieve my goal. Inspired by Ant it could
something like this
Code:
<bean id='manager'
class='....myapp.Manager'>
<call-method name='register'>
<mapper name='digest' class='....myapp.MyDigester'/>
<fileset dir='.../WEB-INF/data'>
<include name='*.xml'/>
</fileset>
</call-method>
</bean>
This is supposed to mean that
- * register is a method taking a single argument
* the arguments for repetitive calls are taken from a fileset
* before the argument objects are passed to register, they are transmogrified into appropriate object hierarchies by a call to the (static) method digest.
Of course, this is all very ad hoc and probably doesn't generalize well. I'm grateful for any suggestion.
Michael