mcconnell    02/03/12 14:17:04

  Modified:    enterprise/tools build.xml
               enterprise/tools/lib merlin.jar
               
enterprise/tools/src/java/org/apache/avalon/excalibur/configuration
                        CascadingConfiguration.java
               enterprise/tools/src/java/org/apache/avalon/excalibur/service
                        ServiceFactory.java ServiceLoader.java
                        ServiceRegistry.java UnitInfo.java package.html
               enterprise/tools/src/java/org/apache/avalon/excalibur/service/ant
                        Load.java
               enterprise/tools/src/java/org/apache/demo util.java
  Log:
  no message
  
  Revision  Changes    Path
  1.8       +12 -1     jakarta-avalon-apps/enterprise/tools/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/enterprise/tools/build.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- build.xml 9 Mar 2002 05:21:39 -0000       1.7
  +++ build.xml 12 Mar 2002 22:17:03 -0000      1.8
  @@ -25,6 +25,7 @@
         dist             - executes build, javadoc and support file creation
         clean            - destroy the build directory
         install          - upgrade merlin.jar in lib
  +      export           - export jar files to ANT_HOME/lib
         
       </echo>
     </target>
  @@ -84,6 +85,16 @@
       </copy>
     </target>
   
  +  <target name="export" depends="install">
  +    <copy toDir="${ant.home}/lib">
  +       <fileset dir="${tools.lib.path}">
  +          <include name="${merlin.jar}"/>
  +          <include name="avalon-framework.jar"/>
  +          <include name="logkit.jar"/>
  +       </fileset>
  +    </copy>
  +  </target>
  +
     <target name="clean">
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
  @@ -250,7 +261,7 @@
       <echo message="Excalibur not present under ${excalibur.path}"/>
     </target>
   
  -  <target name="export" depends="excalibur.check" if="excalibur.present">
  +  <target name="release" depends="excalibur.check" if="excalibur.present">
       <echo message="Exporting service package to Excalibur."/> 
       <copy toDir="${excalibur.path}/src/scratchpad" 
preservelastmodified="true">
          <fileset dir="${src}/java">
  
  
  
  1.9       +113 -111  jakarta-avalon-apps/enterprise/tools/lib/merlin.jar
  
        <<Binary file>>
  
  
  1.3       +47 -0     
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/configuration/CascadingConfiguration.java
  
  Index: CascadingConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/configuration/CascadingConfiguration.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CascadingConfiguration.java       9 Mar 2002 04:50:20 -0000       1.2
  +++ CascadingConfiguration.java       12 Mar 2002 22:17:03 -0000      1.3
  @@ -619,6 +619,53 @@
               return m_parent.getAttributeAsBoolean( name, defaultValue );
           }
       }
  +
  +    //=======================================================================
  +    // utilities
  +    //=======================================================================
  +
  +    public static String list( Configuration config )
  +    {
  +        final StringBuffer buffer = new StringBuffer();
  +        list( buffer, "  ", config );
  +        buffer.append("\n");
  +        return buffer.toString(); 
  +    }
  +
  +    private static void list( StringBuffer buffer, String lead, 
Configuration config )
  +    {
  +
  +        buffer.append( "\n" + lead + "<" + config.getName() );
  +        String[] names = config.getAttributeNames();
  +        if( names.length > 0 )
  +        {
  +            for( int i=0; i<names.length; i++ )
  +            {
  +                buffer.append( " " + names[i] + "=\"" + config.getAttribute( 
names[i], "???" ) + "\"" ); 
  +            }
  +        }
  +        Configuration[] children = config.getChildren();
  +        if( children.length > 0 )
  +        {
  +            buffer.append(">");
  +            for( int j=0; j<children.length; j++ )
  +            {
  +                 list( buffer, lead + "  ", children[j] ); 
  +            }
  +            buffer.append( "\n" + lead + "</" + config.getName() + ">");
  +        }
  +        else
  +        {
  +            if( config.getValue( null ) != null )
  +            {
  +                buffer.append( ">...</" + config.getName() + ">");
  +            }
  +            else
  +            {
  +                buffer.append( "/>");
  +            }
  +        }
  +    }
   }
   
   
  
  
  
  1.7       +48 -14    
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceFactory.java
  
  Index: ServiceFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServiceFactory.java       6 Mar 2002 18:27:54 -0000       1.6
  +++ ServiceFactory.java       12 Mar 2002 22:17:04 -0000      1.7
  @@ -68,9 +68,9 @@
       private Hashtable m_services = new Hashtable();
       private Hashtable m_lookup = new Hashtable();
   
  -    public ServiceFactory( File base, boolean verbose ) throws Exception
  +    public ServiceFactory( File root, boolean verbose ) throws Exception
       {
  -        m_root = base;
  +        m_root = root;
           m_verbose = verbose;
       }
   
  @@ -86,7 +86,8 @@
       {
           m_base_logger = getLogger();
           super.enableLogging( m_base_logger.getChildLogger( "loader" 
).getChildLogger( "factory" ) );
  -        m_registry = new ServiceRegistry( m_verbose );
  +
  +        m_registry = new ServiceRegistry( m_root, m_verbose );
           m_registry.enableLogging( getLogger().getChildLogger("registry") );
           m_registry.configure( m_config );
           m_registry.initialize();
  @@ -157,7 +158,7 @@
               for( int i=0; i<dependencies.length; i++ )
               {
                   DependencyInfo info = dependencies[i];
  -                providers.put( info.getRole(), getProvider( info, base ) );
  +                providers.put( info.getRole(), getProvider( unit, info, base 
) );
               }
               return providers;
           }
  @@ -174,7 +175,7 @@
       * @param info the dependecy declaration
       * @param profile the configuration profile
       */
  -    private Object getProvider( DependencyInfo info, Logger base ) throws 
