mcconnell    2004/02/20 14:49:57

  Modified:    merlin/kernel/impl maven.xml project.properties
               merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl
                        DefaultCriteria.java
               merlin/kernel/unit merlin.properties
               merlin   maven.xml
               merlin/platform/tutorials/context/strategy project.xml
               merlin/platform/tutorials/context/strategy/src/java/tutorial
                        DemoContextualizationHandler.java
               merlin/platform/tutorials/hello merlin.properties
               merlin/platform/tutorials/lifecycle/activation/src/java/tutorial
                        DemonstratableProvider.java
  Log:
  Update criteria management to leverage the improved defaults code, improve the 
maven.xml scripts concerning default static properties handling, and update tutorials 
to reflect changes in the composition and activation apis.
  
  Revision  Changes    Path
  1.8       +19 -0     avalon/merlin/kernel/impl/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/maven.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- maven.xml 14 Feb 2004 21:33:56 -0000      1.7
  +++ maven.xml 20 Feb 2004 22:49:56 -0000      1.8
  @@ -16,6 +16,24 @@
     -->
   
     <postGoal name="java:compile">
  +
  +    <ant:copy toFile="${maven.build.dir}/classes/merlin.properties">
  +      <fileset dir="${basedir}/conf">
  +        <include name="merlin.template"/>
  +      </fileset>
  +      <filterset>
  +        <filter token="MERLIN_IMPLEMENTATION" 
  +           value="artifact:${pom.groupId}/${pom.artifactId}#${pom.currentVersion}"/>
  +        <filter token="LOGGING_IMPLEMENTATION" 
  +           value="${merlin.logging.implementation}"/>
  +        <filter token="STANDARD_RUNTIME" 
  +           value="${merlin.runtime.standard.implementation}"/>
  +        <filter token="SECURE_RUNTIME" 
  +           value="${merlin.runtime.csi.implementation}"/>
  +      </filterset>
  +    </ant:copy>
  +
  +    <!--
       <ant:echo file="${maven.build.dir}/classes/merlin.properties">
   #
   # merlin system implementation
  @@ -37,6 +55,7 @@
   # EOF
   #
   </ant:echo>
  +    -->
       <ant:mkdir dir="${maven.repo.local}/${pom.groupId}/properties"/>
       <ant:copy toDir="${maven.repo.local}/${pom.groupId}/properties" 
          file="${maven.build.dir}/classes/merlin.properties" verbose="yes"/>
  
  
  
  1.6       +3 -3      avalon/merlin/kernel/impl/project.properties
  
  Index: project.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/project.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.properties        14 Feb 2004 21:33:56 -0000      1.5
  +++ project.properties        20 Feb 2004 22:49:56 -0000      1.6
  @@ -8,6 +8,6 @@
   # default logging strategy
   #
   
  -merlin.logging.implementation = 
artifact:avalon-logging/avalon-logkit-impl?version=1.0-SNAPSHOT
  -merlin.runtime.standard.implementation = 
artifact:avalon-activation/avalon-activation-impl?version=2.0-SNAPSHOT
  -merlin.runtime.csi.implementation = 
artifact:avalon-activation/avalon-activation-csi?version=2.0-SNAPSHOT
  +merlin.logging.implementation = 
artifact:avalon-logging/avalon-logkit-impl#1.0-SNAPSHOT
  +merlin.runtime.standard.implementation = 
artifact:avalon-activation/avalon-activation-impl#2.0-SNAPSHOT
  +merlin.runtime.csi.implementation = 
