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

cvs commit: avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/builder MerlinBuilder.java

oberhack    2004/03/02 04:23:18

  Modified:    ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch
                        MerlinDeveloperLaunch.java
               ide/org.apache.avalon.ide.eclipse.launch plugin.xml
               ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/container
                        MerlinContainerEnvironment.java
                        AvalonContainer.java
  Added:       ide/org.apache.avalon.ide.eclipse.launch/lib
                        avalon-util-criteria-1.0.jar
                        avalon-util-env-1.0.jar merlin-bootstrap-1.0.jar
                        avalon-util-exception-1.0.jar merlin-api-3.2.jar
                        merlin-cli-3.2.4.jar avalon-util-defaults-1.1.jar
                        avalon-framework-api-4.1.5.jar
                        avalon-framework-impl-4.1.5.jar
                        merlin-impl-3.2.4.jar
               ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults
                        SystemDefaultsFinder.java DefaultsBuilder.java
                        DefaultsFinder.java SimpleDefaultsFinder.java
                        Defaults.java package.html
               ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/builder
                        MerlinBuilder.java
  Removed:     ide/org.apache.avalon.ide.eclipse.launch/lib .cvsignore
  Log:
  
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/avalon-util-criteria-1.0.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/avalon-util-env-1.0.jar
  
  	<<Binary file>>
  
  
  1.3       +0 -0      avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/merlin-bootstrap-1.0.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/avalon-util-exception-1.0.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/merlin-api-3.2.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/merlin-cli-3.2.4.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/avalon-util-defaults-1.1.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/avalon-framework-api-4.1.5.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/avalon-framework-impl-4.1.5.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/lib/merlin-impl-3.2.4.jar
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults/SystemDefaultsFinder.java
  
  Index: SystemDefaultsFinder.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.util.defaults;
  
  
  import java.util.Properties;
  
  
  /**
   * Finds default property values within the system properties.
   * 
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: oberhack $
   * @version $Revision: 1.1 $
   */
  public class SystemDefaultsFinder extends SimpleDefaultsFinder
  {
      /**
       * Finds default property values within the system properties.
       */
      public SystemDefaultsFinder()
      {
          super( new Properties [] { System.getProperties() }, true ) ;
      }
  }
  
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults/DefaultsBuilder.java
  
  Index: DefaultsBuilder.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.util.defaults;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.util.Properties;
  
  import org.apache.avalon.util.env.Env;
  
  
  /**
   * A utility class that provides support for the establishment
   * of a set of installation properties.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultsBuilder
  {
      //--------------------------------------------------------------
      // static
      //--------------------------------------------------------------
  
     /**
      * Return a home directory taking into account a supplied env symbol, 
      * a property key and a fallback directory.
      *
      * If the supplied key references a known system property
      * value of '[key].home' then that value will be used to establish the home 
      * directory. Otherwise, if the supplied env symbol cannot be resolved
      * to a value, a directory corresponding to ${user.home}/.[key]
      * will be returned.
      *
      * @param key an application key such as 'merlin'
      * @return the derived directory
      */
      public static File getHomeDirectory( String key ) throws Exception
      {
          final String homeKey = key + ".home";
          final String symbol = key.toUpperCase() + "_HOME";
          final String home = 
            System.getProperty( 
              homeKey, 
              Env.getEnvVariable( symbol ) );
  
          if( null != home )
          {
              return new File( home ).getCanonicalFile();
          }
          else
          {
              final File user = 
                new File( System.getProperty( "user.home" ) );
              final String path = "." + key;
              return new File( user, path ).getCanonicalFile();
          }
      }
  
     /**
      * Create a installation properties object.  The implementation
      * will create a new properties object and read in a properties 
      * file if it exists relative to the filename [home]/[key].properties.  
      * Before returning the properties object the home directory will be 
      * assigned as the value of a property name [key].home if the supplied
      * flag argument is TRUE.
      *
      * @param home the home directory
      * @param key the application key 
      * @param flag if TRUE set the property '[key].home' to the home directory 
      * @return the application properties object
      */
      public static Properties getHomeProperties( 
        File home, String key, boolean flag ) throws IOException
      {
          Properties properties = getProperties( home, key );
          if( flag )
          {
              final String name = key + ".home";
              final String path = home.getCanonicalPath();
              properties.setProperty( name, path );
          }
          return properties;
      }
  
     /**
      * Create a user properties object.  The implementation
      * will create a new properties object and read in a properties 
      * file if it exists relative to the filename ${user.home}/[key].properties.  
      *
      * @param key the application key 
      * @return the user properties object
      */
      public static Properties getUserProperties( 
        String key ) throws IOException
      {
          final File user = new File( System.getProperty( "user.home" ) );
          return getProperties( user, key );
      }
  
     /**
      * Create a dir properties object.  The implementation
      * will create a new properties object and read in a properties 
      * file if it exists relative to [dir]/[key].properties.  
      *
      * @param dir the base directory 
      * @param key the application key 
      * @return the user properties object
      */
      public static Properties getProperties( 
        File dir, String key ) throws IOException
      {
          final String filename = key + ".properties";
          final File file = new File( dir, filename );
          return getProperties( file );
      }
  
     /**
      * Create a properties object from the supplied file.  If 
      * the file does not exists an empty property object will be 
      * returned.
      *
      * @param file the properties file
      * @return the properties object
      */
      public static Properties getProperties( File file ) throws IOException
      {
          if( null == file )
          {
              throw new NullPointerException( "file" );
          }
  
          Properties properties = new Properties();
          if( file.exists() )
          {
              properties.load( 
                new FileInputStream( file ) );
          }   
          return properties;
      }
  
      public static Properties getProperties( 
        ClassLoader classloader, String path ) throws IOException
      {
          Properties properties = new Properties();
          InputStream input = 
            classloader.getResourceAsStream( path );
          if( input != null ) 
          {
              properties.load( input );
          }
          return properties;
      }
  
      //--------------------------------------------------------------
      // state
      //--------------------------------------------------------------
  
      private final String m_key;
  
      private final File m_work;
  
      private final File m_root;
  
      private final Properties m_home;
  
      private final Properties m_user;
  
      private final Properties m_dir;
  
      //--------------------------------------------------------------
      // constructor
      //--------------------------------------------------------------
  
      public DefaultsBuilder( final String key, File work ) throws Exception
      {
          m_key = key;
          m_work = work;
          m_root = getHomeDirectory( m_key );
          m_home = getHomeProperties( m_root, m_key, true );
          m_user = getUserProperties( m_key );
          m_dir = getProperties( m_work, m_key );
      }
  
      //--------------------------------------------------------------
      // implementation
      //--------------------------------------------------------------
  
      public File getHomeDirectory()
      {
          return m_root;
      }
  
      public Properties getHomeProperties()
      {
          return m_home;
      }
  
      public Properties getUserProperties()
      {
          return m_user;
      }
  
      public Properties getDirProperties()
      {
          return m_dir;
      }
  
      public Properties getConsolidatedProperties( 
        final Properties defaults, final String[] keys ) throws IOException
      {
          final Properties[] parameters = 
            new Properties[] { 
              defaults,
              m_home,
              m_user,
              m_dir };
          final DefaultsFinder[] finders = 
            new DefaultsFinder[]{
              new SimpleDefaultsFinder( 
                parameters, 
                false ), 
              new SystemDefaultsFinder() 
            };
          return new Defaults( keys, new String[0], finders );
      }
  }
  
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults/DefaultsFinder.java
  
  Index: DefaultsFinder.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.util.defaults;
  
  
  /**
   * Finds a set of default property values.
   * 
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: oberhack $
   * @version $Revision: 1.1 $
   */
  public interface DefaultsFinder
  {
     void find( Defaults a_defaults ) ; 
  }
  
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults/SimpleDefaultsFinder.java
  
  Index: SimpleDefaultsFinder.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.util.defaults;
  
  
  import java.util.Properties;
  
  
  /**
   * Attempts to discover defaults using an array of Properties as value sources.
   * 
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: oberhack $
   * @version $Revision: 1.1 $
   */
  public class SimpleDefaultsFinder implements DefaultsFinder
  {
      /** Properties array to use for discovery */
      private Properties [] m_sources ;
      /** halt on first finding flag */
      private boolean m_haltOnDiscovery = true ;
      
      
      /**
       * Creates a simple defaults finder that searches a single source Properties
       * instance for default values.
       * 
       * @param source single source Properties to discover values in
       */
      public SimpleDefaultsFinder( Properties source )
      {
          m_sources = new Properties [] { source } ;
          m_haltOnDiscovery = false ;
      }
      
      
      /**
       * Creates a simple defaults filder that searches a set of source Properties
       * for default values.
       * 
       * @param sources the source Properties to discover values in
       * @param haltOnDiscovery true to halt search when first value is 
       * discovered, false to continue search overriding values until the last 
       * value is discovered.
       */
      public SimpleDefaultsFinder( Properties [] sources, 
                                     boolean haltOnDiscovery )
      {
          m_sources = sources ;
          m_haltOnDiscovery = haltOnDiscovery ;
      }
      
      
      /**
       * Applies default discovery using properties in array of properties.
       * 
       * @see org.apache.avalon.util.defaults.DefaultsFinder#find(
       * org.apache.avalon.util.defaults.Defaults)
       */
      public void find( Defaults a_defaults )
      {
          Defaults.discover( a_defaults, m_sources, m_haltOnDiscovery ) ;
      }
  }
  
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults/Defaults.java
  
  Index: Defaults.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.util.defaults;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.Properties;
  
  
  /**
   * Gets a set of default property values based on a sequence of default value
   * search components or finders.
   * 
   * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
   * @author $Author: oberhack $
   * @version $Revision: 1.1 $
   */
  public class Defaults extends Properties
  {
      /** single-valued property key names */ 
      private final String [] m_singles ;
      /** multi-valued or enumerated property key names */  
      private final String [] m_enumerated ; 
      /** array of finders that define the property default discovery process */
      private final DefaultsFinder [] m_finders ;
      
      
      // ------------------------------------------------------------------------
      // C O N S T R U C T O R S
      // ------------------------------------------------------------------------
  
      
      /**
       * Creates and populates a set of properties
       * 
       * @param a_singles single valued key names
       * @param a_enumerated multi-valued key names
       * @param a_finders search components used for staged discovery of defaults
       */
      public Defaults( String [] a_singles, String [] a_enumerated, 
                       DefaultsFinder [] a_finders )
      {
          m_finders = a_finders ;
          m_singles = a_singles ;
          m_enumerated = a_enumerated ;
          
          for ( int ii = 0; ii < m_finders.length; ii++ )
          {
              m_finders[ii].find( this ) ;
          }
      }
  
      
      // ------------------------------------------------------------------------
      // A C C E S S O R S 
      // ------------------------------------------------------------------------
      
      
      /**
       * Gets the base names of enumerated multi-valued keys.  Such keys are 
       * enumerated to have multiple values by appending an index onto a key base
       * like so: [base.key].1,[base.key].2,[base.key].3 ... [base.key].N.  The
       * returned keys are just the base key names of multi-valued properties and
       * do not include the appended index.
       * 
       * @return the base key names for multi-valued properties
       */
      public String[] getEnumerated()
      {
          return m_enumerated ;
      }
  
      
      /**
       * Gets the linear set of finders composing the search policy.
       * 
       * @return the finders used to discover property defaults
       */
      public DefaultsFinder[] getFinders()
      {
          return m_finders ;
      }
  
  
      /**
       * Gets the names of all the single valued properties. 
       * 
       * @return single valued property key names
       */
      public String[] getSingles()
      {
          return m_singles ;
      }
      
      
      /**
       * Gets the default values for an enumerated key.
       * 
       * @param a_base the base of the enumerated key
       * @return the values of the multi-valued property
       */
      public String[] getEnumerated( String a_base )
      {
          ArrayList l_values = new ArrayList() ;
          Enumeration l_list = keys() ;
  
          while ( l_list.hasMoreElements() )
          {
              String l_key = ( String ) l_list.nextElement() ;
              if ( l_key.startsWith( a_base ) )
              {
                  l_values.add( getProperty( l_key ) ) ;
              }
          }
          return ( String [] ) l_values.toArray( new String [0] ) ;
      }
  
      
      /**
       * Utility method that gets a key's value and returns a boolean value to 
       * represent it.
       * 
       * @param a_key the boolean property key
       * @return true if the property is 1, true, yes or on, and false otherwise 
       */
      public boolean getBoolean( String a_key )
      {
          String l_value = getProperty( a_key ) ;
          l_value = l_value.trim().toLowerCase() ;
          
          if ( l_value.equals( "1" )       ||
               l_value.equals( "on" )      ||
               l_value.equals( "yes" )     ||
               l_value.equals( "true" ) )
          {
              return true ;
          }
          
          return false ;
      }
      
      
      // ------------------------------------------------------------------------
      // S T A T I C   M E T H O D S
      // ------------------------------------------------------------------------
      
      
      /**
       * Merges a set of properties from source Properties into a Defaults 
       * instance.  Does not allow null overrides.
       * 
       * @param a_defaults the defaults to populate on discovery
       * @param a_sources the sources to search
       * @param a_haltOnDiscovery true to halt on first find or false to continue
       * to last find
       */
      public static void discover( Defaults a_defaults, Properties [] a_sources,
                                   boolean a_haltOnDiscovery )
      {
          if ( null == a_sources || null == a_defaults )
          {
              return ;
          }
          
          /*
           * H A N D L E   S I N G L E   V A L U E D   K E Y S  
           */
          String [] l_keys = a_defaults.getSingles() ;
          for ( int ii = 0; ii < l_keys.length; ii++ )
          {
              String l_key = l_keys[ii] ;
              String l_value = discover( l_key, a_sources, a_haltOnDiscovery ) ;
              
              if ( l_value != null )
              {
                  a_defaults.setProperty( l_key, l_value ) ;
              }
          }
          
          /*
           * H A N D L E   M U L T I - V A L U E D   K E Y S 
           */
          l_keys = a_defaults.getEnumerated() ;
          for ( int ii = 0; ii < l_keys.length; ii++ )
          {
              String l_base = l_keys[ii] ;
              
              for ( int jj = 0; jj < a_sources.length; jj++ )
              {
                  Enumeration l_list = a_sources[jj].propertyNames() ;
                  
                  while ( l_list.hasMoreElements() )
                  {
                      String l_key = ( String ) l_list.nextElement() ;
                      if ( ! l_key.startsWith( l_base ) )
                      {
                          continue ;
                      }
                      
                      String l_value = 
                          discover( l_key, a_sources, a_haltOnDiscovery ) ;
  
                      if ( l_value != null )
                      {
                          a_defaults.setProperty( l_key, l_value ) ;
                      }
                  }
              }
          }
      }
      
      
      /**
       * Discovers a value within a set of Properties either halting on the first
       * time the property is discovered or continuing on to take the last value
       * found for the property key.
       * 
       * @param l_key a property key
       * @param a_sources a set of source Properties
       * @param a_haltOnDiscovery true if we stop on finding a value, false 
       * otherwise
       * @return the value found or null
       */
      public static String discover( String l_key, Properties [] a_sources,
                                     boolean a_haltOnDiscovery )
      {
          String l_retval = null ;
          
          for( int ii = 0; ii < a_sources.length; ii++ )
          {
              if ( a_sources[ii].containsKey( l_key ) )
              {
                  l_retval = a_sources[ii].getProperty( l_key ) ;
                  
                  if ( a_haltOnDiscovery )
                  {
                      break ;
                  }
              }
          }
          
          return l_retval ;
      }
  
  
      /**
       * Expands out a set of property key macros in the following format 
       * ${foo.bar} where foo.bar is a property key, by dereferencing the value 
       * of the key using the original source Properties and other optional 
       * Properties.
       * 
       * If the original expanded Properties contain the value for the macro key 
       * foo.bar then dereferencing stops by using the value in the expanded 
       * Properties: the other optional Properties are NOT used at all.
       * 
       * If the original expanded Properties do NOT contain the value for the 
       * macro key, then the optional Properties are used in order.  The first of
       * the optionals to contain the value for the macro key (foo.bar) shorts the
       * search.  Hence the first optional Properties in the array to contain a 
       * value for the macro key (foo.bar) is used to set the expanded value.
       * 
       * If a macro cannot be expanded because it's key was not defined within the 
       * expanded Properties or one of the optional Properties then it is left as
       * is.
       * 
       * @param a_expanded the Properties to perform the macro expansion upon
       * @param a_optionals null or an optional set of Properties to use for 
       * dereferencing macro keys (foo.bar)
       */
      public static void macroExpand( Properties a_expanded, 
                                      Properties [] a_optionals )
      {
          // Handle null optionals
          if ( null == a_optionals )
          {
              a_optionals = new Properties [ 0 ] ;
          }
          
          Enumeration l_list = a_expanded.propertyNames() ;
          while ( l_list.hasMoreElements() )
          {
              String l_key = ( String ) l_list.nextElement() ;
              String l_macro = a_expanded.getProperty( l_key ) ;
              
              int n = l_macro.indexOf( "${" );
              if( n < 0 )
              {
                  continue;
              }
  
              int m = l_macro.indexOf( "}", n+2 );
              if( m < 0 )
              {
                  continue;
              }
  
              final String symbol = l_macro.substring( n+2, m );
              
              if ( a_expanded.containsKey( symbol ) )
              {
                  final String value = a_expanded.getProperty( symbol );
                  final String head = l_macro.substring( 0, n );
                  final String tail = l_macro.substring( m+1 );
                  final String resolved = head + value + tail;
  
                  a_expanded.put( l_key, resolved ) ;
                  continue ;
              }
  
              /*
               * Check if the macro key exists within the array of optional 
               * Properties.  Set expanded value to first Properties with the 
               * key and break out of the loop.
               */
              for ( int ii = 0; ii < a_optionals.length; ii++ )
              {
                  if ( a_optionals[ii].containsKey( symbol ) )
                  {
                      String value = a_optionals[ii].getProperty( symbol ) ;
                      final String head = l_macro.substring( 0, n );
                      final String tail = l_macro.substring( m+1 );
                      final String resolved = head + value + tail;
  
                      a_expanded.put( l_key, resolved ) ;
                      break ;
                  }
              }
          }
      }
  
     /**
      * Read in a static properties resource relative to a supplied class
      * and path.
      *
      * @param ref a class used to establish a classloader and anchors 
      *    relative path references
      * @param path the resoruce address
      * @return the static properties
      * @exception IllegalStateException if the path is unresolvable
      */
      public static Properties getStaticProperties( Class ref, String path ) throws IOException
      {
          Properties bootstrap = new Properties();
          InputStream input = ref.getResourceAsStream( path );
          if( input == null )
          {
              final String error = 
                "Internal error, unable to locate enbedded resource: " 
                + path 
                + " from the resource: " 
                + ref.getProtectionDomain().getCodeSource().getLocation();
              throw new IllegalStateException( error );
          }
          bootstrap.load( input );
          return bootstrap;
      }
  }
  
  
  
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/util/defaults/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>
  Provides support for the aggregation of a set of property values into a single property set.
  </p>
  </body>
  
  
  
  1.3       +2 -0      avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/MerlinDeveloperLaunch.java
  
  Index: MerlinDeveloperLaunch.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/MerlinDeveloperLaunch.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MerlinDeveloperLaunch.java	16 Feb 2004 21:04:03 -0000	1.2
  +++ MerlinDeveloperLaunch.java	2 Mar 2004 12:23:17 -0000	1.3
  @@ -48,6 +48,8 @@
           PLUGIN_ID + ".merlinProjectNature";
       public static final String MERLIN_PROJECT_CONFIG_NATURE_ID =
           PLUGIN_ID + ".merlinConfigNature";
  +    public static final String MERLIN_BUILDER_ID =
  +    PLUGIN_ID + ".merlinBuilder";
       public static final String ID_MERLIN_CONTAINER = 
           MerlinDeveloperLaunch.PLUGIN_ID + ".merlinLaunchConfigurationDelegate"; //$NON-NLS-1$
       public static final String ATTR_MERLIN_CONTAINER_ID = "merlinContainerID"; //$NON-NLS-1$
  
  
  
  1.5       +10 -0     avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/plugin.xml
  
  Index: plugin.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/plugin.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- plugin.xml	16 Feb 2004 21:04:02 -0000	1.4
  +++ plugin.xml	2 Mar 2004 12:23:17 -0000	1.5
  @@ -24,6 +24,16 @@
         <import plugin="org.apache.avalon.MerlinDeveloperCore"/>
      </requires>
   
  +   <extension
  +         id="merlinBuilder"
  +         name="Merlin Builder"
  +         point="org.eclipse.core.resources.builders">
  +      <builder>
  +         <run
  +               class="org.apache.avalon.ide.eclipse.merlin.builder.MerlinBuilder">
  +         </run>
  +      </builder>
  +   </extension>
   
      <extension
            id="merlinProjectNature"
  
  
  
  1.2       +54 -74    avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/container/MerlinContainerEnvironment.java
  
  Index: MerlinContainerEnvironment.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/container/MerlinContainerEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MerlinContainerEnvironment.java	16 Feb 2004 21:04:03 -0000	1.1
  +++ MerlinContainerEnvironment.java	2 Mar 2004 12:23:17 -0000	1.2
  @@ -6,17 +6,11 @@
    */
   package org.apache.avalon.ide.eclipse.merlin.launch.container;
   
  -import java.io.File;
  -import java.util.Map;
  +import java.io.IOException;
  +
  +import org.apache.avalon.ide.eclipse.merlin.launch.MerlinDeveloperLaunch;
  +import org.apache.avalon.util.defaults.DefaultsBuilder;
   
  -import org.apache.avalon.merlin.cli.Main;
  -import org.apache.avalon.merlin.impl.DefaultCriteria;
  -import org.apache.avalon.repository.Artifact;
  -import org.apache.avalon.repository.main.DefaultInitialContext;
  -import org.apache.avalon.repository.provider.Factory;
  -import org.apache.avalon.repository.provider.InitialContext;
  -import org.apache.avalon.util.env.Env;
  -import org.apache.avalon.util.exception.ExceptionHelper;
   
   /**
    * @author Andreas Develop
  @@ -27,32 +21,18 @@
   public class MerlinContainerEnvironment
   {
   
  +    private DefaultsBuilder merlinBuilder;
  +    private DefaultsBuilder avalonBuilder;
  +    
       public static void main(String[] args)
       {
   
           try
           {
  -            // must be the dir, where merlin is launched
  -            File dir = getBaseDirectory();
  -            File system = new File( getMerlinHome( ), "system" );
  -            
  -            ClassLoader parent = Main.class.getClassLoader();
  -            Artifact impl = null; // default
  -            String[] bootstrap = null; // default
  -            
  -            InitialContext context = 
  -            new DefaultInitialContext( 
  -                    dir, parent, impl, system, bootstrap );
  -            
  -            Factory factory = context.getInitialFactory();
  +            DefaultsBuilder db = new DefaultsBuilder("merlin", null);
  +            Object obj = db.getHomeProperties();
               
  -            // getting the proxy settings for Repository access
  -            Map repCriteria = factory.createDefaultCriteria();
  -            
  -            // getting all other settings
  -            Map criteria = new DefaultCriteria(context);
  -            Object obj = factory.create(repCriteria); 
  -            Object o1 = obj;
  +            Object o = obj;
               
           } catch (Exception e)
           {
  @@ -60,63 +40,63 @@
           }
           
       }
  -
  -    /**
  -     * Return the functional base directory.  The implementation looks
  -     * for the ${merlin.dir} system property and if not found, looks for 
  -     * the ${basedir} system property, and as a last resort, returns the 
  -     * JVM ${user.dir} value.
  -     *
  -     * @return the merlin install directory
  -     */
  -    private static File getBaseDirectory()
  -    {
  -        final String merlin = System.getProperty( "merlin.dir" );
  -        if( null != merlin )
  -           {
  -            return new File( merlin );
  -        }
  -        final String base = System.getProperty( "basedir" );
  -        if( null != base )
  -           {
  -            return new File( base );
  +    public MerlinContainerEnvironment(){
  +        
  +        try
  +        {
  +            merlinBuilder = new DefaultsBuilder("merlin", null);
  +            avalonBuilder = new DefaultsBuilder("avalon", null);
  +        } catch (Exception e)
  +        {
  +            MerlinDeveloperLaunch.log(e, "Error while reading the Avalon environment");
           }
  -        return new File( System.getProperty( "user.dir" ) );
  +        
       }
  -
       /**
  -     * Return the merlin home directory.
  -     * @return the merlin install directory
  +     * @return
        */
  -    private static File getMerlinHome()
  +    public String getAvalonHome()
       {
  -        return new File( getMerlinHomePath() );
  +        String path; 
  +        try
  +        {
  +            path = avalonBuilder.getHomeDirectory().getCanonicalPath();
  +        } catch (IOException e)
  +        {
  +            MerlinDeveloperLaunch.log(e, "Error while reading the Avalon Home Directory");
  +            return null;
  +        }
  +        return path;
       }
  -
       /**
  -     * Return the merlin home directory path.
  -     * @return the merlin install directory path
  +     * @return
        */
  -    private static String getMerlinHomePath()
  +    public String getMerlinHome()
       {
  +        String path; 
           try
           {
  -            String merlin = 
  -            System.getProperty( 
  -                    "merlin.home", 
  -                    Env.getEnvVariable( "MERLIN_HOME" ) );
  -            if( null != merlin ) return merlin;
  -            return System.getProperty( "user.home" ) 
  -            + File.separator + ".merlin";
  -        }
  -        catch( Throwable e )
  +            path = merlinBuilder.getHomeDirectory().getCanonicalPath();
  +        } catch (IOException e)
           {
  -            final String error = 
  -            "Internal error while attempting to access MERLIN_HOME environment.";
  -            final String message = 
  -            ExceptionHelper.packException( error, e, true );
  -            throw new RuntimeException( message );
  +            MerlinDeveloperLaunch.log(e, "Error while reading the Merlin Home Directory");
  +            return null;
           }
  +        return path;
  +    }
  +    /**
  +     * 
  +     */
  +    public void setAvalonDefaultsHome()
  +    {
  +    }
  +    /**
  +     * 
  +     */
  +    public void setMerlinDefaultsHome()
  +    {
  +        // System.setProperty("merlin.home", "");
  +        
       }
       
   }
  
  
  
  1.4       +8 -6      avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/container/AvalonContainer.java
  
  Index: AvalonContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/launch/container/AvalonContainer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AvalonContainer.java	16 Feb 2004 21:04:03 -0000	1.3
  +++ AvalonContainer.java	2 Mar 2004 12:23:17 -0000	1.4
  @@ -22,7 +22,6 @@
   
   import org.apache.avalon.ide.eclipse.merlin.launch.MerlinDeveloperLaunch;
   import org.apache.avalon.ide.eclipse.merlin.nature.MerlinProjectNature;
  -import org.eclipse.core.resources.IFile;
   import org.eclipse.core.resources.IProject;
   import org.eclipse.core.runtime.CoreException;
   import org.eclipse.core.runtime.IPath;
  @@ -187,16 +186,19 @@
               }
           }
       }
  -    
  -    protected LibraryLocation getToolsLibraryLocation() {
  +
  +    protected LibraryLocation getToolsLibraryLocation()
  +    {
           IPath toolsJarPath = new Path(JavaRuntime.getDefaultVMInstall().getInstallLocation().getPath()).append("lib").append("tools.jar"); //$NON-NLS-1$ //$NON-NLS-2$
  -        if (toolsJarPath.toFile().exists()) {
  +        if (toolsJarPath.toFile().exists())
  +        {
               return new LibraryLocation(toolsJarPath, Path.EMPTY, Path.EMPTY);
  -        } else {
  +        } else
  +        {
               return null;
           }
       }
  -    
  +
       private IVMInstall getVMInstall(String vmInstallName)
       {
           if (vmInstallName != null)
  
  
  
  1.1                  avalon-sandbox/ide/org.apache.avalon.ide.eclipse.launch/src/org/apache/avalon/ide/eclipse/merlin/builder/MerlinBuilder.java
  
  Index: MerlinBuilder.java
  ===================================================================
  /*
   * One has to add the builder to a project first.
   * 
     IProjectDescription desc = project.getDescription();
     ICommand[] commands = desc.getBuildSpec();
     boolean found = false;
  
     for (int i = 0; i < commands.length; ++i) {
        if (commands[i].getBuilderName().equals(BUILDER_ID)) {
           found = true;
           break;
        }
     }
     if (!found) { 
        //add builder to project
        ICommand command = desc.newCommand();
        command.setBuilderName(BUILDER_ID);
        ICommand[] newCommands = new ICommand[commands.length + 1];
  
        // Add it before other builders.
        System.arraycopy(commands, 0, newCommands, 1, commands.length);
        newCommands[0] = command;
        desc.setBuildSpec(newCommands);
        project.setDescription(desc, null);
     }
  
  
   */
  package org.apache.avalon.ide.eclipse.merlin.builder;
  
  import java.util.Map;
  
  import org.eclipse.core.resources.IProject;
  import org.eclipse.core.resources.IncrementalProjectBuilder;
  import org.eclipse.core.runtime.CoreException;
  import org.eclipse.core.runtime.IProgressMonitor;
  
  /**
   * @author Andreas Develop
   *
   * To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Generation - Code and Comments
   */
  public class MerlinBuilder extends IncrementalProjectBuilder
  {
  
      /* (non-Javadoc)
       * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
       */
      protected IProject[] build(int pKind, Map pArgs, IProgressMonitor pMonitor) throws CoreException
      {
          Object obj = getDelta(getProject());
          System.out.println("here !");
          return null;
      }
  
      /**
       * 
       */
      public MerlinBuilder()
      {
          super();
          // TODO Auto-generated constructor stub
      }
  
  }
  
  
  

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