You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by dv...@phpapp.org on 2003/03/14 18:18:09 UTC

[Fortress] Two lifestyle defaulting locations...

Hi all,

While adding to wiki, i noticed that there is two places in Fortress where
lifestyle is defaulted to PerThreadComponentHandler.

Here: (DefaultContainer)

<snip:snippet>
    public final void configure( final Configuration configuration )
        throws ConfigurationException
    {
<snip:shortcut/>

                final String handlerClassName =
                    components[ j ].getAttribute( "handler",
                                                 
org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler.class.getName() );

                addRole( shorthand, role, className, handlerClassName );
            }
        }
    }
</snip:snippet>

And here: (AbstractRoleManager)

<snip:snippet>
    protected void addRole( final String shortName,
                            final String role,
                            final String className,
                            final String handlerClassName )
    {
<snip:shortcut/>

        if( null != handlerClassName )
        {

<snip:shortcut/>

        }
        else
        {
            handlerKlass = guessHandlerFor( clazz );
        }

        final org.apache.avalon.fortress.RoleEntry entry = new
org.apache.avalon.fortress.RoleEntry( role, shortName, clazz, handlerKlass );
        m_shorthands.put( shortName, entry );
        m_classnames.put( className, entry );
    }

    protected Class guessHandlerFor( final Class clazz )
    {
        return
org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler.class;
    }
</snip:snippet>

I guess the guess...() method is to be overiden by people whishing to use marker
interface.

Actions i see that can be taken:
1) Add to the addRole() javadoc comment that the handler class can be null and
explain the defaulting mechanism. (i.e. guess...() method)

2) 1 + remove the defaulting in DefaultContainer

3) Add to the addRole() javadoc comment that the handler class cannot be null
and remove the guess code (the method and replace the else block by a throw) and
leave the defaulting in DefaultContainer.

I think 2) is better. I would be glad to send you a patch.

A+. Didier.

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