artifact:avalon-activation/avalon-activation-csi#2.0-SNAPSHOT
  
  
  
  1.22      +43 -133   
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultCriteria.java      14 Feb 2004 21:33:56 -0000      1.21
  +++ DefaultCriteria.java      20 Feb 2004 22:49:56 -0000      1.22
  @@ -39,6 +39,7 @@
   
   import org.apache.avalon.util.defaults.Defaults;
   import org.apache.avalon.util.defaults.DefaultsFinder;
  +import org.apache.avalon.util.defaults.DefaultsBuilder;
   import org.apache.avalon.util.defaults.SimpleDefaultsFinder;
   import org.apache.avalon.util.defaults.SystemDefaultsFinder;
   import org.apache.avalon.util.env.Env;
  @@ -227,145 +228,54 @@
   
           m_context = context;
   
  -        //
  -        // static defaults are the most primative
  -        //
  -
  -        Properties avalonStatic = getStaticProperties( AVALON_PROPERTIES );
  -        Properties merlinStatic = getStaticProperties( MERLIN_PROPERTIES );
  -
  -        //
  -        // then comes environment variables
  -        //
  -
  -        Properties env = getEnvinronment();
  -
  -        //
  -        // then the system properites
  -        //
  -
  -        Properties system = System.getProperties();
  -
  -        //
  -        // get the application properties
  -        //
  -
  -        Properties avalonSystem = 
  -          getLocalProperties( getAvalonHomeDirectory(), AVALON_PROPERTIES );
  -        Properties merlinSystem = 
  -          getLocalProperties( getMerlinHomeDirectory(), MERLIN_PROPERTIES );
  -
  -        //
  -        // ${user.home} overrides environment
  -        //
  -
  -        Properties avalonHome = 
  -          getLocalProperties( USER_HOME, AVALON_PROPERTIES );
  -        Properties merlinHome = 
  -          getLocalProperties( USER_HOME, MERLIN_PROPERTIES );
  -
  -        //
  -        // and ${merlin.dir} overrides ${user.home}
  -        //
  -
  -        File work = getWorkingDirectory();
  -        Properties avalonWork = 
  -          getLocalProperties( work, AVALON_PROPERTIES );
  -        Properties merlinWork = 
  -          getLocalProperties( work, MERLIN_PROPERTIES );
  -
  -        //
  -        // Create the finder (discovery policy), construct the defaults, and
  -        // macro expand the values.
  -        //
  -
  -        final Properties[] parameters = 
  -          new Properties[] { 
  -            avalonStatic, 
  -            merlinStatic, 
  -            avalonSystem, 
  -            merlinSystem, 
  -            env, 
  -            avalonHome, 
  -            avalonWork, 
  -            merlinHome, 
  -            merlinWork };
  -
  -        final DefaultsFinder[] finders = 
  -          new DefaultsFinder[]{
  -            new SimpleDefaultsFinder( 
  -              parameters, 
  -              false ), 
  -            new SystemDefaultsFinder() 
  -          };
  -        
  -        Defaults defaults = 
  -          new Defaults( 
  -             Parameter.getKeys( super.getParameters() ), new String[0], finders );
  -
  -        //printProperties( defaults, "defaults" );
  -
  -        //
  -        // add ${merlin.dir} to assist in synbol expansion then expand
  -        // symbols (done twice to handle nested defintions)
  -        //
  -
  -        defaults.setProperty( "merlin.dir", work.toString() );
  -        Defaults.macroExpand( defaults, new Properties[]{ system, avalonStatic, env 
} );
  -        Defaults.macroExpand( defaults, new Properties[]{ system, avalonStatic, env 
} );
  -
  -        //
  -        // following aquistion of the default parameters we need to assign
  -        // them as criteria values before we expose the criteria instance to the
  -        // client
  -        //
  -
  -        put( "merlin.dir", work.toString() );
  -        ArrayList errors = new ArrayList();
  -        Parameter[] params = super.getParameters();
  -        for( int i=0; i<params.length; i++ )
  +        try
           {
  -            Parameter param = params[i];
  -            final String key = param.getKey();
  -            if( !key.equals( "merlin.dir" ) && !key.equals( "merlin.implementation" 
))
  +            final String key = context.getApplicationKey();
  +            final File work = context.getInitialWorkingDirectory();
  +            DefaultsBuilder builder = new DefaultsBuilder( key, work );
  +            Properties defaults = 
  +              Defaults.getStaticProperties( DefaultCriteria.class, 
"/merlin.properties" );
  +
  +            //
  +            // set the ${merlin.dir} value 
  +            //
  +
  +            defaults.setProperty( "merlin.dir", getWorkingDirectory().toString() );
  +
  +            //
  +            // get the consolidated properties
  +            //
  +
  +            final String[] keys = super.getKeys();
  +            Properties properties = 
  +              builder.getConsolidatedProperties( defaults, keys );
  +
  +            //
  +            // expand the properties
  +            //
  +
  +            Defaults.macroExpand( properties, new Properties[0] );
  +            Defaults.macroExpand( properties, new Properties[0] );
  +
  +            //
  +            // apply any non-null properties to the criteria
  +            //
  +
  +            for( int i=0; i<keys.length; i++ )
               {
  -                try
  -                {
  -                    put( key, defaults.getProperty( key ) );
  -                }
  -                catch( Exception re )
  +                final String propertyKey = keys[i];
  +                final String value = properties.getProperty( propertyKey );
  +                if( null != value )
                   {
  -                    errors.add( re );
  +                    put( propertyKey, value );
                   }
               }
           }
  -
  -        //
  -        // check for any errors created in the process and dump a 
  -        // notice to System.err
  -        //
  -
  -        if( errors.size() > 0 )
  +        catch( Throwable e )
           {
  -            Throwable[] throwables = 
  -              (Throwable[]) errors.toArray( new Throwable[0] );
  -            
  -            if( errors.size() > 1 )
  -            {
  -                final String report = 
  -                  "Multiple errors (ignored) while resolving defaults.";
  -                String message = 
  -                  ExceptionHelper.packException( report, throwables, false );
  -                System.err.println( message );
  -            }
  -            else
  -            {
  -                final String report = 
  -                  "One error (ignored) occured while resolving defaults.";
  -                String message = 
  -                  ExceptionHelper.packException( report, throwables[0], false );
  -                System.err.println( message );
  -            }
  +            final String error = 
  +              "Unexpected error while constructing criteria defaults.";
  +            throw new KernelRuntimeException( error, e );
           }
       }
   
  
  
  
  1.5       +0 -1      avalon/merlin/kernel/unit/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/merlin.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- merlin.properties 20 Jan 2004 01:28:48 -0000      1.4
  +++ merlin.properties 20 Feb 2004 22:49:56 -0000      1.5
  @@ -3,4 +3,3 @@
   merlin.debug = false
   merlin.deployment = conf/hello.block
   merlin.override = conf/override.xml
  -#merlin.implementation = merlin:merlin-impl;SNAPSHOT
  
  
  
  1.54      +1 -1      avalon/merlin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/maven.xml,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- maven.xml 19 Feb 2004 08:58:05 -0000      1.53
  +++ maven.xml 20 Feb 2004 22:49:56 -0000      1.54
  @@ -580,7 +580,7 @@
         basedir="${basedir}"
         includes="platform/tutorials/**/project.xml"
         excludes="platform/tutorials/project.xml,**/target/**"
  -      goals=""
  +      goals="jar:install"
         banner="Validate:"
         ignoreFailures="false" />
     </goal>
  
  
  
  1.7       +2 -2      avalon/merlin/platform/tutorials/context/strategy/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/platform/tutorials/context/strategy/project.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- project.xml       13 Jan 2004 11:41:28 -0000      1.6
  +++ project.xml       20 Feb 2004 22:49:57 -0000      1.7
  @@ -24,8 +24,8 @@
         <version>4.1.5</version>
       </dependency>
       <dependency>
  -      <groupId>avalon-activation</groupId>
  -      <artifactId>avalon-activation-api</artifactId>
  +      <groupId>avalon-composition</groupId>
  +      <artifactId>avalon-composition-api</artifactId>
         <version>2.0-SNAPSHOT</version>
       </dependency>
     </dependencies>
  
  
  
  1.3       +1 -1      
