avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model IncludeDescriptor.java
Date Wed, 24 Jul 2002 17:03:08 GMT
mcconnell    2002/07/24 10:03:07

  Modified:    assembly .cvsignore
               assembly/src/etc kernel.xml sevak.xml
               assembly/src/java/org/apache/excalibur/merlin/container
                        ResourceProvider.java
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        ContainerClassLoader.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        IncludeDescriptor.java
  Log:
  updates to classpath management in complex cases
  
  Revision  Changes    Path
  1.8       +1 -0      jakarta-avalon-excalibur/assembly/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/.cvsignore,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- .cvsignore	17 Jul 2002 13:48:37 -0000	1.7
  +++ .cvsignore	24 Jul 2002 17:03:06 -0000	1.8
  @@ -6,3 +6,4 @@
   kernel.log
   extensions
   velocity.log
  +sevak-conf.xml
  
  
  
  1.16      +1 -1      jakarta-avalon-excalibur/assembly/src/etc/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/kernel.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- kernel.xml	20 Jul 2002 05:03:01 -0000	1.15
  +++ kernel.xml	24 Jul 2002 17:03:06 -0000	1.16
  @@ -21,7 +21,7 @@
      the corresponds to the name of the logging file.
      -->
   
  -   <logging priority="WARN" target="default">
  +   <logging priority="DEBUG" target="default">
         <target name="kernel">
           <file location="kernel.log" />
         </target>
  
  
  
  1.4       +0 -2      jakarta-avalon-excalibur/assembly/src/etc/sevak.xml
  
  Index: sevak.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/sevak.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sevak.xml	24 Jul 2002 16:57:51 -0000	1.3
  +++ sevak.xml	24 Jul 2002 17:03:06 -0000	1.4
  @@ -91,9 +91,7 @@
           </context>
   
           <!-- you need to provide your own sevak-conf.xml file if you want to override
defaults -->
  -        <!-- e.g.: 
           <configuration src="sevak-conf.xml"/>
  -        -->
   
        </component>
   
  
  
  
  1.9       +2 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java
  
  Index: ResourceProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ResourceProvider.java	23 Jul 2002 15:10:40 -0000	1.8
  +++ ResourceProvider.java	24 Jul 2002 17:03:07 -0000	1.9
  @@ -127,6 +127,7 @@
           m_locator = locator;
           m_dictionary = new DefaultContext( dictionary );
           m_dictionary.put( "classloader", loader );
  +        m_dictionary.put( "home", new File( System.getProperty("user.dir") ) );
           m_dictionary.makeReadOnly();
       }
   
  
  
  
  1.6       +76 -8     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/ContainerClassLoader.java
  
  Index: ContainerClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/ContainerClassLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContainerClassLoader.java	20 Jul 2002 00:54:07 -0000	1.5
  +++ ContainerClassLoader.java	24 Jul 2002 17:03:07 -0000	1.6
  @@ -215,6 +215,15 @@
       protected void addURL( URL url )
       {
           super.addURL( url );
  +        checkForComponents( url );
  +    }
  +
  +   /**
  +    * Add a URL to the classpath.
  +    * @param url the URL to add to the classpath
  +    */
  +    protected void checkForComponents( URL url )
  +    {
           String[] entries = getBlocksEntries( url );
           for( int j=0; j<entries.length; j++ )
           {
  @@ -232,6 +241,7 @@
           }
       }
   
  +
       //===================================================================
       // TypeManager
       //===================================================================
  @@ -249,7 +259,8 @@
       {
   
           getLogger().debug( "adding classpath" );
  -        ArrayList list = new ArrayList();
  +        List list = new ArrayList();
  +        Vector stack = new Vector();
           File dir = new File( System.getProperty("user.dir") );
           FilesetDescriptor[] dirs = classpath.getFilesetDescriptors();
           for( int i=0; i<dirs.length; i++ )
  @@ -261,24 +272,81 @@
               {
                   File include = new File( base, includes[j].getFile() );
                   list.add( include.toURL() );
  +                stack.add( include );
               }
           }
  +        
           URL[] urls = (URL[]) list.toArray( new URL[0] );
  -        for( int i = 0; i < urls.length; i++ )
  -        {
  -            getLogger().info("adding: " + urls[i] );    
  -            addURL( urls[i] );
  -        }
           String[] path = urlsToStrings( urls );
           final File[] extensions = getOptionalPackagesFor( path );
           for( int i = 0; i < extensions.length; i++ )
           {
               URL url = extensions[ i ].toURL();
               getLogger().info("extension: " + extensions[ i ].toURL() ); 
  -            addURL( url );
  +            super.addURL( url );
  +        }
  +        load( stack );
  +        for( int i = 0; i < urls.length; i++ )
  +        {
  +            getLogger().info("adding: " + urls[i] );    
  +            checkForComponents( urls[i] );
           }
           getLogger().debug( "classpath addition complete" );
   
  +    }
  +
  +    /**
  +     * Load the supplied jar files under the pipeline classloader.
  +     * For each entry in the stack, try to load it and
  +     * if sucessfull, remove it from the stack - on completion
  +     * the stack should be less than its original size - recursivly
  +     * invoke load until the stack is empty.
  +     * @param stack a <code>Vector</code> containing a sequence of jar files
  +     *   to be added to the classloader.
  +     */
  +    private void load( Vector stack )
  +    {
  +        int size = stack.size();
  +        getLogger().debug( "Stack size: " + stack.size() );
  +        Hashtable errors = new Hashtable();
  +        Enumeration enum = stack.elements();
  +        while( enum.hasMoreElements() )
  +        {
  +            File file = (File)enum.nextElement();
  +            getLogger().debug( "Loading resource: " + file );
  +            try
  +            {
  +                super.addURL( file.toURL() );
  +                stack.remove( file );
  +            }
  +            catch( Throwable error )
  +            {
  +                getLogger().warn(
  +                        "Encountered error while loading resource: " + file, error );
  +                errors.put( file, error );
  +            }
  +        }
  +        if( stack.size() == 0 )
  +        {
  +            return;
  +        }
  +        if( stack.size() < size )
  +        {
  +            load( stack );
  +        }
  +        else
  +        {
  +            Enumeration keys = errors.keys();
  +            getLogger().error( "Load error count = " + errors.size() );
  +            while( keys.hasMoreElements() )
  +            {
  +                File key = (File)keys.nextElement();
  +                getLogger().error(
  +                    "Error while loading file."
  +                    + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) );
  +            }
  +            throw new RuntimeException( "Unable to load file stack - see trace for details."
);
  +        }
       }
   
       private String[] urlsToStrings( URL[] urls )
  
  
  
  1.4       +2 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/IncludeDescriptor.java
  
  Index: IncludeDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/IncludeDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IncludeDescriptor.java	14 Jul 2002 00:55:12 -0000	1.3
  +++ IncludeDescriptor.java	24 Jul 2002 17:03:07 -0000	1.4
  @@ -51,4 +51,5 @@
       {
           return m_file;
       }
  +
   }
  
  
  

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


Mime
View raw message