Exception
  +    private Object getProvider( UnitInfo unit, DependencyInfo info, Logger 
base ) throws Exception
       {
   
           UnitInfo block_info = m_registry.lookup( info );
  @@ -212,7 +213,7 @@
                     // create and pipeline the singleton instance and 
                     // add it to the list of singletons
   
  -                  Object object = execute( block_info, info.getRole(), base 
);
  +                  Object object = execute( unit, block_info, info.getRole(), 
base );
                     provider = new SingletonProvider( object, info.getRole() );
                     m_singletons.put( provider_class, provider );
                 }
  @@ -229,7 +230,7 @@
                     // create and pipeline the singleton instance and 
                     // add it to the list of singletons
   
  -                  Object object = execute( block_info, info.getRole(), base 
);
  +                  Object object = execute( unit, block_info, info.getRole(), 
base );
                     provider = new PooledProvider( (Pool) object, 
info.getRole() );
                     m_pools.put( provider_class, provider );
                 }
  @@ -270,7 +271,7 @@
   
           try
           {
  -            return execute( info, role, m_base_logger ); 
  +            return execute( null, info, role, m_base_logger ); 
           }
           catch( Exception e )
           {
  @@ -283,7 +284,7 @@
           }
       }
   
  -    private Object execute( UnitInfo info, String role, Logger logger ) 
