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/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization DefaultInitializationService.java
Date Sun, 23 Feb 2003 14:08:43 GMT
mcconnell    2003/02/23 06:08:43

  Modified:    assembly/src/java/org/apache/avalon/assembly/appliance
                        DefaultApplianceRepository.java
               assembly/src/java/org/apache/avalon/assembly/engine
                        DefaultRepositoryManager.java
                        EngineClassLoader.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization
                        DefaultInitializationService.java
  Log:
  Preliminary content relating to simulated scanning.
  
  Revision  Changes    Path
  1.4       +3 -18     avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java
  
  Index: DefaultApplianceRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultApplianceRepository.java	17 Feb 2003 12:05:10 -0000	1.3
  +++ DefaultApplianceRepository.java	23 Feb 2003 14:08:43 -0000	1.4
  @@ -56,34 +56,19 @@
   import java.util.ArrayList;
   import java.net.URL;
   
  -import org.apache.avalon.assembly.lifestyle.LifestyleService;
  -import org.apache.avalon.assembly.lifestyle.DefaultLifestyleService;
  -import org.apache.avalon.assembly.logging.DefaultLoggingManager;
  -import org.apache.avalon.assembly.logging.LoggingManager;
   import org.apache.avalon.assembly.engine.Engine;
   import org.apache.avalon.framework.Version;
  -import org.apache.avalon.framework.activity.Initializable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.DefaultContext;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.ReferenceDescriptor;
  -import org.apache.avalon.meta.model.Profile;
   import org.apache.avalon.meta.info.InfoDescriptor;
  +import org.apache.avalon.meta.model.Profile;
   
   /**
    * The default appliance manager provides support for {@link Appliance}
    * registration and retrival.
    *
  + * @todo the engine constructor argument is not being used and should be retracted
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  
  
  
  1.12      +74 -3     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultRepositoryManager.java	16 Feb 2003 10:58:36 -0000	1.11
  +++ DefaultRepositoryManager.java	23 Feb 2003 14:08:43 -0000	1.12
  @@ -246,9 +246,16 @@
   
           if( isDirectory( url ) )
           {
  -            if( getLogger().isWarnEnabled() )
  +            File dir = getDirectory( url );
  +            try
  +            {
  +                load( dir, dir );
  +            }
  +            catch( IOException e )
               {
  -                getLogger().warn("directory scanning not supported: " + url );
  +                final String error = 
  +                  "Unexpected IO error while attempting to scan directory: " + dir;
  +                throw new EngineRuntimeException( error, e );
               }
               return;
           }
  @@ -297,6 +304,44 @@
           }
       }
   
  +    private void load( File base, File dir ) throws IOException
  +    {
  +        File[] files = dir.listFiles();
  +        String path = base.toString();
  +        int j = path.length();
  +        getLogger().debug( "scanning: " + path );
  +        for( int i=0; i<files.length; i++ )
  +        {
  +            File file = files[i];
  +            if( file.isDirectory() )
  +            {
  +                load( dir, file );
  +            }
  +            String filename = file.toString();
  +            String name = filename.substring( j, filename.length() );
  +            if( name.endsWith( X_TYPE ) )
  +            {
  +                getLogger().debug( "parsing: " + name );
  +                try
  +                {
  +                    Type type = processType( name );
  +
  +                    //
  +                    // ## code incomplete - need to add type to m_types
  +                    // and process the type - this needs some refactoring of the 
  +                    // load( jar ) method so we do not duplicate code.
  +                    // 
  +                }
  +                catch( Throwable e )
  +                {
  +                    final String warning = 
  +                      "Removing resource in path " + path + " due to a parse error: " +
name;
  +                    getLogger().warn( warning, e );
  +                }
  +            }
  +        }
  +    }
  +
       private void load( JarFile base ) throws IOException
       {
   
  @@ -389,6 +434,16 @@
           }
       }
   
  +   /**
  +    * Take a filename and resolve it to a class and construct a type from the 
  +    * corresponding xinfo file.
  +    */
  +    private Type processType( String name ) throws Exception
  +    {
  +        String classname = parseResourceName( name );
  +        return m_types.createType( classname );
  +    }
  +
       private boolean isDirectory( URL url )
       {
           if( url.getProtocol().equals( "file" ) )
  @@ -397,6 +452,22 @@
               return file.isDirectory();
           }
           return false;
  +    }
  +
  +    private File getDirectory( URL url ) throws IllegalArgumentException
  +    {
  +        if( url.getProtocol().equals( "file" ) )
  +        {
  +            File file = new File( url.toString().substring( 5 ) );
  +            if( file.isDirectory() )
  +            {
  +                return file;
  +            }
  +            throw new IllegalArgumentException( 
  +              "URL does not refer to a directory: " + url );
  +        }
  +        throw new IllegalArgumentException( 
  +          "URL protocol does not match the required file protocol: " + url );
       }
   
       private String parseResourceName( String resource )
  
  
  
  1.36      +2 -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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- EngineClassLoader.java	17 Feb 2003 12:04:33 -0000	1.35
  +++ EngineClassLoader.java	23 Feb 2003 14:08:43 -0000	1.36
  @@ -771,7 +771,7 @@
           }
           else
           {
  -           getLogger().warn( "#### Expanding a classpath without a base!" );
  +           getLogger().debug( "expanding a classpath without a base" );
           }
   
           //
  
  
  
  1.7       +1 -2      avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/DefaultInitializationService.java
  
  Index: DefaultInitializationService.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/DefaultInitializationService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultInitializationService.java	17 Feb 2003 12:07:44 -0000	1.6
  +++ DefaultInitializationService.java	23 Feb 2003 14:08:43 -0000	1.7
  @@ -89,7 +89,6 @@
           {
               if( appliance.getStartupPolicy() )
               {
  -                getLogger().debug( "### " + appliance + ", " + appliance.getStartupPolicy()
);
                   if( getLogger().isDebugEnabled() )
                   {
                       final String message = "starting " + appliance;
  
  
  

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


Mime
View raw message