Package org.apache.avalon.util.defaults

Examples of org.apache.avalon.util.defaults.Defaults


        Properties bootstrap = getDefaultProperties();
        final DefaultsFinder[] finders = {
            new SimpleDefaultsFinder( new Properties[] { bootstrap }, false ),
            new SystemDefaultsFinder() };
       
        Defaults defaults = new Defaults( SINGLE_KEYS, MULTI_VALUE_KEYS, finders );
        Defaults.macroExpand( defaults, new Properties[]{ System.getProperties() } );

        //
        // Here we start to populate the empty repository configuration using
        // the values stored in the defaults.
        //

        String cache =
          defaults.getProperty( REPOSITORY_CACHE_DIR );
        if( null != cache )
        {
            put(
              REPOSITORY_CACHE_DIR,
              new File( cache ) );
        }

        try
        {
            String hosts =
              defaults.getProperty( REPOSITORY_REMOTE_HOSTS );
            if( null != hosts )
            {
                put( REPOSITORY_REMOTE_HOSTS, hosts );
            }
        }
        catch ( Throwable e )
        {
            final String error =
              "Failed to set remote repositories.";
            throw new RepositoryException( error, e );
        }

        if( defaults.containsKey( REPOSITORY_PROXY_HOST ) )
        {   
            put(
              REPOSITORY_PROXY_HOST,
              new Integer( defaults.getProperty( REPOSITORY_PROXY_HOST ) ) );

            if( defaults.containsKey( REPOSITORY_PROXY_PORT ) )
            {
                put(
                  REPOSITORY_PROXY_PORT,
                  new Integer( defaults.getProperty( REPOSITORY_PROXY_PORT ) ) );
            }

            if( defaults.containsKey( REPOSITORY_PROXY_USERNAME ) )
            {
                put(
                  REPOSITORY_PROXY_USERNAME,
                  defaults.getProperty( REPOSITORY_PROXY_USERNAME ) );
            }

            if( defaults.containsKey( REPOSITORY_PROXY_PASSWORD ) )
            {
                put(
                  REPOSITORY_PROXY_PASSWORD,
                  defaults.getProperty( REPOSITORY_PROXY_PASSWORD ) );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.util.defaults.Defaults

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.