ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kief Morris <>
Subject ChainableReader behavior
Date Fri, 31 Jan 2003 14:51:53 GMT
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 
(, 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}" 
            <fileset dir="${http_templates_dir}" includes="**/*"/>
            <velocityProperty type="engine" key="runtime.log" value="${runtime.log}"/>

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.)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message