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/engine EngineClassLoader.java
Date Mon, 09 Dec 2002 12:10:43 GMT
mcconnell    2002/12/09 04:10:42

  Modified:    assembly/src/java/org/apache/avalon/assembly/engine
                        EngineClassLoader.java
  Log:
  Updated to handle a wider range of launch scenarios.
  
  Revision  Changes    Path
  1.4       +69 -15    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EngineClassLoader.java	9 Dec 2002 03:03:47 -0000	1.3
  +++ EngineClassLoader.java	9 Dec 2002 12:10:42 -0000	1.4
  @@ -117,6 +117,7 @@
   import org.apache.avalon.assembly.engine.model.ClasspathDescriptor;
   import org.apache.avalon.assembly.engine.model.FilesetDescriptor;
   import org.apache.avalon.assembly.engine.model.IncludeDescriptor;
  +import org.apache.avalon.assembly.engine.model.ClasspathDescriptor;
   import org.apache.excalibur.mpool.DefaultPoolManager;
   import org.apache.excalibur.mpool.PoolManager;
   import org.apache.excalibur.event.command.CommandManager;
  @@ -214,6 +215,11 @@
       private LibraryDescriptor m_descriptor;
   
       /**
  +     * Classpath descriptor.
  +     */
  +    private ClasspathDescriptor m_classpath;
  +
  +    /**
        * The set of facilities.
        */
       private Map m_facilities = new Hashtable();
  @@ -238,7 +244,7 @@
       //=======================================================================
   
       /**
  -     * Creation of a new type manager using.
  +     * Creation of a new engine.
        */
       public EngineClassLoader()
       {
  @@ -246,6 +252,20 @@
           m_graph = new DependencyGraph();
       }
   
  +    /**
  +     * Creation of a new engine with a partner
  +     */
  +    public EngineClassLoader( EngineClassLoader parent )
  +    {
  +        super( new URL[ 0 ], parent );
  +        m_graph = new DependencyGraph( parent.getDependencyGraph() );
  +    }
  +
  +    protected DependencyGraph getDependencyGraph()
  +    {
  +        return m_graph;
  +    }
  +
       //=======================================================================
       // LogEnabled
       //=======================================================================
  @@ -309,7 +329,7 @@
   
           try
           {
  -            m_descriptor = (LibraryDescriptor)context.get( "urn:assembly:extensions.descriptor"
);
  +            m_descriptor = (LibraryDescriptor)context.get( "urn:assembly:engine.extensions"
);
           }
           catch( ContextException e )
           {
  @@ -318,6 +338,15 @@
   
           try
           {
  +            m_classpath = (ClasspathDescriptor)context.get( "urn:assembly:engine.classpath"
);
  +        }
  +        catch( ContextException e )
  +        {
  +            m_classpath = new ClasspathDescriptor();
  +        }
  +
  +        try
  +        {
               m_home = (File)context.get( "urn:avalon:home" );
           }
           catch( ContextException e )
  @@ -400,11 +429,11 @@
           //
   
           ArrayList list = new ArrayList();
  -        File anchor = new File( m_home, m_descriptor.getBaseDirectory() );
  +        File anchor = new File( m_home, m_descriptor.getBaseDirectory() ).getCanonicalFile();
           IncludeDescriptor[] includes = m_descriptor.getIncludeDescriptors();
           for( int j = 0; j < includes.length; j++ )
           {
  -            File include = new File( anchor, includes[ j ].getFile() );
  +            File include = new File( anchor, includes[ j ].getFile() ).getCanonicalFile();
               if( include.isDirectory() )
               {
                   list.add( include );
  @@ -425,7 +454,7 @@
               while( tokenizer.hasMoreTokens() )
               {
                   String token = tokenizer.nextToken();
  -                File test = new File( token );
  +                File test = new File( token ).getCanonicalFile();
                   if( test.exists() )
                   {
                       list.add( test );
  @@ -436,7 +465,7 @@
                   }
                   else
                   {
  -                    File file = new File( m_home, token );
  +                    File file = new File( m_home, token ).getCanonicalFile();
                       if( file.exists() )
                       {
                           list.add( file  );
  @@ -486,7 +515,7 @@
               while( tokenizer.hasMoreTokens() )
               {
                   String token = tokenizer.nextToken();
  -                URL url = new File( token ).toURL();
  +                URL url = new File( token ).getCanonicalFile().toURL();
                   if( getLogger().isDebugEnabled() )
                   {
                       getLogger().debug( "path: " + url );
  @@ -495,6 +524,20 @@
               }
           }
   
  +        //
  +        // load the classpath
  +        //
  +
  +        try
  +        {
  +            addClasspath( m_classpath );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Classpath deployment failure.";
  +            throw new EngineException( error, e );
  +        }
  +
           if( getLogger().isDebugEnabled() )
           {
               getLogger().debug( "ready" );
  @@ -543,13 +586,24 @@
           for( int i = 0; i < dirs.length; i++ )
           {
               FilesetDescriptor descriptor = dirs[ i ];
  -            File anchor = new File( m_home, descriptor.getBaseDirectory() );
  -            if( !anchor.exists() )
  +            File anchor;
  +            try
  +            {
  +                anchor = new File( m_home, descriptor.getBaseDirectory() ).getCanonicalFile();
  +                if( !anchor.exists() )
  +                {
  +                    final String error =
  +                      "Classpath base directory does not exist: " 
  +                      + anchor;
  +                    throw new EngineRuntimeException( error );
  +                }
  +            }
  +            catch( Throwable e )
               {
  -                final String error =
  -                  "Classpath base directory does not exist: " 
  -                  + anchor;
  -                throw new EngineRuntimeException( error );
  +                final String error = 
  +                  "Error processing a classpath bae directory: " 
  +                   + descriptor;
  +                throw new EngineRuntimeException( error, e );
               }
   
               IncludeDescriptor[] includes = descriptor.getIncludeDescriptors();
  @@ -558,7 +612,7 @@
                   String inc = includes[ j ].getFile();
                   try
                   {
  -                    addURL( new File( anchor, inc ).toURL() );
  +                    addURL( new File( anchor, inc ).getCanonicalFile().toURL() );
                   }
                   catch( Throwable e )
                   {
  
  
  

--
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