Thanks Simon for reply. It's really weird because the log trace seems to
properly instantiate my class:
74458 [main] DEBUG org.apache.commons.digester.Digester - New
match='TemplateMappingProcessor/MappingEntity'
74460 [main] DEBUG org.apache.commons.digester.Digester - Fire begin() for
FactoryCreateRule[className=null, attributeName=null,
[EMAIL PROTECTED]
74463 [main] DEBUG org.apache.commons.digester.Digester - [FactoryCreateRule]
{TemplateMappingProcessor/MappingEntity} New
com.infodesire.v20.templating.mappingprocessor.TemplateMappingEntity
but still when I call peek _immediately_ after the call to addFactoryCreate()
I do get not this object , but the object that was formerly added to the stack
via push() method.
Anymore hint ?
Thanks.
Marc
Am Dienstag, 6. Juli 2004 00:54 schrieb Simon Kitching:
> On Tue, 2004-07-06 at 04:50, Marc Lustig wrote:
> > Hi,
> >
> > I'm having trouble to use peek() to get the object from top of the stack.
> > I say
> > digester.push(this);
> >
> > Alright, peek() is returning the object from the stack properly.
> > Now I add another object to the stack:
> >
> > digester.addObjectCreate("pattern", TemplateMappingEntity.class);
> >
> > ... and now peek() is NOT giving me back an instance of
> > TemplateMappingEntity!
> >
> > WHY ? (of course the pattern exists)
>
> I don't know why you're not seeing the correct object. What you are
> describing seems to be the correct way to use the digester. And peek
> works fine - if it didn't, the Digester simply wouldn't work at all, and
> quite a lot of people would notice that :-)
>
> When exactly are you doing the peek? I hope you're aware that the object
> will be on the stack only between the start tag of the element specified
> by the pattern and the matching end tag.
>
> eg for
> digester.addObjectCreate("foo/bar", MyClass.class);
> and input
> <root>
> <foo>
> <bar>
> ...
> </bar>
> </foo>
> </root>
>
> the MyClass instance is created and pushed on the stack when <bar> is
> encountered in the input, and popped when </bar> is encountered. If you
> need to refer to the object after its end tag, you need to use
> SetNextRule to tell the parent object to store a reference to the
> object.
>
> > I tried also using a factory to add an object to the stack:
> >
> > digester.addFactoryCreate("pattern", new MappingEntityFactory());
> >
> > In this case as well peek() is NOT returning the instance that is
> > delivered by the createObject() method of my factory.
>
> It should.
>
> > What is wrong with the peek() method??
>
> There definitely isn't anything wrong with the peek method. There must
> be something odd in your code or environment, but I can't think what it
> might be.
>
> I suggest you enable debugging output for digester and have a look at
> the generated information. The simplest way to enable logging is to run
> java with:
> java \
> -D org.apache.commons.logging.Log=\
> org.apache.commons.logging.impl.SimpleLog \
> -D org.apache.commons.logging.simplelog.defaultlog=debug \
> .....
>
> Alternatives include putting log4j.jar in the classpath, and then also
> putting a log4j.xml or log4j.properties file in the classpath.
>
> Regards,
>
> Simon
>
>
> ---------------------------------------------------------------------
> 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]