mcconnell    2002/12/07 06:00:53

  Modified:    assembly build.xml default.properties
               assembly/src/etc demo.mf
               assembly/src/java/org/apache/avalon/assembly/engine
                        DefaultRepositoryManager.java
                        EngineClassLoader.java
  Log:
  Updates to handle extension based loading of dependent jar files.
  
  Revision  Changes    Path
  1.6       +37 -2     avalon-sandbox/assembly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/build.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- build.xml 7 Dec 2002 09:34:27 -0000       1.5
  +++ build.xml 7 Dec 2002 14:00:53 -0000       1.6
  @@ -45,6 +45,11 @@
       <pathelement location="${build.testclasses}"/>
     </path>
   
  +  <path id="runtime.class.path">
  +    <pathelement location="${build.dir}/lib/${demo.jar}"/>
  +    <pathelement location="${build.testclasses}"/>
  +  </path>
  +
     <target name="main" depends="jar,jar-playground" description="Build the project"/>
     <target name="rebuild" depends="clean,main" description="Rebuild the project"/>
     <target name="all" depends="rebuild,docs" description="Rebuild the project"/>
  @@ -341,7 +346,36 @@
       </jar>
     </target>
   
  -  <target name="test" depends="jar-playground,compile-test" description="Perform 
the unit tests" unless="skip.tests">
  +  <target name="deploy">
  +
  +     <mkdir dir="${common.dir}"/>
  +     <copy todir="${common.dir}" file="${avalon-framework.jar}"/>
  +     <copy todir="${common.dir}" file="${avalon-meta.jar}"/>
  +     <copy todir="${common.dir}" file="${excalibur-configuration.jar}"/>
  +     <copy todir="${common.dir}" file="${excalibur-i18n.jar}"/>
  +     <copy todir="${common.dir}" preservelastmodified="true">
  +       <fileset dir="${tools.dir}/lib">
  +         <include name="xerces-2.0.1.jar"/>
  +         <include name="xml-apis.jar"/>
  +         <include name="xalan-2.3.1.jar"/>
  +       </fileset>
  +     </copy>
  +
  +     <mkdir dir="${lib.dir}"/>
  +     <copy todir="${lib.dir}" file="${logkit.jar}"/>
  +     <copy todir="${lib.dir}" file="${excalibur-extension.jar}"/>
  +     <copy todir="${lib.dir}" file="${excalibur-logger.jar}"/>
  +     <copy todir="${lib.dir}" file="${excalibur-event.jar}"/>
  +     <copy todir="${lib.dir}" file="${commons-collections.jar}"/>
  +     <copy todir="${lib.dir}" file="${util.concurrent.jar}"/>
  +     <copy todir="${lib.dir}" file="${excalibur-thread.jar}"/>
  +     <copy todir="${lib.dir}" file="${avalon-lifecycle.jar}"/>
  +     <copy todir="${lib.dir}" file="${avalon-assembly.jar}"/>
  +
  +  </target>
  +
  +
  +  <target name="test" depends="jar-playground,compile-test,deploy" 
description="Perform the unit tests" unless="skip.tests">
   
       <echo message="Performing Unit Tests" />
   
  @@ -351,7 +385,8 @@
           haltonfailure="${junit.failonerror}"
           printsummary="yes"
           dir="${build.tests}">
  -      <classpath refid="test.class.path"/>
  +      <classpath refid="runtime.class.path"/>
  +      <jvmarg value="-Djava.ext.dirs=common;lib"/>
   
         <formatter type="xml"/>    <!-- xml reports for junitreport -->
         <formatter type="plain" usefile="false"/>  <!-- text reports for humans     
