mcconnell    2003/12/09 05:46:33

  Modified:    merlin/kernel/cli/src/java/org/apache/avalon/merlin/cli
                        Main.java
               merlin/kernel/impl/conf merlin.properties
               merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl
                        DefaultCriteria.java DefaultFactory.java
  Log:
  Update kernel factory to handle improved reporting of defaults.
  
  Revision  Changes    Path
  1.4       +70 -70    
avalon/merlin/kernel/cli/src/java/org/apache/avalon/merlin/cli/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/kernel/cli/src/java/org/apache/avalon/merlin/cli/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java 9 Dec 2003 11:51:33 -0000       1.3
  +++ Main.java 9 Dec 2003 13:46:32 -0000       1.4
  @@ -214,6 +214,74 @@
   
       private static Main MAIN = null;
   
  +   /**
  +    * Main command line enty point.
  +    * @param args the command line arguments
  +    */
  +    public static void main( String[] args )
  +    {
  +        try
  +        {
  +            //
  +            // parse the commandline
  +            //
  +
  +            CommandLineParser parser = new BasicParser();
  +            CommandLine line = parser.parse( CL_OPTIONS, args );
  +
  +            File dir = getWorkingDirectory( line );
  +            Artifact artifact = getDefaultImplementation( dir, line );
  +            File system = getMerlinSystemRepository( line );
  +
  +            if( line.hasOption( "version" ) )
  +            {
  +                Main.printVersionInfo( system, artifact );
  +                return;     
  +            }
  +            else if( line.hasOption( "help" ) )
  +            {
  +                if( line.hasOption( "lang" ) )
  +                {
  +                    ResourceManager.clearResourceCache();
  +                    String language = line.getOptionValue( "lang" );
  +                    Locale locale = new Locale( language, "" );
  +                    Locale.setDefault( locale );
  +                    REZ = ResourceManager.getPackageResources( Main.class );
  +                }
  +                Main.printHelpInfo();
  +                return;
  +            }
  +            else
  +            {
  +                //
  +                // setup the initial context
  +                //
  +
  +                ClassLoader parent = Main.class.getClassLoader();
  +                Artifact impl = null; // default
  +                String[] bootstrap = null; // default
  +                
  +                InitialContext context = 
  +                   new DefaultInitialContext( 
  +                     dir, parent, impl, system, bootstrap );
  +
  +                //
  +                // process the commandline and do the real work
  +                //
  +
  +                MAIN = new Main( context, artifact, line );
  +
  +            }
  +        }
  +        catch( Throwable e )
  +        {
  +            String msg = 
  +              ExceptionHelper.packException( e, true );
  +            System.err.println( msg );
  +            System.exit( -1 );
  +        }
  +    }
  +
       //----------------------------------------------------------
       // immutable state
       //----------------------------------------------------------
  @@ -358,74 +426,6 @@
       }
   
      /**
  -    * Main command line enty point.
  -    * @param args the command line arguments
  -    */
  -    public static void main( String[] args )
  -    {
  -        try
  -        {
  -            //
  -            // parse the commandline
  -            //
  -
  -            CommandLineParser parser = new BasicParser();
  -            CommandLine line = parser.parse( CL_OPTIONS, args );
  -
  -            File dir = getWorkingDirectory( line );
  -            Artifact artifact = getDefaultImplementation( dir, line );
  -            File system = getMerlinSystemRepository( line );
  -
  -            if( line.hasOption( "version" ) )
  -            {
  -                Main.printVersionInfo( system, artifact );
  -                return;     
  -            }
  -            else if( line.hasOption( "help" ) )
  -            {
  -                if( line.hasOption( "lang" ) )
  -                {
  -                    ResourceManager.clearResourceCache();
  -                    String language = line.getOptionValue( "lang" );
  -                    Locale locale = new Locale( language, "" );
  -                    Locale.setDefault( locale );
  -                    REZ = ResourceManager.getPackageResources( Main.class );
  -                }
  -                Main.printHelpInfo();
  -                return;
  -            }
  -            else
  -            {
  -                //
  -                // setup the initial context
  -                //
  -
  -                ClassLoader parent = Main.class.getClassLoader();
  -                Artifact impl = null; // default
  -                String[] bootstrap = null; // default
  -                
  -                InitialContext context = 
  -                   new DefaultInitialContext( 
  -                     dir, parent, impl, system, bootstrap );
  -
  -                //
  -                // process the commandline and do the real work
  -                //
  -
  -                MAIN = new Main( context, artifact, line );
  -
  -            }
  -        }
  -        catch( Throwable e )
  -        {
  -            String msg = 
  -              ExceptionHelper.packException( e, true );
  -            System.err.println( msg );
  -            System.exit( -1 );
  -        }
  -    }
  -
  -   /**
       * Resolve the merlin.dir value.
       * @param line the command line construct
       * @return the working directory
  @@ -435,7 +435,7 @@
           if( line.hasOption( "home" ) )
           {
               String dir = line.getOptionValue( "home" );
  -            return new File( dir );
  +            return new File( dir ).getCanonicalFile();
           }
           else
           {
  
  
  
  1.3       +6 -2      avalon/merlin/kernel/impl/conf/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/conf/merlin.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- merlin.properties 9 Dec 2003 09:18:44 -0000       1.2
  +++ merlin.properties 9 Dec 2003 13:46:33 -0000       1.3
  @@ -33,9 +33,13 @@
   #
   # The partition root directory.  The partition root directory serves as 
   # the root anchor for the establishment of the directory supplied to a 
  -# component via the urn:avalon:home context value.
  +# component via the urn:avalon:home context value. If undefined, the 
  +# value defaults to ${merlin.dir}/home overwise a relative value will 
  +# be resolved relative to the ${merlin.dir} directory or if absolute, 
  +#the absolute value will be returned.
  +#
  +# merlin.context = ${merlin.dir}/home
   #
  -merlin.context = ${merlin.dir}/home
   
   #
   # The root anchor directory from which extension directory references
  
  
  
  1.4       +22 -7     
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java
  
  Index: DefaultCriteria.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultCriteria.java      9 Dec 2003 10:14:32 -0000       1.3
  +++ DefaultCriteria.java      9 Dec 2003 13:46:33 -0000       1.4
  @@ -137,10 +137,9 @@
           new Parameter( 
             MERLIN_TEMP, File.class, TEMP_DIR ),
           new Parameter( 
  -          MERLIN_CONTEXT,
  -          File.class, new File( USER_DIR, "home" ) ),
  +          MERLIN_CONTEXT, File.class, null ),
           new Parameter( 
  -          MERLIN_ANCHOR, File.class, USER_DIR ),
  +          MERLIN_ANCHOR, File.class, null ),
           new Parameter( 
             MERLIN_INFO, Boolean.class, new Boolean( false ) ),
           new Parameter( 
  @@ -437,11 +436,19 @@
       * runtime home directories will be established for 
       * components referencing urn:avalon:home
       *
  -    * @return the conext directory
  +    * @return the context directory
       */
       public File getContextDirectory()
       {
  -        return (File) get( MERLIN_CONTEXT );
  +        File context = (File) get( MERLIN_CONTEXT );
  +        if( null == context )
  +        {
  +            return new File( getWorkingDirectory(), "home" );
  +        }
  +        else
  +        {
  +            return resolveWorkingFile( context );
  +        }
       }
   
      /**
  @@ -452,7 +459,8 @@
       */
       public File getAnchorDirectory()
       {
  -        return (File) get( MERLIN_ANCHOR );
  +        File anchor = (File) get( MERLIN_ANCHOR );
  +        return resolveWorkingFile( anchor );
       }
   
      /**
  @@ -512,6 +520,13 @@
       //--------------------------------------------------------------
       // internal
       //--------------------------------------------------------------
  +
  +    private File resolveWorkingFile( File file )
  +    {
  +        if( null == file ) return getWorkingDirectory();
  +        if( file.isAbsolute() ) return file;
  +        return new File( getWorkingDirectory(), file.toString() );
  +    }
   
       private void printProperties( Properties properties, String label )
       {
  
  
  
  1.4       +64 -0     
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultFactory.java       9 Dec 2003 11:51:33 -0000       1.3
  +++ DefaultFactory.java       9 Dec 2003 13:46:33 -0000       1.4
  @@ -286,6 +286,68 @@
               }
   
               buffer.append( "\n" );
  +
  +            buffer.append( 
  +              "\n  ${merlin.repository} == " 
  +              + criteria.getRepositoryDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.lang} == " 
  +              + criteria.getLanguageCode() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.home} == " 
  +              + criteria.getHomeDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.system} == " 
  +              + criteria.getSystemDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.config} == " 
  +              + criteria.getConfigDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.kernel} == " 
  +              + criteria.getKernelURL() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.override} == " 
  +              + criteria.getOverridePath() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.dir} == " 
  +              + criteria.getWorkingDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.temp} == " 
  +              + criteria.getTempDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.context} == " 
  +              + criteria.getContextDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.anchor} == " 
  +              + criteria.getAnchorDirectory() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.info} == " 
  +              + criteria.isInfoEnabled() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.debug} == " 
  +              + criteria.isDebugEnabled() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.server} == " 
  +              + criteria.isServerEnabled() );
  +
  +            buffer.append( 
  +              "\n  ${merlin.autostart} == " 
  +              + criteria.isAutostartEnabled() );
  +
  +            /*
               Iterator keys = criteria.keySet().iterator();
               while( keys.hasNext() )
               {
  @@ -296,6 +358,8 @@
                       buffer.append( "\n  ${" + key + "} == " + value );
                   }
               }
  +            */
  +
               buffer.append( "\n  ${merlin.deployment} == " );
               URL[] urls = criteria.getDeploymentURLs();
               for( int i=0; i<urls.length; i++ )
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to