[Fortress] Two lifestyle defaulting locations...

[email protected]
Newsgroups gmane.comp.jakarta.avalon.phoenix.devel
Message-ID <1047662289.3e720ed1eb7d6__36968.17873647$1047662358@www.nexenservices.com>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.