throws Exception
  +    private Object execute( UnitInfo container, UnitInfo info, String role, 
Logger logger ) throws Exception
       {
   
           if( m_verbose ) if( getLogger().isDebugEnabled() ) getLogger().debug(
  @@ -291,7 +292,16 @@
   
           enableLogging( getLogger().getChildLogger( role ) );
   
  -        Configuration config = info.getConfiguration();
  +        Configuration config = null;
  +        if( container != null )
  +        {
  +            config = new CascadingConfiguration( 
  +              container.getConfiguration().getChild(role), 
info.getConfiguration());
  +        }
  +        else
  +        {
  +            config = info.getConfiguration();
  +        }
   
           //
           // create and pipeline the new instance
  @@ -320,6 +330,7 @@
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to assign a logger channel.";
               throw new PipelineException( error, e );
           }
  @@ -330,11 +341,15 @@
   
           if( m_object instanceof Configurable ) try
           {
  +            if( m_verbose ) getLogger().debug(
  +              "applying configuration to " + info.getName() + "\n"
  +              + CascadingConfiguration.list( config ));
               if( m_verbose ) getLogger().debug( "configuration" );
               ((Configurable)m_object).configure( config );
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to configure an object.";
               throw new PipelineException( error, e );
           }
  @@ -346,6 +361,7 @@
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to parameterize an object.";
               throw new PipelineException( error, e );
           }
  @@ -358,12 +374,11 @@
           if( m_object instanceof Contextualizable ) try
           {
               if( m_verbose ) getLogger().debug( "contextualization" );
  -            Context context = new ServiceContext( 
  -              new String[0], m_root, info.getClassName() );
  -            ((Contextualizable)m_object).contextualize( context );
  +            ((Contextualizable)m_object).contextualize( info.getContext() );
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to contextualize the object.";
               throw new PipelineException( error, e );
           }
  @@ -380,6 +395,7 @@
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to service the object.";
               throw new PipelineException( error, e );
           }
  @@ -391,6 +407,7 @@
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to compose the object.";
               throw new PipelineException( error, e );
           }
  @@ -405,8 +422,8 @@
               ((Initializable)m_object).initialize();
           }
           catch( Throwable e )
  -
           {
  +            handleDisposal( m_object );
               final String error = "Failed to initilize the object.";
               throw new PipelineException( error, e );
           }
  @@ -422,6 +439,7 @@
           }
           catch( Throwable e )
           {
  +            handleDisposal( m_object );
               final String error = "Failed to start the service.";
               throw new PipelineException( error, e );
           }
  @@ -429,6 +447,21 @@
           return m_object;
       }
   
  +    private void handleDisposal( Object object )
  +    {
  +        if( object instanceof Disposable )
  +        {
  +            try
  +            {
  +                ((Disposable)object).dispose();
  +            }
  +            catch( Throwable e )
  +            {
  +                if( getLogger().isDebugEnabled() ) 
getLogger().debug("ignoring disposal error", e );
  +            }
  +        }
  +    }
  +
      /**
       * Notification by the controlling application to dispose of the 
       * service factory.
  @@ -542,5 +575,6 @@
           }
           return table;
       }
  +
   }
   
  
  
  
  1.7       +39 -20    
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceLoader.java
  
  Index: ServiceLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceLoader.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServiceLoader.java        9 Mar 2002 04:50:21 -0000       1.6
  +++ ServiceLoader.java        12 Mar 2002 22:17:04 -0000      1.7
  @@ -51,9 +51,12 @@
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Executable;
   import org.apache.avalon.framework.ExceptionUtil;
   import org.apache.avalon.framework.CascadingThrowable;
   
  +import org.apache.avalon.excalibur.configuration.CascadingConfiguration;
  +
   /**
    * A service loader that loads a target class, manages full component 
lifecycle
    * processing for the target and dependent services, and service 
decommissioning.
  @@ -157,6 +160,7 @@
       private String[] m_args;
       private PipelineClassLoader m_classloader;
   
  +    private File m_root;
       private String m_target;
       private Object m_object;
       private File[] m_includes;
  @@ -248,12 +252,12 @@
       public static void main( String[] args )
       {
           ServiceLoader pipeline = null;
  +        Logger logger = null;
           try
           {
  -
               CLI cli = new CLI( args );
               Hierarchy hierarchy = createBootstrapLogger( 
cli.getLoggingPriority() );
  -            Logger logger = new LogKitLogger( hierarchy.getLoggerFor( "" ) );
  +            logger = new LogKitLogger( hierarchy.getLoggerFor( "" ) );
   
               File path = cli.getConfigurationPath();
               Configuration config = null;
  @@ -271,21 +275,21 @@
           }
           catch( IllegalParameterException ipe )
           {
  -            System.err.println( ipe.getMessage() );
  +            logger.error( ipe.getMessage() );
           }        
           catch( PipelineException e )
           {
  -            System.err.println( e );
  +            logger.error( e.getMessage() + e.toString() );
               if( pipeline != null ) pipeline.dispose();
           }
           catch( PipelineRuntimeException e )
           {
  -            System.err.println( e );
  +            logger.error( e.getMessage() + e.toString() );
               if( pipeline != null ) pipeline.dispose();
           }
           catch( Throwable e )
           {
  -            ExceptionUtil.printStackTrace( e, true );
  +            e.printStackTrace();
               if( pipeline != null ) pipeline.dispose();
           }
       }
  @@ -300,6 +304,9 @@
       */
       public void configure( Configuration config ) throws 
