commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Kudła <adamku...@gmail.com>
Subject [digester] ofTypeSpecifiedByAttribute doesnt work
Date Thu, 02 Feb 2012 03:12:53 GMT
Hi,

tonight I have spent 5 hours working over one bug in my app.

Unfortunately I digged to some place of code where I think I found a
bug in Digester

It is in: org.apache.commons.digester3.ObjectCreateRule

I think this part of code:
@Override
    public void begin( String namespace, String name, Attributes attributes )
        throws Exception
    {
        Class<?> clazz = this.clazz;

        if ( clazz == null )
        {
            // Identify the name of the class to instantiate
            String realClassName = className;
            if ( attributeName != null )
            {
                String value = attributes.getValue( attributeName );
                if ( value != null )
                {
                    realClassName = value;
                }
            }
            if ( getDigester().getLogger().isDebugEnabled() )
            {
                getDigester().getLogger().debug( format(
"[ObjectCreateRule]{%s} New '%s'",

getDigester().getMatch(),
                                                         realClassName ) );
            }

            // Instantiate the new object and push it on the context stack
            clazz = getDigester().getClassLoader().loadClass( realClassName );
        }

doesn't work in that way I want.

When I have specified this rule:
forPattern("neuralNetwork/layers/layer/neuron/activationFunction").createObject()
           .ofType(DefaultActivationFunction.class).ofTypeSpecifiedByAttribute("typeName").then().setProperties().then().setNext("setActivationFunction");

and having this XML:
<activationFunction type="org.kobrys.LinearActivationFunction" a="1" b="0"/>

and of course LinearActivationFunction is a subclass of
DefaultActivationFunction...

When is used method ofType(...) - it is set this.clazz which
automaticaly distable acces in the 'if' part of code body.



This code works but allways returns DefaultActivationFunction. Inside
ObjectCreateRule instance attributeName is not null so it looks like
if statement is some kind of wrong.

Am I doing something wrong? Or is it a bug?


Thanks
-- 
Adam Kudła
adamkudla@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message