avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject cvs commit: avalon/util/env/src/java/org/apache/avalon/util/env Env.java
Date Wed, 21 Jan 2004 02:15:20 GMT
akarasulu    2004/01/20 18:15:20

  Modified:    util/env/src/java/org/apache/avalon/util/env Env.java
  Log:
  Added method to cache the last Env instance which equates to a parse of
  the environment so the most recent parse of the env is used.
  
  Revision  Changes    Path
  1.5       +26 -1     avalon/util/env/src/java/org/apache/avalon/util/env/Env.java
  
  Index: Env.java
  ===================================================================
  RCS file: /home/cvs/avalon/util/env/src/java/org/apache/avalon/util/env/Env.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Env.java	21 Jan 2004 01:17:15 -0000	1.4
  +++ Env.java	21 Jan 2004 02:15:20 -0000	1.5
  @@ -80,6 +80,8 @@
   
       /** the user's platform specific shell executable */
       private static String s_shell = null ;
  +    /** the last Env instance created */
  +    private static Env s_lastEnv = null ;
       
   
       /**
  @@ -97,8 +99,31 @@
               String l_key = ( String ) l_list.nextElement() ;
               setProperty( l_key, l_props.getProperty( l_key ) ) ;
           }
  +
  +	s_lastEnv = this ;
       }
   
  +
  +    /**
  +     * Gets a copy of the last Env instance without parsing the user's shell 
  +     * environment.  Use this method if you do not want to reparse the 
  +     * environment every time an environment variable is accessed.  If an 
  +     * environment has not been created yet one is created then cloned 
  +     * and a copy is returned instead of returning null.
  +     * 
  +     * @return a copy of the last Env object created
  +     */
  +    Env getLastEnv() throws EnvAccessException
  +    {
  +        if ( s_lastEnv == null )
  +        {
  +            s_lastEnv = new Env() ;
  +        }
  +
  +        // return cloned copy so there is no cross interference
  +	return ( Env ) s_lastEnv.clone() ;
  +    }
  +    
   
       /**
        * Gets the value of a shell environment variable.
  
  
  

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


Mime
View raw message