mcconnell    2003/03/06 04:24:17

  Modified:    assembly/src/java/org/apache/avalon/assembly/engine
                        DefaultRepositoryManager.java
  Log:
  Improved support for loading of block based on a jar: protocol.
  
  Revision  Changes    Path
  1.15      +49 -37    
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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DefaultRepositoryManager.java     6 Mar 2003 09:11:34 -0000       1.14
  +++ DefaultRepositoryManager.java     6 Mar 2003 12:24:16 -0000       1.15
  @@ -274,53 +274,32 @@
               return;
           }
   
  -        if( isFile( url ) )
  +        if( getLogger().isDebugEnabled() )
           {
  -            if( getLogger().isDebugEnabled() )
  -            {
  -                getLogger().debug("scanning: " + url );
  -            }
  +            getLogger().debug("scanning: " + url );
  +        }
   
  -            //
  -            // we are dealing with a jar file so we need to scan the classes
  -            // for service and type defintions
  -            //
  +        if( url.getProtocol().equals("jar") )
  +        {
  +            loadJarFile( url );
  +            return;
  +        }
   
  +        if( isFile( url ) )
  +        {
               try
               {
                   URL resource = getJarURL( url );
  -                if( resource.toString().endsWith( "!/" ) )
  -                {
  -                    final JarURLConnection jar = 
(JarURLConnection)resource.openConnection();
  -                    final JarFile base = jar.getJarFile();
  -                    m_scanned.add( url );
  -                    load( base );
  -                    return;
  -                }
  -                else
  -                {
  -                    final String error =
  -                      "Embeded jar file loading not supported at this time: " + url;
  -                    throw new EngineRuntimeException( error );
  -                }
  -            }
  -            catch( EngineRuntimeException e )
  -            {
  -                throw e; 
  +                loadJarFile( resource );
               }
               catch( Throwable e )
               {
                   final String error = 
  -                  "Unexpected error while handling a file url: " + url;
  -                throw new EngineRuntimeException( error );
  +                  "Unexpected exception while loading a file: " + url;
  +                throw new EngineRuntimeException( error, e );
               }
           }
  -
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            getLogger().debug("scanning: " + url );
  -        }
  -
  +        
           try
           {
               Object object = url.getContent();
  @@ -332,7 +311,8 @@
               }
               else
               {
  -                getLogger().warn("unrecognized content type [" 
  +                getLogger().warn(
  +                 "unrecognized content type [" 
                    + object.getClass() + "] in url: " + url );
                   return;
               }
  @@ -341,6 +321,38 @@
           {
               getLogger().warn("content error related to url: " + url, e );
               return;
  +        }
  +    }
  +
  +    private void loadJarFile( URL url )
  +    {
  +        if( !url.getProtocol().equals( "jar" ) )
  +        {
  +            final String error = 
  +              "Supplied URL is not the jar protocol.";
  +            throw new IllegalArgumentException( error );
  +        }
  +
  +        if( !url.toString().endsWith( "!/" ) )
  +        {
  +            final String error =
  +              "Embeded jar file loading not supported: " + url;
  +            throw new IllegalArgumentException( error );
  +        }
  +
  +        try
  +        {
  +            final JarURLConnection jar = (JarURLConnection)url.openConnection();
  +            final JarFile base = jar.getJarFile();
  +            m_scanned.add( url );
  +            load( base );
  +            return;
  +        }
  +        catch( Throwable e )
  +        {
  +             final String error = 
  +              "Unexpected error while handling url: " + url;
  +            throw new EngineRuntimeException( error );
           }
       }
   
  
  
  

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

Reply via email to