-->
  
  
  
  1.5       +5 -1      avalon-sandbox/assembly/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/default.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- default.properties        7 Dec 2002 09:34:27 -0000       1.4
  +++ default.properties        7 Dec 2002 14:00:53 -0000       1.5
  @@ -107,6 +107,9 @@
   
   tools.dir=${basedir}/../../jakarta-avalon/tools
   
  +lib.dir = ${build.tests}/lib
  +common.dir = ${build.tests}/common
  +
   #  Set the properties for distribution directories
   dist.dir = dist
   dist.javadocs = ${dist.dir}/docs/api
  @@ -117,13 +120,14 @@
   #  name of jar file
   jar.name = ${name}-${version}.jar
   
  +avalon-assembly.jar = ${build.lib}/${jar.name}
  +
   #  property indicating directory where all distribution archives are placed
   dist.base = distributions
   
   
   # project specific properties
   
  -lib.dir = lib
   demo.name = demo
   demo.jar = ${name}-${demo.name}-${version}.jar
   
  
  
  
  1.3       +3 -31     avalon-sandbox/assembly/src/etc/demo.mf
  
  Index: demo.mf
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/etc/demo.mf,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- demo.mf   7 Dec 2002 09:34:27 -0000       1.2
  +++ demo.mf   7 Dec 2002 14:00:53 -0000       1.3
  @@ -1,40 +1,12 @@
   Manifest-Version: 1.0
   Created-By: Apache Avalon
  -Extension-List: framework meta lifecycle i18n
  +Extension-List: framework assembly
   framework-Extension-Name: avalon-framework
   framework-Specification-Version: 1.0
   framework-Implementation-Version: 4.1.2
  -meta-Extension-Name: avalon-meta
  -meta-Specification-Version: 1.0
  -lifecycle-Extension-Name: avalon-lifecycle
  -lifecycle-Specification-Version: 1.0
  -configuration-Extension-Name: excalibur-configuration
  -configuration-Specification-Version: 1.0
  -i18n-Extension-Name: excalibur-i18n
  -i18n-Specification-Version: 1.0
  +assembly-Extension-Name: avalon-assembly
  +assembly-Specification-Version: 1.0
   
   Name: Avalon-Block
   Block-Name: Playground
  -
  -Name: org/apache/avalon/playground/SimpleComponent.class
  -Avalon: Type
  -
  -Name: org/apache/avalon/playground/TerminalComponent.class
  -Avalon: Type
  -
  -Name: org/apache/avalon/playground/BasicComponent.class
  -Avalon: Type
  -
  -Name: org/apache/avalon/playground/ComplexComponent.class
  -Avalon: Type
  -
  -Name: org/apache/avalon/playground/InvalidComponent.class
  -Avalon: Type
  -
  -Name: org/apache/avalon/playground/ExploitationManager.class
  -Avalon: Type
  -
  -Name: org/apache/avalon/playground/DemoManager.class
  -Avalon: Type
  -
   
  
  
  
  1.2       +98 -16    
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultRepositoryManager.java
  
  Index: DefaultRepositoryManager.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/DefaultRepositoryManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultRepositoryManager.java     7 Dec 2002 09:34:28 -0000       1.1
  +++ DefaultRepositoryManager.java     7 Dec 2002 14:00:53 -0000       1.2
  @@ -57,6 +57,7 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.io.FileFilter;
   import java.net.JarURLConnection;
   import java.net.URL;
   import java.net.URLClassLoader;
  @@ -76,6 +77,7 @@
   import org.apache.avalon.assembly.profile.ProfileManager;
   import org.apache.avalon.assembly.service.ServiceManager;
   import org.apache.avalon.assembly.engine.model.*;
  +import org.apache.avalon.assembly.util.DefaultFileFilter;
   import org.apache.avalon.excalibur.extension.Extension;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  @@ -109,6 +111,9 @@
       // static
       //===================================================================
   
  +    private static final FileFilter JAR_FILTER = new DefaultFileFilter( "jar" );
  +
  +
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultRepositoryManager.class );
   
  @@ -179,6 +184,8 @@
        */
       private Boolean m_bootstrap = new Boolean( false );
   
  +    private List m_scanned = new ArrayList();
  +
       //==============================================================
       // Contextualizable
       //==============================================================
  @@ -251,6 +258,7 @@
               if( include.isDirectory() )
               {
                   list.add( include );
  +                getLogger().debug( "including kernel extension dir: " + include );
               }
               else
               {
  @@ -259,21 +267,68 @@
               }
           }
   
  +        if( m_bootstrap.booleanValue() )
  +        {
  +            String sep = System.getProperty( "path.separator" );
  +            String exts = System.getProperty( "java.ext.dirs" );
  +            StringTokenizer tokenizer = new StringTokenizer( exts, sep );
  +            while( tokenizer.hasMoreTokens() )
  +            {
  +                String token = tokenizer.nextToken();
  +                File test = new File( token );
  +                if( test.exists() )
  +                {
  +                    list.add( test );
  +                    if( getLogger().isDebugEnabled() )
  +                    {
  +                        getLogger().debug( "including system extension dir: " + 
test );
  +                    }
  +                }
  +                else
  +                {
  +                    File file = new File( m_home, token );
  +                    if( file.exists() )
  +                    {
  +                        list.add( file  );
  +                        if( getLogger().isDebugEnabled() )
  +                        {
  +                            getLogger().debug( "including relative extension dir: " 
+ file );
  +                        }
  +                    }
  +                    else
  +                    {
  +                        if( getLogger().isWarnEnabled() )
  +                        {
  +                            final String warning = 
  +                              "The extension directory path: '" + token 
  +                              + "' deas not refer to a directory.";
  +                            getLogger().warn( warning );
  +                        }
  +                    }
  +                }
  +            }
  +        }
  +
           File[] files = (File[])list.toArray( new File[ 0 ] );
           ExtensionManager repository = new DefaultExtensionManager( files );
           m_manager = new PackageManager( repository );
   
           //
  -        // handle the system classpath bootstrap process
  +        // handle the system bootstrap process
           //
   
           if( m_bootstrap.booleanValue() )
           {
  +
               if( getLogger().isDebugEnabled() )
               {
                  getLogger().debug( "bootstraping from classpath" );
               }
   
  +            //
  +            // handle the classpath
  +            //
  +
               String sep = System.getProperty( "path.separator" );
               String classpath = System.getProperty( "java.class.path" );
   
  @@ -282,7 +337,11 @@
               {
                   String token = tokenizer.nextToken();
                   URL jar = new File( token ).toURL();
  -                scan( jar );
  +                if( getLogger().isDebugEnabled() )
  +                {
  +                    getLogger().debug( "path: " + jar );
  +                }
  +                addLibrary( jar );
               }
           }
       }
  @@ -373,9 +432,12 @@
        */
       public void addLibrary( URL url )
       {
  -        addExtensions( url );
  -        m_classloader.addLibraryURL( url );
  -        scan( url );
  +        //if( !m_scanned.contains( url ) )
  +        //{
  +            addExtensions( url );
  +            m_classloader.addLibraryURL( url );
  +            scan( url );
  +        //}
       }
   
       private void addExtensions( URL url )
  @@ -395,10 +457,6 @@
                   try
                   {
                       URL target = ext.toURL();
  -                    if( getLogger().isDebugEnabled() )
  -                    {
  -                        getLogger().debug( "include: " + target );
  -                    }
                       addLibrary( target );
                   }
                   catch( Throwable e )
  @@ -429,9 +487,9 @@
               return;
           }
   
  -        if( getLogger().isDebugEnabled() )
  +        if( m_scanned.contains( url ) )
           {
  -            getLogger().debug( "scanning: " + url );
  +            return;
           }
   
           try
  @@ -441,12 +499,14 @@
               Manifest manifest = jar.getManifest();
               if( manifest == null )
               {
  +                m_scanned.add( url );
                   return;
               }
   
               Attributes attributes = manifest.getAttributes( AVALON_BLOCK_KEY );
               if( attributes == null )
               {
  +                m_scanned.add( url );
                   return;
               }
   
  @@ -455,6 +515,11 @@
               // for service and type defintions
               //
   
  +            m_scanned.add( url );
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                getLogger().debug( "scanning: " + url );
  +            }
               JarFile base = jar.getJarFile();
               loadComponents( base );
   
  @@ -475,7 +540,9 @@
   
       private void loadComponents( JarFile base ) throws IOException
       {
  +
           List list = new ArrayList();
  +        List types = new ArrayList();
           Enumeration entries = base.entries();
           while( entries.hasMoreElements() )
           {
  @@ -489,8 +556,7 @@
                   {
                       Type type = m_types.createType( classname );
                       m_types.addType( type );
  -                    Profile[] profiles = m_profiles.loadProfiles( type );
  -                    m_profiles.addProfiles( profiles );
  +                    types.add( type );
                   }
                   catch( Throwable e )
                   {
  @@ -506,8 +572,7 @@
                   {
                       Type type = m_types.createType( classname );
                       m_types.addType( type );
  -                    Profile[] profiles = m_profiles.loadProfiles( type );
  -                    m_profiles.addProfiles( profiles );
  +                    types.add( type );
                   }
                   catch( Throwable e )
                   {
  @@ -531,6 +596,23 @@
                         "Ignoring type: " + name;
                       getLogger().warn( warning, e );
                   }
  +            }
  +        }
  +
  +        Type[] created = (Type[]) types.toArray( new Type[0] );
  +        for( int i=0; i<created.length; i++ )
  +        {
  +            Type type = created[i];
  +            try
  +            {
  +                Profile[] profiles = m_profiles.loadProfiles( type );
  +                m_profiles.addProfiles( profiles );
  +            }
  +            catch( Throwable e )
  +            {
  +                final String warning = 
  +                  "Profile registration error from type: " + 
type.getInfo().getClassname();
  +                getLogger().warn( warning, e );
               }
           }
       }
  
  
  
  1.2       +8 -2      
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EngineClassLoader.java    7 Dec 2002 09:34:28 -0000       1.1
  +++ EngineClassLoader.java    7 Dec 2002 14:00:53 -0000       1.2
  @@ -358,13 +358,14 @@
           m_lifestyle = createLifestyleService( m_facilities );
           m_appliances = createApplianceManager( m_facilities );
           m_assembly = createAssemblyService( m_facilities, m_graph );
  -                                     
  +                                 
           if( getLogger().isDebugEnabled() )
           {
               getLogger().debug( "ready" );
           }
       }
   
  +
       //==============================================================
       // AssemblyService
       //==============================================================
  @@ -454,6 +455,11 @@
       void addLibraryURL( URL url )
       {
           addURL( url );
  +    }
  +
  +    protected void addURL( URL url )
  +    {
  +        super.addURL( url );
       }
   
      /**
  
  
  

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

Reply via email to