> From: Kief Morris [mailto:[EMAIL PROTECTED]] > I'm trying to figure out the behavior of ChainableReader implementations > under copy type tasks. In particular, it seems that the Reader has its > initialize() method called for each file being copied, which is leading > to some deeper problems. Is this the correct behavior?Kief,
Kief, Ouch, this is not the way that I thought filterchains were created, but it appears that so. I thought that each filter in a chain was first created, then initialized, just once for a given task. But in fact, it looks like the entire chain is created, initialized and then discarded for each file processed, which for VPP, incurs a lot of overhead. Anyone, Is there anyway that the filterchain can be reused within a task? didge > -----Original Message----- > From: Kief Morris [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 31, 2003 6:52 AM > To: [EMAIL PROTECTED] > Subject: ChainableReader behavior > > > I'm trying to figure out the behavior of ChainableReader implementations > under copy type tasks. In particular, it seems that the Reader has its > initialize() method called for each file being copied, which is leading > to some deeper problems. Is this the correct behavior? > > Background: I'm using a custom task I found on Sourceforge called VPP > (http://vpp.sourceforge.net/), which implements a copy operation that > calls Velocity to process each file copied. There is a <vpp> task which > is implemented with a class called VPP that extends the Copy task, and > another named VPPFilter which extends BaseParamFilterReader and > implements ChainableReader. > > I run a build with this in my build.xml: > > <vpp todir="${build_dir_http}" > overwrite="true"> > <fileset dir="${http_templates_dir}" includes="**/*"/> > <velocityProperty type="engine" key="runtime.log" > value="${runtime.log}"/> > </vpp> > > The problem is that on each file copy, a new instance of VPPFilter is > created. FileUtils.copyFile() calls > ChainFilterHelper.getAssembledReader(), > which creates a new instance of each ChainableReader. The way VPPFilter > is written, it creates a new instance of the Velocity parser each > time, which > is wasteful. I actually get an additional problem (the symptom > which led me > to investigate this) which is that the second instantiation of > Velocity tries to > write to the logger created by the first instantiation, after > it's closed. Obviously > that's not an Ant issue, but it points to the fact that Velocity > is being recreated > for each file, which is a waste. > > So I guess my ultimate question is, where should Velocity be instantiated > so it only gets created once for the particular <vpp> task? I haven't been > able to find decent documentation on how ChainableReader is supposed to > work. Reading the source helps to figure out what is actually > going on, but > is of limited usefulness as a guide to designing an extension. > > A sub-question, does anyone know of other implementations of this concept, > i.e. tasks which use Velocity in the same way that copy works, as opposed > to the way texen works (texen doesn't leverage ant to specify templates to > parse, create output directory structures, etc.) > > Thanks, > Kief > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
