Package org.codehaus.dna.impl

Examples of org.codehaus.dna.impl.DefaultConfiguration


    }

    public void testToString()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );

        final String expected = "[Configuration name='myElement']";
        final String string = configuration.toString();
        assertEquals( expected, string );
    }
View Full Code Here


    }

    public void testToStringWithAttributes()
        throws Exception
    {
        final DefaultConfiguration configuration =
            new DefaultConfiguration( "myElement", "file.xml:20", "" );
        configuration.setAttribute( "key", "value" );
        final Map attributeMap = configuration.getAttributeMap();

        final String expected =
            "[Configuration name='myElement' attributes=" + attributeMap + "]";
        final String string = configuration.toString();
        assertEquals( expected, string );
    }
View Full Code Here

{
   public void testDNAAcceptorManager()
      throws Exception
   {
      final DNAAcceptorManager manager = new DNAAcceptorManager();
      final DefaultConfiguration root = new DefaultConfiguration( "root", "", "" );
      final DefaultConfiguration configuration = new DefaultConfiguration( "shutdownTimeout", "", "" );
      configuration.setValue( "22" );
      root.addChild( configuration );

      final ConsoleLogger logger = new ConsoleLogger( ConsoleLogger.LEVEL_NONE );
      manager.enableLogging( logger );
      final AcceptorMonitor monitor = manager.getMonitor();
View Full Code Here

     */
    private Configuration processConfiguration( final String application,
                                                final Configuration configuration )
        throws LoomException
    {
        final DefaultConfiguration newConfiguration =
            new DefaultConfiguration( "config",
                                      configuration.getPath(),
                                      configuration.getLocation() );
        final Configuration[] configurations = configuration.getChildren();
        for( int i = 0; i < configurations.length; i++ )
        {
            final Configuration config = configurations[i];
            try
            {
                final Configuration newConfig =
                    m_repository.processConfiguration( application,
                                                       config.getName(),
                                                       config );
                newConfiguration.addChild( newConfig );
            }
            catch( final ConfigurationException ce )
            {
                throw new LoomException( ce.getMessage(), ce );
            }
View Full Code Here

     */
    public static Configuration merge( final Configuration layer,
                                       final Configuration base )
        throws ConfigurationException
    {
        final DefaultConfiguration merged =
            new DefaultConfiguration( base.getName(),
                                      base.getPath(),
                                      "Merged [layer: " +
                                      layer.getLocation()
                                      + ", base: " + base.getLocation() + "]" );

        copyAttributes( base, merged );
        copyAttributes( layer, merged );

        mergeChildren( layer, base, merged );

        final String value = getValue( layer, base );
        if( null != value )
        {
            merged.setValue( value );
        }

        return merged;
    }
View Full Code Here

    private static Configuration expandValues( final PropertyExpander expander,
                                               final Configuration input,
                                               final Map data )
        throws Exception
    {
        final DefaultConfiguration output =
            new DefaultConfiguration( input.getName(),
                                      input.getPath(),
                                      input.getLocation() );
        final String[] names = input.getAttributeNames();
        for( int i = 0; i < names.length; i++ )
        {
            final String name = names[ i ];
            final String value = input.getAttribute( name );
            final String newValue = expander.expandValues( value, data );
            output.setAttribute( name, newValue );
        }

        final Configuration[] children = input.getChildren();
        for( int i = 0; i < children.length; i++ )
        {
            final Configuration child =
                expandValues( expander, children[ i ], data );
            output.addChild( child );
        }

        final String content = input.getValue( null );
        if( null != content )
        {
            final String newValue =
                expander.expandValues( content, data );
            output.setValue( newValue );
        }

        return output;
    }
View Full Code Here

     */
    public static Configuration split( final Configuration merged,
                                       final Configuration base )
        throws ConfigurationException
    {
        final DefaultConfiguration layer = doSplit( merged, base, false );

        layer.makeReadOnly();

        return layer;
    }
View Full Code Here

    private static DefaultConfiguration doSplit( final Configuration merged,
                                                 final Configuration base,
                                                 final boolean isMerged )
        throws ConfigurationException
    {
        final DefaultConfiguration layer =
            new DefaultConfiguration( base.getName(),
                                      merged.getPath(),
                                      "Merged [merged: " +
                                      merged.getLocation()
                                      + ", base: " + base.getLocation() + "]" );

        copyAttributes( layer, merged, base );
        copyValue( layer, merged, base );
        copyChildren( layer, merged, base );

        if( isMerged )
        {
            layer.setAttribute( Constants.MERGE_ATTR, "true" );
        }

        return layer;
    }
View Full Code Here

    private static DefaultConfiguration doSplit( final Configuration merged,
                                                 final Configuration base,
                                                 final String keyAttr )
        throws ConfigurationException
    {
        final DefaultConfiguration layer = doSplit( merged, base, true );

        if( null != keyAttr )
        {
            layer.setAttribute( Constants.KEY_ATTR, keyAttr );
        }

        return layer;
    }
View Full Code Here

            {
                layer.addChild( kids[ i ] );
            }
            else if( !ConfigurationUtil.equals( kids[ i ], mergedWith ) )
            {
                final DefaultConfiguration layerChild = doSplit( kids[ i ],
                                                                 mergedWith,
                                                                 keyAttr );

                layerChild.makeReadOnly();

                layer.addChild( layerChild );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.dna.impl.DefaultConfiguration

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.