ConfigurationException
       {
  +        //getLogger().debug(
  +        //      "pipeline configuration\n"
  +        //      + CascadingConfiguration.list( config ));
           m_config = config;
       }
   
  @@ -344,8 +351,8 @@
           try
           {
               if( m_classloader == null ) m_classloader = createClassloader();
  -            m_factory = new ServiceFactory( 
  -              new File( System.getProperty("user.dir") ), getVerbose() );
  +            m_root = new File( System.getProperty("user.dir") );
  +            m_factory = new ServiceFactory( m_root, getVerbose() );
               m_factory.enableLogging( getLogger() );
               m_factory.configure( m_config );
               m_factory.initialize();
  @@ -367,15 +374,6 @@
               final String error = "Service processing error.";
               throw new PipelineException( error, e );
           }
  -        finally
  -        {
  -            if( m_policy )
  -            {
  -                if( m_object != null ) terminate();
  -                dispose();
  -                return;
  -            }
  -        }
       }
   
       /**
  @@ -411,14 +409,13 @@
           }
   
           //
  -        // create an instance of the target and if verify that we can in 
fact build a 
  -        // service manager if needed
  +        // create an instance of the target and verify that dependencies are 
resolvable
           //
   
           UnitInfo info;
           try
           {
  -            info = new UnitInfo( new UnitInfo( m_target.replace('.','/')), 
m_config );
  +            info = new UnitInfo( m_target.replace('.','/'), m_config, m_root 
);
               if( getVerbose() && getLogger().isDebugEnabled() ) 
                 getLogger().debug( "validating target");
               try
  @@ -467,6 +464,28 @@
                 }
             }
           );
  +
  +        if( m_policy )
  +        {
  +            if( m_object != null )
  +            {
  +                if( m_object instanceof Executable )
  +                {
  +                    try
  +                    {
  +                        ((Executable)m_object).execute();
  +                    }
  +                    catch( Throwable e )
  +                    {
  +                        throw new PipelineException("Target execution 
error.", e );
  +                    }
  +                }
  +                terminate();
  +                dispose();
  +                return;
  +            }
  +        }
  +
       }
   
      /**
  
  
  
  1.4       +4 -2      
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceRegistry.java
  
  Index: ServiceRegistry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceRegistry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServiceRegistry.java      6 Mar 2002 18:27:54 -0000       1.3
  +++ ServiceRegistry.java      12 Mar 2002 22:17:04 -0000      1.4
  @@ -42,14 +42,16 @@
       private Hashtable m_table;
       private Hashtable m_lookup;
       private boolean m_verbose = false;
  +    private File m_root;
   
      /**
       * Creation of a new <code>ServiceRegistry</code>
       * @param verbose if TRUE, enable DEBUG message priority logging
       */
  -    public ServiceRegistry( boolean verbose )
  +    public ServiceRegistry( File root, boolean verbose )
       {
           m_verbose = verbose;
  +        m_root = root;
       }
   
       public void configure( Configuration config )
  @@ -138,7 +140,7 @@
               for( int i=0; i<blocks.length; i++ )
               {
                   final String path = blocks[i];
  -                vector.add( new UnitInfo( path ) );
  +                vector.add( new UnitInfo( path, m_root ) );
               }
           }
           catch( Throwable e )
  
  
  
  1.4       +57 -6     
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/UnitInfo.java
  
  Index: UnitInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/UnitInfo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnitInfo.java     6 Mar 2002 18:27:54 -0000       1.3
  +++ UnitInfo.java     12 Mar 2002 22:17:04 -0000      1.4
  @@ -7,17 +7,22 @@
   
   package org.apache.avalon.excalibur.service;
   
  -import java.util.Vector;
  +import java.io.File;
   import java.io.InputStream;
   import java.io.IOException;
  +import java.util.Vector;
   
   import org.apache.avalon.framework.CascadingException;
  +import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.excalibur.mpool.Pool;
   
   import org.apache.avalon.excalibur.configuration.CascadingConfiguration;
  +import org.apache.avalon.excalibur.context.ContextUtility;
   
   /**
    * Meta information about a <code>Serviceable</code> component.  
  @@ -31,6 +36,7 @@
   
       private Class m_block;
       private Configuration m_config;
  +    private Context m_context;
       private ServiceInfo[] m_services;
       private DependencyInfo[] m_dependencies;
       private int m_policy = SINGLETON_LIFETIME_POLICY;
  @@ -75,6 +81,16 @@
       */
       public UnitInfo( Class block, Configuration xinfo ) throws Exception
       {
  +        this( block, xinfo, new DefaultConfiguration("configuration",null) );
  +    }
  +
  +    public UnitInfo( Class block, Configuration xinfo, Configuration conf ) 
