You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Berin Loritsch <bl...@apache.org> on 2001/10/02 18:42:01 UTC

[VOTE] DefaultContext mod

Currently, Avalon Framework identifies a Resolvable interface
in the context directory that insinuates that should an object
use this interface, it will be automatically resolved via the
Context.

I propose that we modify DefaultContext to check to see if
the object stored in the Context is Resolveable, and if so
return the object derived from Resolveable.resolve(Context).

The DefaultContext method in question will change to this:

    /**
     * Retrieve an item from the Context.
     *
     * @param key the key of item
     * @return the item stored in context
     * @exception ContextException if item not present
     */
    public Object get( final Object key )
        throws ContextException
    {
        final Object data = m_contextData.get( key );

        if( null != data )
        {
            // BEGIN NEW SECTION

            if ( data instanceof Resolveable )
            {
                return ( (Resolveable) data ).resolve(this);
            }

            // END NEW SECTION

            return data;
        }

        //thus data == null
        if( null == m_parent )
        {
            throw new ContextException( "Unable to locate " + key );
        }

        return m_parent.get( key );
    }

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


Re: [VOTE] DefaultContext mod

Posted by Peter Donald <do...@apache.org>.
+1 Works for me

On Wed, 3 Oct 2001 02:42, Berin Loritsch wrote:
> Currently, Avalon Framework identifies a Resolvable interface
> in the context directory that insinuates that should an object
> use this interface, it will be automatically resolved via the
> Context.
>
> I propose that we modify DefaultContext to check to see if
> the object stored in the Context is Resolveable, and if so
> return the object derived from Resolveable.resolve(Context).
>
> The DefaultContext method in question will change to this:
>
>     /**
>      * Retrieve an item from the Context.
>      *
>      * @param key the key of item
>      * @return the item stored in context
>      * @exception ContextException if item not present
>      */
>     public Object get( final Object key )
>         throws ContextException
>     {
>         final Object data = m_contextData.get( key );
>
>         if( null != data )
>         {
>             // BEGIN NEW SECTION
>
>             if ( data instanceof Resolveable )
>             {
>                 return ( (Resolveable) data ).resolve(this);
>             }
>
>             // END NEW SECTION
>
>             return data;
>         }
>
>         //thus data == null
>         if( null == m_parent )
>         {
>             throw new ContextException( "Unable to locate " + key );
>         }
>
>         return m_parent.get( key );
>     }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org

-- 
Cheers,

Pete

*--------------------------------*
| Every rule has an exception,   |
| except the rule of exceptions. |
*--------------------------------*


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