ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library DefaultLibraryManager.java DefaultLibrary.java
Date Tue, 25 Jun 2002 07:13:28 GMT
adammurdoch    2002/06/25 00:13:28

  Modified:    container/src/java/org/apache/myrmidon/interfaces/library
                        Library.java
               container/src/java/org/apache/myrmidon/components/library
                        DefaultLibraryManager.java DefaultLibrary.java
  Log:
  Added Library.getParents() and getExtensions().
  
  Revision  Changes    Path
  1.2       +8 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/library/Library.java
  
  Index: Library.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/library/Library.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Library.java	3 May 2002 06:56:11 -0000	1.1
  +++ Library.java	25 Jun 2002 07:13:28 -0000	1.2
  @@ -28,7 +28,13 @@
       /**
        * Returns the library meta-info, if any.
        */
  -    Extension getExtension();
  +    Extension[] getExtensions();
  +
  +    /**
  +     * Returns the parents of this library.  Returns an empty array if this
  +     * library has no parent.
  +     */
  +    Library[] getParents();
   
       /**
        * Returns the ClassLoader for the library.
  
  
  
  1.9       +30 -10    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultLibraryManager.java
  
  Index: DefaultLibraryManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultLibraryManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultLibraryManager.java	22 May 2002 07:26:25 -0000	1.8
  +++ DefaultLibraryManager.java	25 Jun 2002 07:13:28 -0000	1.9
  @@ -23,13 +23,13 @@
   import org.apache.avalon.excalibur.extension.OptionalPackage;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.activity.Initializable;
   import org.apache.myrmidon.interfaces.ComponentException;
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
   import org.apache.myrmidon.interfaces.library.Library;
  @@ -86,7 +86,7 @@
       /**
        * Creates a library wrapper for a ClassLoader.
        */
  -    public Library createLibrary( ClassLoader classLoader ) throws Exception
  +    public Library createLibrary( final ClassLoader classLoader ) throws Exception
       {
           return buildLibrary( null, null, classLoader );
       }
  @@ -174,7 +174,7 @@
        * Builds a library for a ClassLoader.
        */
       private Library buildLibrary( final String name,
  -                                  final Extension extension,
  +                                  final Extension[] extensions,
                                     final ClassLoader classLoader )
           throws Exception
       {
  @@ -185,7 +185,11 @@
               prependClassPath( loader, classPath );
           }
           final URL[] libClassPath = (URL[])classPath.toArray( new URL[ classPath.size()
] );
  -        return new DefaultLibrary( name, extension, classLoader, libClassPath );
  +        return new DefaultLibrary( name,
  +                                   extensions,
  +                                   classLoader,
  +                                   libClassPath,
  +                                   new Library[ 0 ] );
       }
   
       /**
  @@ -195,25 +199,41 @@
                                     final Library[] parentLibraries )
           throws Exception
       {
  +        // Assemble the classpath and available extensions from the set of packages
           final URL[] urls = new URL[ packages.length ];
  +        final ArrayList extensions = new ArrayList();
           for( int i = 0; i < packages.length; i++ )
           {
  -            urls[ i ] = toUrl( packages[ i ].getFile() );
  +            final OptionalPackage pkg = packages[ i ];
  +            urls[ i ] = toUrl( pkg.getFile() );
  +            final Extension[] pkgExtensions = pkg.getAvailableExtensions();
  +            for( int j = 0; j < pkgExtensions.length; j++ )
  +            {
  +                extensions.add( pkgExtensions[ j ] );
  +            }
           }
  +
  +        // Create the classloader
           final ClassLoader[] parentClassLoaders = new ClassLoader[ parentLibraries.length
];
           for( int i = 0; i < parentLibraries.length; i++ )
           {
               parentClassLoaders[ i ] = parentLibraries[ i ].getClassLoader();
           }
           final ClassLoader classLoader = new MultiParentURLClassLoader( urls, parentClassLoaders
);
  -        String name = null;
  -        final Extension[] extns = packages[ 0 ].getAvailableExtensions();
  -        if( extns != null && extns.length > 0 )
  +
  +        // Figure out the name
  +        final Extension[] extns = (Extension[])extensions.toArray( new Extension[ extensions.size()
] );
  +        final String name;
  +        if( extns.length == 0 )
  +        {
  +            name = null;
  +        }
  +        else
           {
               name = extns[ 0 ].getExtensionName();
           }
   
  -        return new DefaultLibrary( name, null, classLoader, urls );
  +        return new DefaultLibrary( name, extns, classLoader, urls, parentLibraries );
       }
   
       /**
  
  
  
  1.2       +19 -7     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultLibrary.java
  
  Index: DefaultLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultLibrary.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLibrary.java	3 May 2002 06:56:11 -0000	1.1
  +++ DefaultLibrary.java	25 Jun 2002 07:13:28 -0000	1.2
  @@ -21,19 +21,22 @@
       implements Library
   {
       private final String m_name;
  -    private final Extension m_extension;
  +    private final Extension[] m_extensions;
       private final ClassLoader m_classLoader;
       private final URL[] m_classpath;
  +    private final Library[] m_parentLibs;
   
       public DefaultLibrary( final String name,
  -                           final Extension extension,
  +                           final Extension[] extensions,
                              final ClassLoader classLoader,
  -                           final URL[] classpath )
  +                           final URL[] classpath,
  +                           final Library[] parentLibs )
       {
           m_name = name;
  -        m_extension = extension;
  +        m_extensions = extensions;
           m_classLoader = classLoader;
           m_classpath = classpath;
  +        m_parentLibs = parentLibs;
       }
   
       /**
  @@ -47,9 +50,18 @@
       /**
        * Returns the library meta-info, if any.
        */
  -    public Extension getExtension()
  +    public Extension[] getExtensions()
       {
  -        return m_extension;
  +        return m_extensions;
  +    }
  +
  +    /**
  +     * Returns the parents of this library.  Returns an empty array if this
  +     * library has no parent.
  +     */
  +    public Library[] getParents()
  +    {
  +        return m_parentLibs;
       }
   
       /**
  
  
  

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


Mime
View raw message