You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by NJuk Njuk <nj...@gmail.com> on 2009/09/02 17:51:22 UTC

Re: [Digester] (solved) re-parsing digest file after modifications yields results prior to modification

i managed to solve this issue.  turns out it was user error (on my part).
as typical, i spent a bunch of time digging through the digester code to see
if there was some problem with the URL being cached---in fact, digester
takes this into account and appears to handle it by turning caching off and,
after parsing, cleaning up resources.  in the end, the problem was with the
digest file i was modifying.

i have a 'source' version and a 'distribution' version.  the latter is
copied from the 'source' version on startup and is the file that the
digester reads (and re-reads).  out of habit, i was modifying the 'source'
version.  when i realized this mistake, and switched to editing the
'distribution' version, the application worked as expected.

On Mon, Aug 24, 2009 at 3:10 PM, NJuk Njuk <nj...@gmail.com> wrote:

> i have an application that needs the ability to re-parse the same digest
> file multiple times.  each time the digest file will have been modified, so
> the resultant object should reflect these modifications.  the digest rules
> are defined via xmlrules.  these rules themselves do not change; the
> modification is only to the digest file.
>
> assume below digestRulesURL and digestURL are valid URLs (that never
> change) pointing to the appropriate files.  each time i setup a new digester
> instance and call parse() via the following...
>
> Digester aDigester = DigesterLoader.createDigester(digestRulesURL);
> aDigester.setNamespaceAware(true);
> aDigester.setXIncludeAware(true);
>
> SomeObject o = (SomeObject) aDigester.parse(digestURL);
>
> ...the results of parse() always reflect the first time it was called.
> that is to say, no matter how many times i change the digest file, create a
> new digester, and call parse (as above), the resulting object (though
> seemingly a new instance) has the same state as the original call to
> parse().
>
> i know from the Digester FAQ, that one should not reuse a digester object,
> which is why i am recreating each time.
> there appears to be some sort of caching or state that is maintained.  i
> peeked around the xmlrules DigesterLoader code and related, but not enough
> to see anything that would tip me off.
>
> any help would be appreciated.