You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/02/18 14:34:15 UTC

cvs commit: avalon/repository/impl/src/java/org/apache/avalon/repository/impl DefaultRepositoryCriteria.java

mcconnell    2004/02/18 05:34:14

  Modified:    repository/impl/src/java/org/apache/avalon/repository/impl
                        DefaultRepositoryCriteria.java
  Log:
  Some minor adjustments taking into account the updated initial context object model.
  
  Revision  Changes    Path
  1.3       +85 -63    avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java
  
  Index: DefaultRepositoryCriteria.java
  ===================================================================
  RCS file: /home/cvs/avalon/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultRepositoryCriteria.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultRepositoryCriteria.java	24 Jan 2004 23:20:05 -0000	1.2
  +++ DefaultRepositoryCriteria.java	18 Feb 2004 13:34:14 -0000	1.3
  @@ -36,6 +36,7 @@
   import org.apache.avalon.util.defaults.DefaultsFinder;
   import org.apache.avalon.util.defaults.SimpleDefaultsFinder;
   import org.apache.avalon.util.defaults.SystemDefaultsFinder;
  +import org.apache.avalon.util.defaults.DefaultsBuilder;
   
   
   /**
  @@ -152,85 +153,106 @@
           super( PARAMS );
   
           //
  -        // setup the default values aquired from the initial context
  +        // create the consolidated properties
           //
   
  -        put( 
  -          REPOSITORY_CACHE_DIR, 
  -          context.getInitialCacheDirectory() );
  -        put( 
  -          REPOSITORY_REMOTE_HOSTS, 
  -          context.getInitialHosts() );
  -
  -        //
  -        // Create the finder (discovery policy), construct the defaults, and
  -        // macro expand the values.
  -        //
  +        try
  +        {
   
  -        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() } );
  +            final String key = context.getApplicationKey();
  +            final File work = context.getInitialWorkingDirectory();
  +            Properties bootstrap = getDefaultProperties();
  +            DefaultsBuilder builder = new DefaultsBuilder( key, work );
  +            Properties properties = 
  +              builder.getConsolidatedProperties( bootstrap, SINGLE_KEYS );
  +
  +            //
  +            // override values aquired from the initial context
  +            //
   
  -        //
  -        // 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 ) );
  -        }
  +              context.getInitialCacheDirectory() );
  +            put( 
  +              REPOSITORY_REMOTE_HOSTS, 
  +              context.getInitialHosts() );
   
  -        try
  -        {
  -            String hosts = 
  -              defaults.getProperty( REPOSITORY_REMOTE_HOSTS );
  -            if( null != hosts )
  +            //
  +            // Create the finder (discovery policy), construct the defaults, and
  +            // macro expand the values.
  +            //
  +            //
  +            //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 criteria using
  +            // the values from the consilidated defaults
  +            //
  +
  +            String cache = 
  +              properties.getProperty( REPOSITORY_CACHE_DIR );
  +            if( null != cache )
               {
  -                put( REPOSITORY_REMOTE_HOSTS, hosts );
  +                put( 
  +                  REPOSITORY_CACHE_DIR, 
  +                  new File( cache ) );
               }
  -        }
  -        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 ) )
  +            try
               {
  -                put(
  -                  REPOSITORY_PROXY_PORT, 
  -                  new Integer( defaults.getProperty( REPOSITORY_PROXY_PORT ) ) );
  +                String hosts = 
  +                  properties.getProperty( REPOSITORY_REMOTE_HOSTS );
  +                if( null != hosts )
  +                {
  +                    put( REPOSITORY_REMOTE_HOSTS, hosts );
  +                }
               }
  -
  -            if( defaults.containsKey( REPOSITORY_PROXY_USERNAME ) )
  +            catch ( Throwable e )
               {
  -                put(
  -                  REPOSITORY_PROXY_USERNAME, 
  -                  defaults.getProperty( REPOSITORY_PROXY_USERNAME ) );
  +                final String error = 
  +                  "Failed to set remote repositories.";
  +                throw new RepositoryException( error, e );
               }
   
  -            if( defaults.containsKey( REPOSITORY_PROXY_PASSWORD ) )
  -            {
  +            if( properties.containsKey( REPOSITORY_PROXY_HOST ) )
  +            {    
                   put(
  -                  REPOSITORY_PROXY_PASSWORD, 
  -                  defaults.getProperty( REPOSITORY_PROXY_PASSWORD ) );
  +                  REPOSITORY_PROXY_HOST, 
  +                  new Integer( properties.getProperty( REPOSITORY_PROXY_HOST ) ) );
  +    
  +                if( properties.containsKey( REPOSITORY_PROXY_PORT ) )
  +                {
  +                    put(
  +                      REPOSITORY_PROXY_PORT, 
  +                      new Integer( properties.getProperty( REPOSITORY_PROXY_PORT ) ) );
  +                }
  +    
  +                if( properties.containsKey( REPOSITORY_PROXY_USERNAME ) )
  +                {
  +                    put(
  +                      REPOSITORY_PROXY_USERNAME, 
  +                      properties.getProperty( REPOSITORY_PROXY_USERNAME ) );
  +                }
  +
  +                if( properties.containsKey( REPOSITORY_PROXY_PASSWORD ) )
  +                {
  +                    put(
  +                      REPOSITORY_PROXY_PASSWORD, 
  +                      properties.getProperty( REPOSITORY_PROXY_PASSWORD ) );
  +                }
               }
  +        }
  +        catch( IOException ioe )
  +        {
  +            final String error = 
  +              "Failed to resolve repository parameters.";
  +            throw new RepositoryException( error, ioe );
           }
       }
   
  
  
  

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