avalon/merlin/platform/tutorials/context/strategy/src/java/tutorial/DemoContextualizationHandler.java
  
  Index: DemoContextualizationHandler.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/platform/tutorials/context/strategy/src/java/tutorial/DemoContextualizationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DemoContextualizationHandler.java 24 Jan 2004 23:25:34 -0000      1.2
  +++ DemoContextualizationHandler.java 20 Feb 2004 22:49:57 -0000      1.3
  @@ -20,7 +20,7 @@
   import java.lang.reflect.Constructor;
   import java.util.Map;
   
  -import org.apache.avalon.activation.lifecycle.ContextualizationHandler;
  +import org.apache.avalon.composition.model.ContextualizationHandler;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Context;
   
  
  
  
  1.8       +1 -1      avalon/merlin/platform/tutorials/hello/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/platform/tutorials/hello/merlin.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- merlin.properties 10 Feb 2004 19:54:29 -0000      1.7
  +++ merlin.properties 20 Feb 2004 22:49:57 -0000      1.8
  @@ -1,3 +1,3 @@
   
  -merlin.info = false
  +merlin.info = true
   merlin.debug = false
  
  
  
  1.4       +3 -1      
avalon/merlin/platform/tutorials/lifecycle/activation/src/java/tutorial/DemonstratableProvider.java
  
  Index: DemonstratableProvider.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/platform/tutorials/lifecycle/activation/src/java/tutorial/DemonstratableProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DemonstratableProvider.java       24 Jan 2004 23:25:34 -0000      1.3
  +++ DemonstratableProvider.java       20 Feb 2004 22:49:57 -0000      1.4
  @@ -17,12 +17,14 @@
   
   package tutorial;
   
  -import org.apache.avalon.activation.lifecycle.LifecycleCreateExtension;
  +import org.apache.avalon.composition.model.LifecycleCreateExtension;
   import org.apache.avalon.composition.model.ComponentModel;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +
   import org.apache.avalon.meta.info.StageDescriptor;
   
   /**
  
  
  

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

Reply via email to