avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/tools/ant MetaTask.java
Date Thu, 08 May 2003 03:02:40 GMT
mcconnell    2003/05/07 20:02:40

  Modified:    merlin   maven.xml
               merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl
                        DefaultAppliance.java DefaultApplianceFactory.java
               merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl
                        DefaultTypeRepository.java EngineClassLoader.java
                        Resources.properties
               merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl
                        DefaultContextualizationService.java
                        DefaultDeploymentService.java
               merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl
                        AbstractLifestyleHandler.java
                        DefaultLifestyleService.java
               merlin/assembly/src/java/org/apache/avalon/assembly/locator/impl
                        DefaultLocator.java
               merlin/assembly/src/test/org/apache/avalon/assembly/engine
                        EngineTestCase.java FactoryTestCase.java
               merlin/merlin-cli/src/java Merlin.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        StandardBlock.java StandardBlock.xinfo
                        StandardBlockLoader.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl
                        DefaultKernel.java DefaultKernelLoader.java
               merlin/merlin-plugin plugin.jelly plugin.properties
                        project.xml
               merlin/merlin-smp/xdocs/starting/hello creation.xml
               merlin/merlin-spi/src/java/org/apache/avalon/merlin/kernel
                        Kernel.java
               merlin/meta/src/java/org/apache/avalon/meta/info/builder
                        XMLServiceCreator.java
               merlin/meta-tools/src/java/org/apache/avalon/meta/info/builder
                        XMLServiceWriter.java XMLTypeWriter.java
               merlin/meta-tools/src/java/org/apache/avalon/meta/tools/ant
                        MetaTask.java
  Added:       merlin/merlin-plugin/src/java/org/apache/avalon/merlin/tools
                        MerlinBean.java
  Log:
  Updates related to the integration of the support for the execution of Merlin as a Maven plugin.
  
  Revision  Changes    Path
  1.12      +1 -1      avalon-sandbox/merlin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/maven.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- maven.xml	28 Apr 2003 21:19:42 -0000	1.11
  +++ maven.xml	8 May 2003 03:02:39 -0000	1.12
  @@ -266,7 +266,7 @@
         basedir="${basedir}"
         includes="merlin-plugin/project.xml"
         goals="plugin:install"
  -      banner="Resolving dependencies:"
  +      banner="Installing plugin:"
         ignoreFailures="false"/>
     </goal>
   
  
  
  
  1.7       +29 -7     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultAppliance.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultAppliance.java	1 May 2003 10:45:23 -0000	1.6
  +++ DefaultAppliance.java	8 May 2003 03:02:39 -0000	1.7
  @@ -262,6 +262,9 @@
        */
       private ApplianceRepository m_repository;
   
  +    private boolean m_contextualized = false;
  +    private boolean m_initialized = false;
  +
       //=====================================================================
       // Contextualizable
       //=====================================================================
  @@ -273,11 +276,13 @@
        */
       public void contextualize( Locator context ) throws ContextException
       {
  +        getLogger().debug( "appliance contextualization" );
           m_applianceContext = (ApplianceContext) context.get( ApplianceContext.KEY );
           m_lifestyle = (LifestyleService) context.get( LifestyleService.KEY );
           m_engine = (EngineClassLoader) context.get( APPLIANCE_ENGINE_KEY );
           m_system = (Locator) context.get( APPLIANCE_SYSTEM_KEY );
           m_repository = (ApplianceRepository) context.get( APPLIANCE_REPOSITORY_KEY );
  +        m_contextualized = true;
       }
   
       //=====================================================================
  @@ -286,7 +291,9 @@
   
       public void initialize() throws Exception
       {
  -        if( m_applianceContext == null )
  +        getLogger().debug( "appliance initialization" );
  +      
  +        if( !m_contextualized )
           {
               throw new IllegalStateException( "contextualization" );
           }
  @@ -295,7 +302,7 @@
           try
           {
               m_class = m_engine.loadClass( classname );
  -        } 
  +        }
           catch( Throwable e )
           {
               final String error =
  @@ -304,6 +311,7 @@
               throw new ApplianceException( error, e );
           }
   
  +
           m_name = m_applianceContext.getName();
           m_path = m_applianceContext.getPartitionName() + m_name;
   
  @@ -318,7 +326,8 @@
           catch( Throwable e )
           {
               final String error =
  -                    "Unexpected lifestyle handler establishment failure in appliance: " + this;
  +              "Unexpected lifestyle handler establishment failure in appliance: " 
  +              + this;
               throw new ApplianceException( error, e );
           }
   
  @@ -327,6 +336,8 @@
               final String message = "created appliance: " + this + ", for: " + classname;
               getLogger().debug( message );
           }
  +
  +        m_initialized = true;
       }
   
       //=====================================================================
  @@ -359,6 +370,11 @@
       public Object resolve( Object source, String ref )
               throws LocatorException
       {
  +        if( !m_initialized )
  +        {
  +            throw new IllegalStateException( "initialization" );
  +        }
  +
           if( !m_assembled )
           {
               final String message =
  @@ -412,7 +428,8 @@
           try
           {
               m_handler.release( object, source );
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Lifestyle handler raised a release error in appliance: " + this;
  @@ -639,6 +656,11 @@
        */
       public void assemble( DependencyGraph graph ) throws ApplianceException
       {
  +        if( !m_initialized )
  +        {
  +            throw new IllegalStateException( "initialization" );
  +        }
  +
           if( m_assembled )
           {
               return;
  @@ -782,8 +804,8 @@
           } catch( Throwable e )
           {
               final String error =
  -                    "Unexpected exception while preparing deployment context in appliance: "
  -                    + this;
  +              "Unexpected exception while preparing deployment context in appliance: "
  +              + this;
               throw new ApplianceException( error, e );
           }
   
  
  
  
  1.7       +21 -5     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultApplianceFactory.java
  
  Index: DefaultApplianceFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/impl/DefaultApplianceFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultApplianceFactory.java	30 Apr 2003 02:03:41 -0000	1.6
  +++ DefaultApplianceFactory.java	8 May 2003 03:02:39 -0000	1.7
  @@ -334,6 +334,13 @@
               throw new NullPointerException( "logger" );
           }
   
  +        if( m_repository == null )
  +        {
  +            final String error = 
  +              "Appliance factory has not been contextualized.";
  +            throw new IllegalStateException( error );
  +        }
  +
           //
           // create the lifestyle service
           //
  @@ -345,12 +352,12 @@
           try
           {
               locator = new DefaultLocator( context );
  +            locator.put( PoolManager.ROLE, m_pool );
               locator.put( LifestyleService.KEY, lifestyle );
               locator.put( ApplianceRepository.KEY, m_repository );
               locator.put( ApplianceContext.KEY, context );
               locator.put( "urn:assembly:engine", engine );
               locator.put( "urn:assembly:appliance.system", system );
  -            locator.put( PoolManager.ROLE, m_pool );
               locator.makeReadOnly();
           }
           catch( Throwable e )
  @@ -364,6 +371,8 @@
           if( (classname == null)
                   || (classname.equals( DefaultAppliance.class.getName() )) )
           {
  +            getLogger().debug( "creating a classic appliance" );
  +
               //
               // bootstrap the appliance using DefaultAppliance
               //
  @@ -385,6 +394,8 @@
           } 
           else
           {
  +            getLogger().debug( "custom appliance using: " + classname );
  +
               //
               // its a custom appliance so in this case we use an apppliance to
               // construct the appliance
  @@ -411,17 +422,22 @@
                   cntx.makeReadOnly();
   
                   Appliance appliance = engine.createAppliance( cntx, false );
  +
                   appliance.assemble( new DependencyGraph() );
  +
                   Object object = appliance.resolve( this );
  +
                   if( object instanceof Appliance )
                   {
                       return (Appliance) object;
  -                } 
  +                }
                   else
                   {
                       final String error =
  -                            "Supplied classname '" + classname
  -                            + "' does not implement the Appliance interface.";
  +                       "Supplied classname '" + classname
  +                       + "' does not implement the Appliance interface."
  +                       + "\nclass: " + object.getClass().getName()
  +                       + "\nobject: " + object;
                       throw new ApplianceException( error );
                   }
               } 
  
  
  
  1.2       +4 -4      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/DefaultTypeRepository.java
  
  Index: DefaultTypeRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/DefaultTypeRepository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTypeRepository.java	29 Apr 2003 14:39:43 -0000	1.1
  +++ DefaultTypeRepository.java	8 May 2003 03:02:39 -0000	1.2
  @@ -165,9 +165,9 @@
           } catch( Throwable e )
           {
               final String error =
  -                    "Could not register a type relative to the path: "
  -                    + clazz.getName()
  -                    + " due to a type build error.";
  +              "Could not register a type relative to the path: "
  +              + clazz.getName()
  +              + " due to a type build error.";
               throw new TypeException( error, e );
           }
       }
  
  
  
  1.5       +2 -2      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/EngineClassLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EngineClassLoader.java	30 Apr 2003 02:03:41 -0000	1.4
  +++ EngineClassLoader.java	8 May 2003 03:02:39 -0000	1.5
  @@ -1066,7 +1066,7 @@
               throw new NullPointerException( "context" );
           }
   
  -        Logger logger = getLogger();
  +        Logger logger = getLogger().getChildLogger( context.getName() );
   
           String classname = context.getApplianceFactoryClassname();
           ApplianceFactory factory;
  
  
  
  1.2       +1 -1      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/impl/Resources.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Resources.properties	26 Apr 2003 12:37:44 -0000	1.1
  +++ Resources.properties	8 May 2003 03:02:39 -0000	1.2
  @@ -1,5 +1,5 @@
   
  -initialization=initialization
  +initialization=engine initialization
   kernel.extension=including kernel extension dir: {0} 
   system.extension=including system extension dir: {0} 
   relative.extension=including relative extension dir: {0} 
  
  
  
  1.2       +2 -1      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultContextualizationService.java
  
  Index: DefaultContextualizationService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultContextualizationService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultContextualizationService.java	29 Apr 2003 00:55:46 -0000	1.1
  +++ DefaultContextualizationService.java	8 May 2003 03:02:39 -0000	1.2
  @@ -136,6 +136,7 @@
                   //
                   // its classic Avalon contextulization
                   //
  +
                   Contextualization contextualizer = new AvalonContextualizer();
                   if( getLogger().isDebugEnabled() )
                   {
  
  
  
  1.7       +13 -2     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java
  
  Index: DefaultDeploymentService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifecycle/impl/DefaultDeploymentService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultDeploymentService.java	29 Apr 2003 23:35:24 -0000	1.6
  +++ DefaultDeploymentService.java	8 May 2003 03:02:39 -0000	1.7
  @@ -132,7 +132,8 @@
       {
           try
           {
  -            final DefaultContextualizationService service = new DefaultContextualizationService();
  +            final DefaultContextualizationService service = 
  +              new DefaultContextualizationService();
               service.enableLogging( getLogger().getChildLogger( "context" ) );
               m_contextualization = service;
           }
  @@ -173,6 +174,11 @@
               throw new NullPointerException( "classloader" );
           }
   
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "initiating deployment: " + appliance );
  +        }
  +
           Object instance;
           try
           {
  @@ -403,6 +409,11 @@
       private void handleLogging( Appliance appliance, LogEnabled object ) throws Exception
       {
           String path = appliance.getPath();
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( "assigning logging channel" );
  +        }
       
           LoggingDirective logging = appliance.getLoggingDirective();
           m_logging.addCategories( path, logging );
  
  
  
  1.2       +14 -3     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/AbstractLifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractLifestyleHandler.java	26 Apr 2003 12:37:47 -0000	1.1
  +++ AbstractLifestyleHandler.java	8 May 2003 03:02:39 -0000	1.2
  @@ -120,8 +120,19 @@
       public void contextualize( Locator context ) throws ContextException
       {
           m_classloader = (ClassLoader) context.get( "urn:avalon:classloader" );
  -        m_appliance = (Appliance) context.get( "urn:assembly:appliance.target" );
  -        m_deployment = (DeploymentService) context.get( "urn:assembly:lifecycle.deployment" );
  +        m_deployment = 
  +          (DeploymentService) context.get( "urn:assembly:lifecycle.deployment" );
  +        Object object = context.get( "urn:assembly:appliance.target" );
  +        if( object instanceof Appliance )
  +        {
  +            m_appliance = (Appliance) object;
  +        }
  +        else
  +        {
  +            final String error =
  +              "Supplied appliance is not an instance of Appliance. Object: " + object;
  +            throw new IllegalStateException( error );
  +        }
       }
   
       //==============================================================
  
  
  
  1.3       +6 -4      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java
  
  Index: DefaultLifestyleService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/impl/DefaultLifestyleService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultLifestyleService.java	29 Apr 2003 23:35:25 -0000	1.2
  +++ DefaultLifestyleService.java	8 May 2003 03:02:39 -0000	1.3
  @@ -156,6 +156,7 @@
           {
               throw new NullPointerException( "appliance" );
           }
  +
           if( classloader == null )
           {
               throw new NullPointerException( "classloader" );
  @@ -166,13 +167,14 @@
           //
   
           DefaultLocator context = new DefaultLocator( m_context );
  +        context.put( 
  +          "urn:assembly:appliance.target", new ApplianceHolder( appliance ) );
  +        context.put( "urn:avalon:classloader", classloader );
  +        context.put( DeploymentService.KEY, m_deployment );
           if( deploymentContext != null )
           {
               context.put( "urn:assembly:deployment.context", deploymentContext );
           }
  -        context.put( "urn:assembly:appliance.target", new ApplianceHolder( appliance ) );
  -        context.put( "urn:avalon:classloader", classloader );
  -        context.put( DeploymentService.KEY, m_deployment );
           context.makeReadOnly();
   
           //
  
  
  
  1.2       +27 -5     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/locator/impl/DefaultLocator.java
  
  Index: DefaultLocator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/locator/impl/DefaultLocator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLocator.java	26 Apr 2003 12:37:47 -0000	1.1
  +++ DefaultLocator.java	8 May 2003 03:02:39 -0000	1.2
  @@ -199,8 +199,8 @@
       {
           try
           {
  -            getObject( m_dictionary.translate( key ) );
  -            return true;
  +            Object object = getObject( m_dictionary.translate( key ) );
  +            return object != null;
           } catch( ContextException le )
           {
               return false;
  @@ -243,7 +243,8 @@
           if( m_parent instanceof DefaultLocator )
           {
               return ((DefaultLocator) m_parent).getObject( key );
  -        } else
  +        } 
  +        else
           {
               return m_parent.get( key );
           }
  @@ -259,16 +260,36 @@
       public Object get( final Object key ) throws ContextException
       {
           final Object data = getObject( m_dictionary.translate( key ) );
  +        if( data == null )
  +        {
  +            final String error =
  +              "Unexpected state. Mapped source returned a null object reference.";
  +                throw new IllegalStateException( error );
  +        }
  +
           if( data instanceof Reclaimable )
           {
               Object object = ((Resolvable) data).resolve( this );
  +            if( object == null )
  +            {
  +                final String error =
  +                  "Unexpected state. Reclaimable source returned a null object reference.";
  +                throw new IllegalStateException( error );
  +            }
               m_reclaimers.put( object, data );
               return object;
           }
   
           if( data instanceof Resolvable )
           {
  -            return ((Resolvable) data).resolve( this );
  +            Object resolvable = ((Resolvable) data).resolve( this );
  +            if( resolvable == null )
  +            {
  +                final String error =
  +                  "Unexpected state. Resolvable source returned a null object reference.";
  +                throw new IllegalStateException( error );
  +            }
  +            return resolvable;
           }
   
           return data;
  @@ -317,7 +338,8 @@
           if( null == value )
           {
               m_data.remove( key );
  -        } else
  +        } 
  +        else
           {
               m_data.put( key, value );
           }
  
  
  
  1.9       +4 -2      avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java
  
  Index: EngineTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EngineTestCase.java	30 Apr 2003 02:03:41 -0000	1.8
  +++ EngineTestCase.java	8 May 2003 03:02:39 -0000	1.9
  @@ -278,7 +278,8 @@
               engine.contextualize( context );
               engine.initialize();
               return engine;
  -        } catch( Exception e )
  +        } 
  +        catch( Exception e )
           {
               ExceptionHelper.printException( "Engine setup failure.", e, this, true );
               assertTrue( false );
  @@ -317,7 +318,8 @@
               DefaultPoolManager poolManager =
                       new DefaultPoolManager( commandManager.getCommandSink() );
               return poolManager;
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Internal error during establishment of the default pool manager. Cause: ";
  
  
  
  1.9       +6 -3      avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/FactoryTestCase.java
  
  Index: FactoryTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/test/org/apache/avalon/assembly/engine/FactoryTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FactoryTestCase.java	30 Apr 2003 02:03:41 -0000	1.8
  +++ FactoryTestCase.java	8 May 2003 03:02:39 -0000	1.9
  @@ -126,7 +126,8 @@
               Appliance appliance = m_engine.createAppliance( context, false );
               appliance.assemble( graph );
               assertTrue( appliance.resolve( this ) != null );
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               String error = ExceptionHelper.packException(
                       "failure for create type using : " + classname, e );
  @@ -149,7 +150,8 @@
               engine.contextualize( context );
               engine.initialize();
               return engine;
  -        } catch( Exception e )
  +        }  
  +        catch( Exception e )
           {
               ExceptionHelper.printException( "Engine setup failure.", e, this, true );
               assertTrue( false );
  @@ -188,7 +190,8 @@
               DefaultPoolManager poolManager =
                       new DefaultPoolManager( commandManager.getCommandSink() );
               return poolManager;
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Internal error during establishment of the default pool manager. Cause: ";
  
  
  
  1.10      +1 -1      avalon-sandbox/merlin/merlin-cli/src/java/Merlin.java
  
  Index: Merlin.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-cli/src/java/Merlin.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Merlin.java	25 Apr 2003 07:10:56 -0000	1.9
  +++ Merlin.java	8 May 2003 03:02:40 -0000	1.10
  @@ -276,7 +276,7 @@
               //
   
               map.put( "urn:merlin:classloader.common", COMMON );
  -            map.put( "urn:merlin:classloader.system", CLASSLOADER);
  +            map.put( "urn:merlin:classloader.system", CLASSLOADER );
               map.put( "urn:merlin:home", home );
               map.put( "urn:merlin:system", system );
               map.put( "urn:merlin:kernel.profile", kernel );
  
  
  
  1.6       +6 -0      avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java
  
  Index: StandardBlock.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardBlock.java	29 Apr 2003 21:07:35 -0000	1.5
  +++ StandardBlock.java	8 May 2003 03:02:40 -0000	1.6
  @@ -70,10 +70,12 @@
   import org.apache.avalon.assembly.engine.impl.EngineClassLoader;
   import org.apache.avalon.assembly.locator.Locator;
   import org.apache.avalon.assembly.locator.LocatorException;
  +import org.apache.avalon.assembly.locator.Contextualizable;
   import org.apache.avalon.assembly.util.ExceptionHelper;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.merlin.block.Block;
   import org.apache.avalon.merlin.block.BlockException;
   import org.apache.avalon.merlin.container.Container;
  @@ -271,6 +273,10 @@
       */
       public URL getURL()
       {
  +        if( m_repository == null )
  +        {
  +            throw new IllegalStateException( "repository" );
  +        }
           return m_repository.getURL();
       }
   
  
  
  
  1.5       +1 -0      avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.xinfo
  
  Index: StandardBlock.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.xinfo,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StandardBlock.xinfo	30 Apr 2003 02:03:41 -0000	1.4
  +++ StandardBlock.xinfo	8 May 2003 03:02:40 -0000	1.5
  @@ -37,6 +37,7 @@
     </context>
   
     <services>
  +    <service type="org.apache.avalon.assembly.appliance.Appliance"/>
       <service type="org.apache.avalon.merlin.block.Block"/>
     </services>
   
  
  
  
  1.8       +22 -2     avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlockLoader.java
  
  Index: StandardBlockLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlockLoader.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StandardBlockLoader.java	30 Apr 2003 02:03:41 -0000	1.7
  +++ StandardBlockLoader.java	8 May 2003 03:02:40 -0000	1.8
  @@ -95,6 +95,7 @@
   import org.apache.avalon.merlin.block.impl.VirtualService;
   import org.apache.avalon.merlin.block.impl.XMLContainerCreator;
   import org.apache.avalon.merlin.container.impl.DefaultContainer;
  +import org.apache.avalon.merlin.kernel.Kernel;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.InfoDescriptor;
   import org.apache.avalon.meta.info.ServiceDescriptor;
  @@ -156,6 +157,11 @@
       private File m_home;
   
      /**
  +    * The base directory.
  +    */
  +    private File m_base;
  +
  +   /**
       * Configuration fragments keyed by appliance path.
       */
       private final Map m_library = new Hashtable();
  @@ -212,6 +218,10 @@
           m_common = (ClassLoader) context.get( "urn:merlin:classloader.common" );
           m_domain = (String) context.get( "urn:merlin:domain" );
           m_repository = (Repository) context.get( Repository.KEY );
  +        if( context.hasEntry( Kernel.BASE_KEY ) )
  +        {
  +            m_base = (File) context.get( Kernel.BASE_KEY );
  +        }
       }
   
       //==============================================================
  @@ -395,8 +405,18 @@
   
           try
           {
  +            URL[] urls = null;
  +            if( m_base == null )
  +            {
  +                urls = new URL[]{ getBasePath( url ) };
  +            }
  +            else
  +            {
  +                urls = new URL[]{ m_base.toURL() };
  +            }
  +
               EngineClassLoader engine =
  -              new EngineClassLoader( new URL[]{ getBasePath( url ) }, m_system );
  +              new EngineClassLoader( urls, m_system );
   
               engine.enableLogging( getLogger() );
   
  
  
  
  1.15      +26 -6     avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DefaultKernel.java	29 Apr 2003 21:10:35 -0000	1.14
  +++ DefaultKernel.java	8 May 2003 03:02:40 -0000	1.15
  @@ -157,7 +157,8 @@
       private URL m_override;
   
      /**
  -    * The application home directory.
  +    * The application home directory from which relative references will be 
  +    * resolved.
       */
       private File m_home;
   
  @@ -166,6 +167,12 @@
       */
       private File m_root;
   
  +   /**
  +    * The optional directory that shall be used to establish the inital URL
  +    * supplied to the classloader.
  +    */
  +    private File m_base;
  +
       /**
        * Logging channel for the kernel;
        */
  @@ -288,6 +295,11 @@
       *     <td>{@link java.io.File}</td>
       *     <td>The working home directory.</td>
       *   </tr>
  +    *   <tr>
  +    *     <td><code>urn:merlin:base</code></td>
  +    *     <td>{@link java.io.File}</td>
  +    *     <td>An optional base directory to include in the initial classloader.</td>
  +    *   </tr>
       * </table>
       * @param context the runtime context
       * @exception ContextException if an error occurs during the contextualization phase
  @@ -340,6 +352,11 @@
               m_priority = (String) context.get( "urn:merlin:logging.priority" );
           }
   
  +        if( context.hasEntry( Kernel.BASE_KEY ) )
  +        {
  +            m_base = (File) context.get( Kernel.BASE_KEY );
  +        }
  +
           m_contextualized = true;
       }
   
  @@ -458,6 +475,10 @@
               context.put( "urn:merlin:classloader.system", m_loader );
               context.put( "urn:merlin:classloader.common", m_common );
               context.put( "urn:merlin:domain", m_domain );
  +            if( m_base != null ) 
  +            {
  +                context.put( Kernel.BASE_KEY, m_base );
  +            }
               context.makeReadOnly();
   
               m_installer.contextualize( context );
  @@ -571,8 +592,8 @@
           catch( Throwable e )
           {
               final String error =
  -              "Unable to deploy block.\nBlock: " 
  -              + block.getName() + " due to an assembly failure.";
  +              "Unable to assemble block.\nBlock: " 
  +              + block.getName();
               throw new KernelException( error, e );
           }
   
  @@ -584,8 +605,7 @@
           {
               final String error =
                 "Unable to deploy block.\nBlock: " 
  -              + block.getName() 
  -              + " due to an deployment failure.";
  +              + block.getName();
               throw new KernelException( error, e );
           }
   
  
  
  
  1.6       +2 -4      avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelLoader.java
  
  Index: DefaultKernelLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultKernelLoader.java	26 Apr 2003 12:37:48 -0000	1.5
  +++ DefaultKernelLoader.java	8 May 2003 03:02:40 -0000	1.6
  @@ -7,6 +7,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.util.Map;
  +import java.util.Hashtable;
   
   import org.apache.avalon.assembly.locator.impl.DefaultLocator;
   import org.apache.avalon.assembly.util.ExceptionHelper;
  @@ -81,7 +82,7 @@
   
           //
           // contextualize, configure, initialize and start the kernel
  -        //
  +        //        
   
           Throwable cause = null;
           DefaultLocator context = new DefaultLocator( map );
  @@ -141,9 +142,6 @@
             }
           );
       }
  -
  -
  -
   
       private Configuration getKernelConfiguration( final File file )
         throws ConfigurationException, IOException, SAXException
  
  
  
  1.2       +140 -8    avalon-sandbox/merlin/merlin-plugin/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-plugin/plugin.jelly,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plugin.jelly	29 Mar 2003 03:14:02 -0000	1.1
  +++ plugin.jelly	8 May 2003 03:02:40 -0000	1.2
  @@ -1,12 +1,22 @@
   <?xml version="1.0"?>
   
   <project xmlns:j="jelly:core"
  -         xmlns:util="jelly:util"
  -         xmlns:maven="jelly:maven">
  +  xmlns:define="jelly:define"
  +  xmlns:util="jelly:util"
  +  xmlns:maven="jelly:maven"
  +  xmlns:ant="jelly:ant"
  +  xmlns:merlin="merlin">
  +
  +  <define:taglib uri="merlin">
  +    <define:jellybean
  +      name="test"
  +      className="org.apache.avalon.merlin.tools.MerlinBean"
  +      method="doExecute"
  +      />
  +  </define:taglib>
   
     <taskdef name="meta" classname="org.apache.avalon.meta.tools.ant.MetaTask">
       <classpath>
  -      <pathelement path="${plugin.resources}" />
         <pathelement path="${plugin.getDependencyPath('avalon:avalon-meta-tools')}"/>
         <pathelement path="${plugin.getDependencyPath('avalon:avalon-meta-spi')}"/>
         <pathelement path="${plugin.getDependencyPath('avalon:avalon-meta')}"/>
  @@ -15,21 +25,143 @@
       </classpath>
     </taskdef>
   
  -  <path id="merlin.build.meta.path">
  +  <ant:property name="merlin.build.meta.dir" value="${maven.build.src}"/>
  +  <ant:path id="merlin.build.meta.path">
       <pathelement location="${merlin.build.meta.dir}"/>
  -  </path>
  +  </ant:path>
     <maven:addPath id="maven.compile.src.set" refid="merlin.build.meta.path"/>
   
     <goal name="merlin:meta" 
  -    description="Generate meta info descriptors.">
  +    description="Generate meta info descriptors based on meta tags declared in Java source files for inclusion in a jar file.">
       <echo>meta source dir: ${maven.src.dir}</echo>
       <echo>meta dest dir: ${maven.build.src}</echo>
       <mkdir dir="${maven.build.src}"/>
  -    <meta destDir="${maven.build.src}" format="${merlin.meta.format}" force="${merlin.meta.force}">
  +    <meta destDir="${maven.build.src}" 
  +        format="${merlin.meta.format}" 
  +        force="${merlin.meta.force}">
         <fileset dir="${maven.src.dir}/java">
           <include name="**/*.java"/>
         </fileset>
       </meta>
     </goal>
  -  
  +
  +  <goal name="merlin:deploy"
  +    description="Deployment of a jar file containing a block.xml directive and execution of all components associated with a lauch on startup policy.">
  +
  +    <!--
  +    Assign a value to the merlin.system.dir variable.  If the 
  +    value has already been defined this will fail and the prior
  +    defintion will hold.
  +    -->
  +    <ant:property environment="env"/>
  +    <j:set var="merlin.system" value="${env.MERLIN_HOME}"/>
  +    <j:set var="merlin.system.dir" value="${env.MERLIN_HOME}"/>
  +    <util:file var="sys" name="${merlin.system.dir}"/>
  +    <j:if test="${sys.exists()}">
  +      <j:set var="merlin.system" value="${merlin.system.dir}"/>
  +    </j:if>
  +
  +    <!--
  +    If a kernel configuration has been declared the use it otherwise
  +    we default to the merlin installation kernel definition.
  +    -->
  +    <j:set var="merlin.kernel" value="${env.MERLIN_HOME}/config/kernel.xml"/>
  +    <j:set var="merlin.kernel.config" value="${merlin.kernel}"/>
  +    <util:file var="kernelFile" name="${merlin.kernel.config}"/>
  +    <j:if test="${kernelFile.exists()}">
  +      <j:set var="merlin.kernel" value="${merlin.kernel.config}"/>
  +    </j:if>
  +
  +    <!-- 
  +    Declare the default configuration path which will be overriden
  +    if an merlin.block.config property is set and exists.
  +    -->
  +    <j:set var="merlin.config" value="${maven.conf.dir}/config.xml"/>
  +    <j:set var="merlin.block.config" value="${merlin.config}"/>
  +    <util:file var="configFile" name="${merlin.block.config}"/>
  +    <j:if test="${configFile.exists()}">
  +      <j:set var="merlin.config" value="${merlin.block.config}"/>
  +    </j:if>
  +
  +    <j:set var="merlin.debug" value="${merlin.kernel.debug}"/>
  +    <j:if test="${merlin.debug == null}">
  +      <j:set var="merlin.debug" value="DEBUG"/>
  +    </j:if>
  +
  +    <!--
  +    Launch Merlin with the supplied system, kernel, target and config
  +    paths and internal debug priority.
  +    -->
  +    <merlin:test 
  +      system="${merlin.system}"
  +      kernel="${merlin.kernel}" 
  +      home="${basedir}" 
  +      target="${maven.build.dir}/${maven.final.name}.jar" 
  +      config="${merlin.config}" 
  +      debug="${merlin.debug}" 
  +    />
  +
  +  </goal>
  +
  +  <goal name="merlin:simulate"
  +    description="Simulate the deployment of a block based on a supplied block.xml
  +    directive and a base directory contining classes are related artifacts.">
  +
  +    <!--
  +    Assign a value to the merlin.system.dir variable.  If the 
  +    value has already been defined this will fail and the prior
  +    defintion will hold.
  +    -->
  +    <ant:property environment="env"/>
  +    <j:set var="merlin.system" value="${env.MERLIN_HOME}"/>
  +    <j:set var="merlin.system.dir" value="${env.MERLIN_HOME}"/>
  +    <util:file var="sys" name="${merlin.system.dir}"/>
  +    <j:if test="${sys.exists()}">
  +      <j:set var="merlin.system" value="${merlin.system.dir}"/>
  +    </j:if>
  +
  +    <!--
  +    If a kernel configuration has been declared the use it otherwise
  +    we default to the merlin installation kernel definition.
  +    -->
  +    <j:set var="merlin.kernel" value="${env.MERLIN_HOME}/config/kernel.xml"/>
  +    <j:set var="merlin.kernel.config" value="${merlin.kernel}"/>
  +    <util:file var="kernelFile" name="${merlin.kernel.config}"/>
  +    <j:if test="${kernelFile.exists()}">
  +      <j:set var="merlin.kernel" value="${merlin.kernel.config}"/>
  +    </j:if>
  +
  +    <!-- 
  +    Declare the default configuration path which will be overriden
  +    if an merlin.block.config property is set and exists.
  +    -->
  +    <j:set var="merlin.config" value="${maven.conf.dir}/config.xml"/>
  +    <j:set var="merlin.block.config" value="${merlin.config}"/>
  +    <util:file var="configFile" name="${merlin.block.config}"/>
  +    <j:if test="${configFile.exists()}">
  +      <j:set var="merlin.config" value="${merlin.block.config}"/>
  +    </j:if>
  +
  +    <j:set var="merlin.debug" value="${merlin.kernel.debug}"/>
  +    <j:if test="${merlin.debug == null}">
  +      <j:set var="merlin.debug" value="DEBUG"/>
  +    </j:if>
  +
  +    <!--
  +    Launch Merlin with the supplied system, kernel, target and config
  +    paths and internal debug priority.
  +    -->
  +    <merlin:test 
  +      system="${merlin.system}"
  +      kernel="${merlin.kernel}" 
  +      home="${basedir}" 
  +      path="${maven.conf.dir}/block.xml" 
  +      base="${basedir}/target/classes" 
  +      config="${merlin.config}" 
  +      debug="${merlin.debug}" 
  +      deploy="false" 
  +    />
  +
  +  </goal>
  +
   </project>
  
  
  
  1.2       +4 -0      avalon-sandbox/merlin/merlin-plugin/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-plugin/plugin.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plugin.properties	29 Mar 2003 03:14:02 -0000	1.1
  +++ plugin.properties	8 May 2003 03:02:40 -0000	1.2
  @@ -18,3 +18,7 @@
   # default XML format is more portable.
   #
   merlin.meta.format=xml
  +
  +
  +
  +
  
  
  
  1.3       +80 -15    avalon-sandbox/merlin/merlin-plugin/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-plugin/project.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.xml	29 Mar 2003 06:56:46 -0000	1.2
  +++ project.xml	8 May 2003 03:02:40 -0000	1.3
  @@ -8,52 +8,116 @@
     <currentVersion>1.0</currentVersion>
     <description>Merlin Plugin for Maven</description>
     <shortDescription>Merlin Plugin for Maven</shortDescription>
  -
  -  <developers>
  -    <developer>
  -      <name>Stephen McConnell</name>
  -      <id>mcconnell</id>
  -      <email>mcconnell@apache.org</email>
  -      <organization>OSM SARL</organization>
  -    </developer>
  -  </developers>
  +  <package>org.apache.avalon.merlin</package>
   
     <dependencies>
  +
       <dependency>
         <groupId>avalon</groupId>
         <artifactId>avalon-framework</artifactId>
         <version>4.1.4</version>
       </dependency>
  +
       <dependency>
  -      <groupId>excalibur</groupId>
  -      <artifactId>excalibur-i18n</artifactId>
  -      <version>1.0</version>
  +      <groupId>avalon</groupId>
  +      <artifactId>avalon-logkit</artifactId>
  +      <version>1.2</version>
       </dependency>
  +
       <dependency>
  -      <groupId>excalibur</groupId>
  -      <artifactId>excalibur-configuration</artifactId>
  +      <groupId>avalon</groupId>
  +      <artifactId>avalon-lifecycle</artifactId>
         <version>1.0</version>
       </dependency>
  +
       <dependency>
         <groupId>avalon</groupId>
         <artifactId>avalon-meta</artifactId>
         <version>1.0</version>
       </dependency>
  +
       <dependency>
         <groupId>avalon</groupId>
         <artifactId>avalon-meta-spi</artifactId>
         <version>1.0</version>
       </dependency>
  +
  +    <dependency>
  +      <groupId>avalon</groupId>
  +      <artifactId>avalon-assembly</artifactId>
  +      <version>1.0</version>
  +    </dependency>
  +
  +    <dependency>
  +      <groupId>avalon</groupId>
  +      <artifactId>avalon-assembly-spi</artifactId>
  +      <version>1.0</version>
  +    </dependency>
  +
       <dependency>
         <groupId>avalon</groupId>
         <artifactId>avalon-meta-tools</artifactId>
         <version>1.0</version>
       </dependency>
  +
  +    <!-- excalibur -->
  +
  +    <dependency>
  +      <groupId>excalibur</groupId>
  +      <artifactId>excalibur-i18n</artifactId>
  +      <version>1.0</version>
  +    </dependency>
  +
  +    <dependency>
  +      <groupId>excalibur</groupId>
  +      <artifactId>excalibur-thread</artifactId>
  +      <version>1.1.1</version>
  +    </dependency>
  +    
  +    <dependency>
  +      <groupId>excalibur</groupId>
  +      <artifactId>excalibur-event</artifactId>
  +      <version>2.0</version>
  +    </dependency>
  +    
  +    <dependency>
  +      <groupId>excalibur</groupId>
  +      <artifactId>excalibur-util-concurrent</artifactId>
  +      <version>1.3.1</version>
  +    </dependency>
  +
  +    <dependency>
  +      <groupId>excalibur</groupId>
  +      <artifactId>excalibur-configuration</artifactId>
  +      <version>1.0</version>
  +    </dependency>
  +    
  +    <dependency>
  +      <groupId>excalibur</groupId>
  +      <artifactId>excalibur-extension</artifactId>
  +      <version>1.0</version>
  +    </dependency>
  +
  +    <!-- merlin -->
  +
  +    <dependency>
  +      <groupId>merlin</groupId>
  +      <artifactId>merlin-spi</artifactId>
  +      <version>1.0</version>
  +    </dependency>
  +
  +    <dependency>
  +      <groupId>merlin</groupId>
  +      <artifactId>merlin-core</artifactId>
  +      <version>2.1</version>
  +    </dependency>
  +
       <dependency>
         <groupId>ant</groupId>
         <artifactId>ant</artifactId>
         <version>1.5</version>
       </dependency>
  +
       <dependency>
         <groupId>qdox</groupId>
         <artifactId>qdox</artifactId>
  @@ -67,6 +131,7 @@
         <version>1.0.b2</version>
         <url>http://xml.apache.org/xerces2-j/</url>
       </dependency>
  +
       <dependency>
         <id>xerces</id>
         <version>2.2.1</version>
  @@ -76,7 +141,7 @@
     </dependencies>
     
     <build>
  -    <sourceDirectory>${basedir}/src/main</sourceDirectory>
  +    <sourceDirectory>${basedir}/src/java</sourceDirectory>
       <unitTestSourceDirectory>${basedir}/src/test</unitTestSourceDirectory>
   
       <unitTest>
  
  
  
  1.1                  avalon-sandbox/merlin/merlin-plugin/src/java/org/apache/avalon/merlin/tools/MerlinBean.java
  
  Index: MerlinBean.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.avalon.merlin.tools;
  
  import java.io.File;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.ArrayList;
  import java.util.Hashtable;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.avalon.assembly.util.ExceptionHelper;
  import org.apache.avalon.assembly.locator.Contextualizable;
  import org.apache.avalon.assembly.util.ExceptionHelper;
  import org.apache.avalon.merlin.kernel.Kernel;
  import org.apache.avalon.merlin.kernel.KernelException;
  import org.apache.avalon.merlin.kernel.KernelRuntimeException;
  import org.apache.avalon.merlin.kernel.KernelLoader;
  import org.apache.avalon.merlin.kernel.impl.DefaultKernelLoader;
  import org.apache.avalon.merlin.block.Block;
  import org.apache.avalon.merlin.block.impl.StandardBlock;
  
  
  /**
   * Deploy a set of components using Merlin.
   *
   * @author mcconnell@apache.org
   */
  
  public class MerlinBean
  {
  
      private File m_target;
      private File m_path;
      private File m_base;
      private File m_conf;
      private File m_kernelPath;
      private File m_system;
      private File m_home;
      private String m_debug;
      private boolean m_deploy = true;
  
      private Kernel m_kernel;
  
      public void setTarget( File target ) 
      {
          m_target = target;
      }
  
      private URL getTarget()
      {
          try
          {
              return new URL( "jar:" + m_target.toURL() + "!/" );
          }
          catch( Throwable e )
          {
              throw new RuntimeException( e.toString() );
          }
      }
  
      public void setPath( File path ) 
      {
          m_path = path;
      }
  
      private URL getPath()
      {
          try
          {
              return m_path.toURL();
          }
          catch( Throwable e )
          {
              throw new RuntimeException( e.toString() );
          }
      }
  
      private File getBase()
      {
          if( m_base == null )
          {
              File file = new File( m_path.getParentFile().getParentFile(), "target/classes" );
              if( file.exists() )
              {
                  return file;
              }
              else
              {
                  final String error = 
                    "Cannot resolve the base direcrtory.";
                  throw new IllegalStateException( error );
              }
          }
          else
          {
              return m_base;
          }
      }
  
      public void setConfig( File conf ) 
      {
          m_conf = conf;
      }
  
      public void setBase( File base ) 
      {
          m_base = base;
      }
  
      public void setKernel( File kernel ) 
      {
          m_kernelPath = kernel;
      }
  
      public void setHome( File home ) 
      {
          m_home = home;
      }
  
      private File getHome()
      {
          if( m_home == null )
          {
              m_home = new File( System.getProperty( "user.dir" ) );
          }
          return m_home;
      }
  
      public void setDebug( String priority ) 
      {
          m_debug = priority;
      }
  
      public void setSystem( File system ) 
      {
          m_system = system;
      }
  
      public void setDeploy( boolean value ) 
      {
          m_deploy = value;
      }
  
      public boolean getDeploy( ) 
      {
          return m_deploy;
      }
  
      public File getSystem() 
      {
          return m_system;
      }
  
      public void doExecute() throws Exception
      {
          final String system =
            "System '" + m_system + "'";
          System.out.println( system );
  
          final String kernelConfig =
            "Kernel '" + m_kernelPath + "'";
          System.out.println( kernelConfig );
  
          final String conf =
            "Config '" + m_conf + "' (" + m_conf.exists() + ")";
          System.out.println( conf );
  
          if( m_target != null )
          {
              if( m_path != null )
              {
                  final String error = 
                    "Incompatible arguments - use target or path.";
                  throw new IllegalArgumentException( error );
              }
  
              final String target =
                "Target '" + m_target + "'";
              System.out.println( target );
          }
          else
          {
              final String path =
                "Path '" + m_path + "'";
              System.out.println( path );
  
              final String base =
                "Base '" + m_base + "'";
              System.out.println( base );
          }
  
          final String debug =
            "Debug '" + m_debug + "'";
          System.out.println( debug );
  
          try
          {
  
              ClassLoader classloader = StandardBlock.class.getClassLoader();
  
              KernelLoader loader = new DefaultKernelLoader();
              Map map = new Hashtable();
              map.put( "urn:merlin:classloader.common", classloader );
              map.put( "urn:merlin:classloader.system", classloader );
              map.put( "urn:merlin:home", getHome() );
              map.put( "urn:merlin:system", m_system );
              map.put( "urn:merlin:kernel.profile", m_kernelPath );
              map.put( "urn:merlin:debug", m_debug );
              if( m_target != null )
              {
                  map.put( "urn:merlin:block.url", getTarget() );
              }
              else
              {
                  map.put( "urn:merlin:block.url", getPath() );
                  map.put( "urn:merlin:base", getBase() );
              }
              if( m_conf.exists() )
              {
                  map.put( "urn:merlin:block.config", m_conf.toURL() );
              }
  
              m_kernel = loader.build( map );
          }
          catch( Throwable e )
          {
              final String error = 
                "Could not establish the kernel.";
              String message = ExceptionHelper.packException( error, e );
              System.err.println( message );
              throw new KernelException( message, e );
          }
  
          if( m_deploy )
          {
              Block block = m_kernel.getRootBlock();
              try
              {
                  block.deploy();
              }
              catch( Throwable e )
              {
                  final String error = 
                    "Deployment failure.";
                  String message = ExceptionHelper.packException( error, e );
                  System.err.println( message );
                  m_kernel.shutdown();
                  throw new KernelException( message, e );
              }
          }
          m_kernel.shutdown();
      }
  
      private static URL[] getJarFiles( File base )
      {
          return getJarFiles( base, new URL[0] );
      }
  
      private static URL[] getJarFiles( File base, URL[] urls )
      {
          List list = new ArrayList();
          for( int i=0; i<urls.length; i++ )
          {
              list.add( urls[i] );
          }
          populateJars( list, base );
          return (URL[]) list.toArray( new URL[0] );
      }
  
      private static void populateJars( List list, File base )
      {
          try
          {
              File[] files = base.listFiles();
              for( int i=0; i<files.length; i++ )
              {
                  File file = files[i];
                  if( file.getName().endsWith( ".jar" ) )
                  {
                      list.add( file.toURL() );
                  }
              }
          }
          catch( Throwable e )
          {
              final String error =
                "Unexpected error while scanning files in shared directory: " + base;
              throw new KernelRuntimeException( error, e );
          }
      }
  }
  
  
  
  
  1.4       +8 -3      avalon-sandbox/merlin/merlin-smp/xdocs/starting/hello/creation.xml
  
  Index: creation.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/xdocs/starting/hello/creation.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- creation.xml	17 Apr 2003 03:44:11 -0000	1.3
  +++ creation.xml	8 May 2003 03:02:40 -0000	1.4
  @@ -12,9 +12,8 @@
         <subsection name="Tutorial Overview">
           <p>
           This tutorial takes you though the creation of a very simple
  -        component, the declaration of a component type descriptor, the 
  -        declaration of a block containing the component, and the execution
  -        of the block my Merlin.
  +        component, the declaration of a component type descriptor, and the 
  +        declaration of a block containing the component.
           </p>
           <p>
           Resources (sample code and build files) supporting this tutorial 
  @@ -84,6 +83,12 @@
   
   </block>
   ]]></source>
  +      </subsection>
  +      <subsection name="Execution">
  +        <p>
  +        The next tutorial - titled <a href="execution.html">Running Hello</a> 
  +        covers deployment of the component using the Merlin runtime platform.
  +        </p>
         </subsection>
       </section>
     </body>
  
  
  
  1.5       +9 -1      avalon-sandbox/merlin/merlin-spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Kernel.java	27 Apr 2003 09:28:55 -0000	1.4
  +++ Kernel.java	8 May 2003 03:02:40 -0000	1.5
  @@ -68,6 +68,14 @@
       //=======================================================================
   
      /**
  +    * When deploying merlin in a simulation mode the kernel can be established 
  +    * with a URL referencing a base directory from which classes and scanned
  +    * for type, service and profile defintions.
  +    */
  +    static final String BASE_KEY = "urn:merlin:base";
  +
  +
  +   /**
       * Return the root block.
       * @return the root block
       */
  
  
  
  1.3       +15 -2     avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/info/builder/XMLServiceCreator.java
  
  Index: XMLServiceCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/info/builder/XMLServiceCreator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLServiceCreator.java	15 Apr 2003 03:05:41 -0000	1.2
  +++ XMLServiceCreator.java	8 May 2003 03:02:40 -0000	1.3
  @@ -62,6 +62,7 @@
   import org.apache.avalon.meta.info.Service;
   import org.apache.avalon.meta.info.EntryDescriptor;
   import org.apache.avalon.meta.info.ReferenceDescriptor;
  +import org.apache.excalibur.configuration.ConfigurationUtil;
   import org.xml.sax.InputSource;
   
   /**
  @@ -145,7 +146,19 @@
           for( int i = 0; i < children.length; i++ )
           {
               Configuration child = children[ i ];
  -            final String key = child.getAttribute( "key" );
  +            String key = null;
  +            try
  +            {
  +                key = child.getAttribute( "key" );
  +            }
  +            catch( ConfigurationException ce )
  +            {
  +                final String error =
  +                  "Missing 'key' attribute in 'attribute' element.\n"
  +                  + ConfigurationUtil.list( child );
  +                throw new ConfigurationException( error, ce );
  +            }
  +            
               String value = child.getAttribute( "value", null );
               if( value == null )
               {
  
  
  
  1.4       +2 -2      avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/info/builder/XMLServiceWriter.java
  
  Index: XMLServiceWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/info/builder/XMLServiceWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLServiceWriter.java	16 Apr 2003 14:19:42 -0000	1.3
  +++ XMLServiceWriter.java	8 May 2003 03:02:40 -0000	1.4
  @@ -154,7 +154,7 @@
                                    final String key, final String value )
           throws IOException
       {
  -        writer.write( "\n    <attribute name=\"" );
  +        writer.write( "\n    <attribute key=\"" );
           writer.write( key );
           writer.write( "\" value=\"" );
           writer.write( value );
  
  
  
  1.4       +2 -2      avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/info/builder/XMLTypeWriter.java
  
  Index: XMLTypeWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/info/builder/XMLTypeWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLTypeWriter.java	16 Apr 2003 14:19:42 -0000	1.3
  +++ XMLTypeWriter.java	8 May 2003 03:02:40 -0000	1.4
  @@ -407,7 +407,7 @@
                                    final String key, final String value )
           throws IOException
       {
  -        writer.write( "\n      <attribute name=\"" );
  +        writer.write( "\n      <attribute key=\"" );
           writer.write( key );
           writer.write( "\" value=\"" );
           writer.write( value );
  
  
  
  1.4       +3 -3      avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/tools/ant/MetaTask.java
  
  Index: MetaTask.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-tools/src/java/org/apache/avalon/meta/tools/ant/MetaTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MetaTask.java	16 Apr 2003 14:19:43 -0000	1.3
  +++ MetaTask.java	8 May 2003 03:02:40 -0000	1.4
  @@ -255,7 +255,7 @@
                   services++;
   
                   //
  -                // it is a service so we can fo ahead annd build a
  +                // it is a service so we can fo ahead and build a
                   // a service descriptor
                   //
   
  @@ -334,7 +334,7 @@
           throws IOException
       {
           final String fqn = service.getReference().getClassname();
  -        final File file = getOutputFileForClass( fqn );
  +        final File file = getOutputFileForService( fqn );
           final OutputStream outputStream = new FileOutputStream( file );
           try
           {
  
  
  

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


Mime
View raw message