Package org.apache.avalon.fortress.util

Examples of org.apache.avalon.fortress.util.OverridableContext


   */
  public void contextualize(Context context) throws ContextException
  {
    //The context passed here is read-only....
    //Wrap it in a writable context we can make read-only later
    super.contextualize(new OverridableContext(context));

    if (defaultContainer == null)
    {
      defaultContainer = this;
    }
View Full Code Here


    private Context setupContext( final Configuration conf, final Context parentContext )
        throws Exception
    {
        //FIXME(GP): This method should setup the Context object according to the
        //           configuration spec.
        final DefaultContext context = new OverridableContext( parentContext );
        final Configuration[] confs = conf.getChildren( "entry" );
        for( int i = 0; i < confs.length; i++ )
        {
            final String key = confs[ i ].getAttribute( "name" );
            final String value = confs[ i ].getAttribute( "value", null );
            if( value == null )
            {
                String clazz = confs[ i ].getAttribute( "class" );
                Object obj = getClass().getClassLoader().loadClass( clazz ).newInstance();
                context.put( key, obj );
                if( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "FortressTestCase: added an instance of class "
                        + clazz + " to context entry " + key );
                }

            }
            else
            {
                context.put( key, value );
                if( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "FortressTestCase: added value \"" + value
                        + "\" to context entry " + key );
                }

            }
        }
        addContext( context );
        context.makeReadOnly();
        return context;
    }
View Full Code Here

        super( name );
    }

    public void testOverride() throws Exception
    {
        OverridableContext context = new OverridableContext( new DefaultContext() );
        context.put( "name", "value" );

        assertNotNull( context.get( "name" ) );
        assertEquals( "value", context.get( "name" ) );

        context.put( "name", "" );

        assertNotNull( context.get( "name" ) );
        assertEquals( "", context.get( "name" ) );

        context.put( "name", null );

        try
        {
            context.get( "name" );
            fail( "Did not throw the expected exception" );
        }
        catch ( ContextException ce )
        {
            // SUCCESS!!
View Full Code Here

    private Context setupContext( final Configuration conf, final Context parentContext )
        throws Exception
    {
        //FIXME(GP): This method should setup the Context object according to the
        //           configuration spec.
        final DefaultContext context = new OverridableContext( parentContext );
        final Configuration[] confs = conf.getChildren( "entry" );
        for( int i = 0; i < confs.length; i++ )
        {
            final String key = confs[ i ].getAttribute( "name" );
            final String value = confs[ i ].getAttribute( "value", null );
            if( value == null )
            {
                String clazz = confs[ i ].getAttribute( "class" );
                Object obj = getClass().getClassLoader().loadClass( clazz ).newInstance();
                context.put( key, obj );
                if( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "FortressTestCase: added an instance of class "
                        + clazz + " to context entry " + key );
                }

            }
            else
            {
                context.put( key, value );
                if( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "FortressTestCase: added value \"" + value
                        + "\" to context entry " + key );
                }

            }
        }
        addContext( context );
        context.makeReadOnly();
        return context;
    }
View Full Code Here

        super( name );
    }

    public void testOverride() throws Exception
    {
        OverridableContext context = new OverridableContext( new DefaultContext() );
        context.put( "name", "value" );

        assertNotNull( context.get( "name" ) );
        assertEquals( "value", context.get( "name" ) );

        context.put( "name", "" );

        assertNotNull( context.get( "name" ) );
        assertEquals( "", context.get( "name" ) );

        context.put( "name", null );

        try
        {
            context.get( "name" );
            fail( "Did not throw the expected exception" );
        }
        catch ( ContextException ce )
        {
            // SUCCESS!!
View Full Code Here

TOP

Related Classes of org.apache.avalon.fortress.util.OverridableContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.