throws Exception
  +    {
  +        this( block, xinfo, conf, new File( System.getProperty("user.dir") ) 
);
  +    }
  +
  +    public UnitInfo( Class block, Configuration xinfo, Configuration conf, 
File root ) throws Exception
  +    {
           m_block = block;
           
           //
  @@ -144,20 +160,35 @@
           // get the default configuration
           //
   
  -        m_config = xinfo.getChild("configuration");
  -        String base = m_config.getAttribute("extends", null );
  +        Configuration configuration = xinfo.getChild("configuration");
  +        String base = configuration.getAttribute("extends", null );
           if( base != null )
           {
  -            Configuration c = loadConfiguration( base );
  -            m_config = new CascadingConfiguration( m_config, c );
  +            Configuration base_config = loadConfiguration( base );
  +            configuration = new CascadingConfiguration( configuration, 
base_config );
           }
  +        m_config = new CascadingConfiguration( conf, configuration );
   
           //
           // get the default name
           //
   
           m_name = xinfo.getChild("block").getAttribute("name", getClassName() 
);
  -        
  +
  +        //
  +        // get the default context
  +        //
  +
  +        Context context = new ServiceContext( new String[0], root, getName() 
);
  +        Configuration context_config = xinfo.getChild("context",false);
  +        if( context_config != null )
  +        {
  +            m_context = ContextUtility.createContextFromConfiguration( 
context, context_config );
  +        }
  +        else
  +        {
  +            m_context = context;
  +        }
       }
   
      /**
  @@ -180,6 +211,7 @@
           m_dependencies = info.getDependencies();
           m_policy = info.getPolicy();
           m_name = info.getName();
  +        m_context = info.getContext();
       }
   
       public UnitInfo( String path ) throws Exception
  @@ -187,6 +219,16 @@
           this( loadClass( path ), loadConfiguration( path + ".xinfo" ) );
       }
   
  +    public UnitInfo( String path, File root ) throws Exception
  +    {
  +        this( path, new DefaultConfiguration("configuration",null), root );
  +    }
  +
  +    public UnitInfo( String path, Configuration config, File root ) throws 
Exception
  +    {
  +        this( loadClass( path ), loadConfiguration( path + ".xinfo" ), 
config, root );
  +    }
  +
      /**
       * Returns the name of the class implemenmting the service.
       * @return the class name
  @@ -268,6 +310,15 @@
       public Configuration getConfiguration()
       {
           return m_config;
  +    }
  +
  +   /**
  +    * Returns the default service context.
  +    * @return Context the default service context
  +    */
  +    public Context getContext()
  +    {
  +        return m_context;
       }
   
      /**
  
  
  
  1.7       +0 -212    
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/package.html
  
  Index: package.html
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/package.html,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- package.html      9 Mar 2002 04:50:21 -0000       1.6
  +++ package.html      12 Mar 2002 22:17:04 -0000      1.7
  @@ -1,215 +1,3 @@
   <body>
   <p>Resource supporting the management of components using dynamic service 
composition.</p>
  -<table border="1" cellpadding="3" cellspacing="0" width="100%">
  -<tr bgcolor="#ccccff">
  -<td colspan="2"><b>Features Summary</b></td>
  -<tr><td width="20%"><b>Feature</b></td>
  -<td><b>Description</b></td></tr>
  -
  -<tr><td valign="top">Service Composition</td>
  -<td>Handles automated composition of services based on declared component 
dependencies.</td></tr>
  -<tr><td valign="top">Default Configurations</td>
  -<td>Provides support for configuration using component default 
configurations together
  -with supplied configuration information using the CascadingConfiguration 
model.</td></tr>
  -<tr><td valign="top">Mixed execution modes</td>
  -<td>Supports execution from the command line (main method), as a jar file, 
as an Ant task,
  -and as an embedded component.
  -    <p><strong>java -jar form</strong></p>
  -    <p>Execution using java -jar pattern requires the presence 
  -    of the following files under the same directory:</p>
  -           <ul>
  -             <li><code>merlin.jar</code>
  -             <li><code>avalon-framework.jar</code>
  -            <li><code>logkit.jar</code>
  -           </ul>
  -      <p>An example command line is shown below:</p>
  -       <pre>
  -     $ java -jar <strong>merlin.jar</strong> &lt;supporting-jar-files&gt; 
  -         -target &lt;class-name&gt; 
  -       </pre>
  -       <p><strong>java -classpath form</strong></p>
  -       <p>Execution using java -classpath pattern requires the inclusions 
  -       of the pipeline, framework and logkit jar files in the classpath 
  -       statement.</p>
  -       <p>An example command line is shown below:</p>
  -       <pre>
  -     $ java -classpath 
<strong>merlin.jar;avalon-framework.jar;logkit.jar</strong> 
  -         org.apache.avalon.excalibur.service.ServiceLoader
  -          &lt;supporting-jar-files&gt; -target &lt;class-name&gt; 
  -       </pre>
  -    <p><strong>Ant task</strong></p>
  -    <p>Execution of Merlin as an Ant task requires the presence 
  -    of the following files under the ${ant.home}/lib directory:</p>
  -           <ul>
  -             <li><code>merlin.jar</code>
  -             <li><code>avalon-framework.jar</code>
  -            <li><code>logkit.jar</code>
  -           </ul>
  -      <p>An example load task is included below:</p>
  -       <pre>
  -    &lt;task name="my-task"&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      Declare the ant task. 
  -      --&gt;</i></font>
  -
  -      &lt;taskdef resource="merlin.properties"/&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      Invoke the loading of a target and supporting services. 
  -      --&gt;</i></font>
  -
  -      &lt;load target="org.apache.demo.ReferralBlock" priority="DEBUG" 
  -        disposal="true" verbose="false"&gt;
  -
  -        <font color="blue"><i>&lt;!--
  -        For all of the jar files in the fileset, load the jar file
  -        into the service classloader. 
  -         --&gt;</i></font>
  -
  -        &lt;fileset dir="${dist}"&gt;
  -           &lt;include name="examples.jar"/&gt;
  -        &lt;/fileset&gt;
  -
  -      &lt;/load&gt;
  -
  -    &lt;/task"&gt;
  -       </pre>
  -</td></tr>
  -</table>
  -     
  -
  -<h3>Component Creation</h3>
  -
  -The pipeline class manages the creation and deployment of a target component 
and dynamic
  -resolution of dependencies based on meta-information contained in a jar 
manifest file.  Entries
  -in the manifest file reference class names that are used to load the 
component implementation
  -and configuration the component based on meta-information contained in 
.xinfo and .conf files 
  -of the same name as the implementation class.
  -
  -<h4>The Manifest File</h4>
  -
  -<p>Reusable components are published through a manifest declaration show 
below.  When 
  -a jar file is supplied to the Pipeline the manifest is checked for any block 
declarations.
  -Blocks declared within the manifest are registered by the pipeline as 
potentially available 
  -services that can be used in service dependency resolution.  Each 
Avalon-block declaration
  -in the manifest refers to a component implementation class and its 
associated .xinfo file.</p>
  -
  -<pre>
  -  Manifest-Version: 1.0
  -
  -  Name: org/apache/DirectoryBlock.class
  -  Avalon-Block: true
  -
  -  Name: org/apache/ReferralBlock.class
  -  Avalon-Block: true
  -</pre>
  -
  -<h4>The &lt;classname&gt;.xinfo File</h4>
  -
  -<p>For each component declared in a manifest, the implementation establishes 
the available services
  -and dependencies based on information contained in an <code>.xinfo</code> 
file.  Given a component
  -implementation class 
<strong><code>org/apache/ReferralBlock.class</code></strong> the 
<code>ServiceLoader</code>  will attempt to locate a 
<strong><code>org/apache/ReferralBlock.xinfo</code></strong> 
  -resource in the jar file.</P>
  -
  -<pre>
  -  &lt;?xml version="1.0"?&gt;
  -
  -  &lt;blockinfo&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      Block name and implementation version.
  -      --&gt;</i></font>
  -
  -      &lt;block name="referral"&gt;
  -        &lt;version&gt;1.0&lt;/version&gt;
  -      &lt;/block&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      Services that are offered by the component are declared under the 
  -      services element.  A services element may contain multiple service
  -      declarations.
  -      --&gt;</i></font>
  -
  -      &lt;services&gt;
  -
  -          <font color="blue"><i>&lt;!--
  -          A service declaration includes a class name (typically an 
interface)
  -          and a service version identifier.  Service versions may have up to 
  -          three fields (e.g. 1.1.3).
  -          --&gt;</i></font>
  -
  -          &lt;service name="org.apache.ReferralService" version="1.0" /&gt;
  -
  -      &lt;/services&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      A component declares the dependencies it has with other components 
under 
  -      the dependencies element.  A dependencies element may contain multiple
  -      dependency statements.
  -      --&gt;</i></font>
  -
  -      &lt;dependencies&gt;
  -
  -          <font color="blue"><i>&lt;!--
  -          A dependency element contains the declaration of a role and a 
service
  -          that the component is dependent on. The pipeline processor will 
attempt
  -          to resolve dependencies based on registered services and 
dynamically 
  -          establish and provide the dependencies via the component 
Serviceable 
  -          implementation.  The role name corresponds to the identifying 
string
  -          that the component implementation will use to lookup a service from
  -          a service manager during the serviceable or composable lifecycle 
phase.
  -          --&gt;</i></font>
  -
  -          &lt;dependency&gt;
  -
  -              &lt;role&gt;directory&lt;/role&gt;
  -              &lt;service name="org.apache.DirectoryService" 
version="1.0"/&gt;
  -
  -              <font color="blue"><i>&lt;!--
  -              An optional configuration element may be declared as part of a 
  -              dependency.  The configuration will be applied as the primary 
  -              configuration backaged by the supporting services default 
  -              configuration.
  -              --&gt;</i></font>
  -
  -              &lt;configuration&gt;
  -                  &lt;policy value="COUNT"/&gt;
  -              &lt;/configuration&gt;
  -
  -          &lt;/dependency&gt;
  -
  -      &lt;/dependencies&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      Component implementation policy may be one of the following:
  -      (a) <strong>SINGLETON</strong>, service is available for the lifetime 
of the manager
  -      (b) <strong>TRANSIENT</strong>, manager is a factory of transient 
service instances 
  -      (c) <strong>OTHER</strong>, (default) The container will check if the 
class implements 
  -      the org.apache.excalibur.mpool.Pool interface.  If true, 
<code>lookup</code> 
  -      and <code>release</code> invocations will be redirected to the pools 
<code>acquire</code> and 
  -      <code>release</code> methods - otherwise, the class will be registered 
under the 
  -      <strong>TRANSIENT</strong> policy.
  -      --&gt;</i></font>
  -    
  -      &lt;implementation policy="SINGLETON" /&gt;
  -
  -      <font color="blue"><i>&lt;!--
  -      The default configuration for a component is declared under the 
<strong>configuration</strong>
  -      element.  This configuration value may be modified and/or supplimented 
by a 
  -      configuration supplied by a managing container.  If the 
<strong>configuration</strong>
  -      elements includes the <string>extends</string> attribute, the 
configuration will be created
  -      as a <code>CascadingConfiguration<code> where the default 
configuration is a resource derived
  -      from the extends path value and the primary configuration will be the 
content of the 
  -      configuration element.
  -      --&gt;</i></font>
  -
  -      &lt;configuration extends=org/apache/"credits.xml"&gt;
  -         &lt;about&gt;Example default configuration for this 
component.&lt;/about&gt;
  -      &lt;/configuration&gt;
  -
  -
  -  &lt;/blockinfo&gt;
  -</pre>
  -
   </body>
  
  
  
  1.2       +28 -1     
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ant/Load.java
  
  Index: Load.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ant/Load.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Load.java 3 Mar 2002 15:45:58 -0000       1.1
  +++ Load.java 12 Mar 2002 22:17:04 -0000      1.2
  @@ -27,6 +27,7 @@
   import org.apache.tools.ant.types.Commandline;
   import org.apache.tools.ant.types.CommandlineJava;
   import org.apache.tools.ant.types.Path;
  +import org.apache.tools.ant.types.Environment;
   
   import org.apache.log.Hierarchy;
   import org.apache.log.Priority;
  @@ -67,10 +68,12 @@
       private String[] m_args;
   
       private Vector m_filesets = new Vector();
  +    private Vector m_sys_properties = new Vector();
       private String m_target;
       private String m_priority;
       private String m_policy = "true";
       private String m_verbose = "false";
  +    private String m_config;
   
       private Commandline m_cmd = new Commandline();
       private Execute m_exe = new Execute(new PumpStreamHandler(System.out, 
System.err));
  @@ -84,6 +87,13 @@
           m_filesets.addElement(set);
       }
   
  +    /**
  +     * Creates a nested arg element.
  +     */
  +    public Commandline.Argument createArg() {
  +        return m_cmd.createArgument();
  +    }
  +
       public void setClasspath(Path path) 
       {
           if (m_classpath == null) 
  @@ -136,6 +146,15 @@
           m_verbose = value;
       }
   
  +    /**
  +     * Set the configuration file.
  +     * @param String boolean equivalent 
  +     */
  +    public void setConfiguration( String value ) 
  +    {
  +        m_config = value;
  +    }
  +
   
       /**
        * Performs execution as an Ant target.
  @@ -205,6 +224,14 @@
           toExecute.createArgument().setValue( "-verbose");
           toExecute.createArgument().setValue( m_verbose );
   
  +        // add the config parameter
  +    
  +        if( m_config != null )
  +        {
  +            toExecute.createArgument().setValue( "-configuration");
  +            toExecute.createArgument().setValue( m_config );
  +        }
  +
           try
           {
               m_exe.setAntRun(project);
  @@ -217,7 +244,7 @@
           {
               e.printStackTrace();
               throw new BuildException( e.getMessage() );
  -        } 
  +        }
       }
   }
   
  
  
  
  1.2       +1 -3      
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/demo/util.java
  
  Index: util.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/demo/util.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- util.java 6 Mar 2002 18:27:54 -0000       1.1
  +++ util.java 12 Mar 2002 22:17:04 -0000      1.2
  @@ -7,12 +7,10 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.logger.Logger;
   
  -
   /**
  - * This is a minimal demonstration server.
  + * Configuration debug utility.
    * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
    */
  -
   public class util
   {
   
  
  
  

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

Reply via email to