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/interfaces/library LibraryManager.java
Date Mon, 13 May 2002 09:52:31 GMT
adammurdoch    02/05/13 02:52:31

  Modified:    antlib/src/java/org/apache/antlib/runtime ImportTask.java
                        Resources.properties TypeAvailableCondition.java
               container/src/java/org/apache/myrmidon/components/executor
                        Resources.properties
               container/src/java/org/apache/myrmidon/components/library
                        DefaultLibraryManager.java Resources.properties
               container/src/java/org/apache/myrmidon/interfaces/library
                        LibraryManager.java
  Added:       antlib/src/java/org/apache/antlib/runtime
                        AbstractLibraryClassPath.java
                        RootLibraryClassPath.java
                        TypeLibAvailableCondition.java
                        TypeLibClassPath.java
  Log:
  * Added <typelib-path> path, which evaluates to the path of an antlib
    or extension (tools.jar, say).
  
  * Added <ant-classpath> path, which evaluates to the class-path of the
    shared classloader.
  
  * Added <typelib-available> condition, which checks for the availability of
    an antlib or extension (only by name so far).
  
  Revision  Changes    Path
  1.3       +7 -2      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ImportTask.java
  
  Index: ImportTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ImportTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ImportTask.java	12 May 2002 12:57:54 -0000	1.2
  +++ ImportTask.java	13 May 2002 09:52:30 -0000	1.3
  @@ -41,8 +41,7 @@
           super.validate();
           if( null == m_library )
           {
  -            final String message =
  -                REZ.getString( "import.missing-library.error" );
  +            final String message = REZ.getString( "no-libname.error" );
               throw new TaskException( message );
           }
       }
  @@ -54,6 +53,12 @@
       {
           final LibraryManager libraryManager = (LibraryManager)getService( LibraryManager.class
);
           final Library library = libraryManager.getLibrary( m_library );
  +        if( library == null )
  +        {
  +            // Could not find the library
  +            final String message = REZ.getString( "no-library.error", m_library );
  +            throw new Exception( message );
  +        }
           return library;
       }
   }
  
  
  
  1.5       +7 -1      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Resources.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Resources.properties	12 May 2002 11:18:39 -0000	1.4
  +++ Resources.properties	13 May 2002 09:52:30 -0000	1.5
  @@ -1,4 +1,5 @@
  -import.missing-library.error=No library name specified.
  +no-libname.error=No type library name specified.
  +no-library.error=Could not find type library "{0}".
   
   typelib.no-lib.error=No library path specified.
   
  @@ -8,3 +9,8 @@
   abstracttypelib.missing-name.error=Specified role ("{0}") but missing type name.
   abstracttypelib.missing-role.error=Specified name ("{0}") but missing role name..
   abstracttypelib.no-deploy.error=Could not import types from Type Library.
  +
  +typelib-available.evaluate.error=Could not determine if library is available.
  +
  +typelib-path.evaluate.error=Could not determine the class-path for type library "{0}".
  +abstract-typelib-path.classpath-not-local.error=The type library's class-path contains
non-file URLs.
  \ No newline at end of file
  
  
  
  1.3       +2 -2      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java
  
  Index: TypeAvailableCondition.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeAvailableCondition.java	24 Apr 2002 02:20:58 -0000	1.2
  +++ TypeAvailableCondition.java	13 May 2002 09:52:30 -0000	1.3
  @@ -20,7 +20,7 @@
    * A condition that evaluates to true if a particular type is available.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.2 $ $Date: 2002/04/24 02:20:58 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/13 09:52:30 $
    *
    * @ant.type type="condition" name="type-available"
    */
  @@ -36,7 +36,7 @@
       /**
        * Sets the role to search for.
        */
  -    public void setType( final String type )
  +    public void setRole( final String type )
       {
           m_roleName = type;
       }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/AbstractLibraryClassPath.java
  
  Index: AbstractLibraryClassPath.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.myrmidon.framework.file.FileList;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.library.Library;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import java.net.URL;
  import java.io.File;
  
  /**
   * An abstract FileList implementation, that evaluates to the class-path for
   * a typelib.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/13 09:52:30 $
   *
   * @todo - Implement the vfs FileList interface instead.
   */
  public abstract class AbstractLibraryClassPath
      implements FileList
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( AbstractLibraryClassPath.class );
  
      /**
       * Returns the files in this list.
       */
      public String[] listFiles( final TaskContext context )
          throws TaskException
      {
          final Library library = getLibrary( context );
  
          // Build the file list
          final URL[] classPath = library.getClassPath();
          final String[] files = new String[ classPath.length ];
          for( int i = 0; i < classPath.length; i++ )
          {
              final URL url = classPath[ i ];
              if( !url.getProtocol().equals( "file" ) )
              {
                  final String message = REZ.getString( "abstract-typelib-path.classpath-not-local.error"
);
                  throw new TaskException( message );
              }
              files[ i ] = new File( url.getFile() ).getAbsolutePath();
          }
  
          return files;
      }
  
      /**
       * Returns the library to build the class-path for.
       */
      protected abstract Library getLibrary( final TaskContext context )
          throws TaskException;
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/RootLibraryClassPath.java
  
  Index: RootLibraryClassPath.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.myrmidon.interfaces.library.Library;
  import org.apache.myrmidon.interfaces.library.LibraryManager;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * A FileList that evaluates to the class-path for the root typelib.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/13 09:52:30 $
   *
   * @ant.type type="path" name="ant-classpath"
   */
  public class RootLibraryClassPath
      extends AbstractLibraryClassPath
  {
      /**
       * Returns the library to build the class-path for.
       */
      protected Library getLibrary( final TaskContext context )
          throws TaskException
      {
          final LibraryManager libraryManager = (LibraryManager)context.getService( LibraryManager.class
);
          return libraryManager.getRootLibrary();
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeLibAvailableCondition.java
  
  Index: TypeLibAvailableCondition.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.myrmidon.framework.conditions.Condition;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.library.LibraryManager;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * A condition that determines whether a typelib is available.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/13 09:52:30 $
   *
   * @ant.type type="condition" name="typelib-available"
   */
  public class TypeLibAvailableCondition
      implements Condition
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( TypeLibAvailableCondition.class );
  
      private String m_library;
  
      public void setLibrary( final String library )
      {
          m_library = library;
      }
  
      /**
       * Evaluates this condition.
       */
      public boolean evaluate( final TaskContext context )
          throws TaskException
      {
          if( m_library == null )
          {
              final String message = REZ.getString( "no-libname.error" );
              throw new TaskException( message );
          }
  
          try
          {
              final LibraryManager libraryManager = (LibraryManager)context.getService( LibraryManager.class
);
              return ( libraryManager.getLibrary( m_library ) != null );
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "typelib-available.evaluate.error" );
              throw new TaskException( message, e );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeLibClassPath.java
  
  Index: TypeLibClassPath.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.runtime;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.library.Library;
  import org.apache.myrmidon.interfaces.library.LibraryManager;
  
  /**
   * A FileList that evaluates to the class-path for a typelib.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/13 09:52:30 $
   *
   * @ant.type type="path" name="typelib-path"
   */
  public class TypeLibClassPath
      extends AbstractLibraryClassPath
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( TypeLibClassPath.class );
  
      private String m_library;
  
      public void setLibrary( final String library )
      {
          m_library = library;
      }
  
      /**
       * Returns the library to build the class-path for.
       */
      protected Library getLibrary( final TaskContext context ) throws TaskException
      {
          if( m_library == null )
          {
              final String message = REZ.getString( "no-libname.error" );
              throw new TaskException( message );
          }
  
          try
          {
              final LibraryManager libraryManager = (LibraryManager)context.getService( LibraryManager.class
);
              final Library library = libraryManager.getLibrary( m_library );
              if( library != null )
              {
                  return library;
              }
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "typelib-path.evaluate.error", m_library
);
              throw new TaskException( message, e );
          }
  
          // Could not find the library
          final String message = REZ.getString( "no-library.error", m_library );
          throw new TaskException( message );
      }
  }
  
  
  
  1.8       +5 -8      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/Resources.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Resources.properties	11 Mar 2002 08:41:32 -0000	1.7
  +++ Resources.properties	13 May 2002 09:52:30 -0000	1.8
  @@ -1,11 +1,8 @@
  -creating.notice=Creating {0}.
  -contextualizing.notice=Contextualizing {0}.
  -configuring.notice=Configuring {0}.
  -executing.notice=Executing {0}.
  +creating.notice=Creating task {0}.
  +contextualizing.notice=Contextualizing task {0}.
  +configuring.notice=Configuring task {0}.
  +executing.notice=Executing task {0}.
   
   create.error=Could not create task <{0}>.
   contextualize.error=Could not set the context for task <{0}>.
  -execute.error={1}: Could not execute task <{0}>.
  -
  -unused-settings.error=Unused aspect settings for namespace {0} (parameterCount={1} elementCount={2}).
  -dispatch-settings.notice=Dispatching Aspect Settings to namespace {0} (parameterCount={1}
elementCount={2}).
  +execute.error={1}: Task <{0}> failed.
  
  
  
  1.5       +14 -8     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultLibraryManager.java	12 May 2002 12:57:54 -0000	1.4
  +++ DefaultLibraryManager.java	13 May 2002 09:52:30 -0000	1.5
  @@ -39,7 +39,7 @@
    * The default library manager implementation.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.4 $ $Date: 2002/05/12 12:57:54 $
  + * @version $Revision: 1.5 $ $Date: 2002/05/13 09:52:30 $
    */
   public class DefaultLibraryManager
       implements Serviceable, Contextualizable, Initializable, LibraryManager
  @@ -71,7 +71,16 @@
   
       public void initialize() throws Exception
       {
  -        m_rootLibrary = buildLibrary( "myrmidon.runtime", null, m_rootClassLoader );
  +        m_rootLibrary = buildLibrary( "myrmidon.shared", null, m_rootClassLoader );
  +    }
  +
  +    /**
  +     * Returns the root library - that is, the library that is the ultimate
  +     * ancestor of all libraries created by this library manager.
  +     */
  +    public Library getRootLibrary()
  +    {
  +        return m_rootLibrary;
       }
   
       /**
  @@ -92,20 +101,17 @@
           {
               final Extension extension = new Extension( libraryName, null, null, null, null,
null, null );
               final OptionalPackage pkg = m_extensionManager.getOptionalPackage( extension
);
  -            if( pkg != null )
  +            if( pkg == null )
               {
  -                return buildLibrary( pkg, new HashSet() );
  +                return null;
               }
  +            return buildLibrary( pkg, new HashSet() );
           }
           catch( final Exception e )
           {
               final String message = REZ.getString( "load-library.error", libraryName );
               throw new ComponentException( message, e );
           }
  -
  -        // Could not find the library
  -        final String message = REZ.getString( "no-library.error", libraryName );
  -        throw new Exception( message );
       }
   
       /**
  
  
  
  1.3       +0 -1      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/Resources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	10 May 2002 06:27:31 -0000	1.2
  +++ Resources.properties	13 May 2002 09:52:30 -0000	1.3
  @@ -1,6 +1,5 @@
   no-file.error=Could not find library "{0}".
   file-is-dir.error=Library "{0}" is a directory.
  -no-library.error=Could not find Type Library "{0}".
   load-library.error=Could not load Type Library "{0}".
   get-classpath-for-loader.error=Could not determine the class-path for a ClassLoader.
   create-classloader-for-files.error=Could not create a ClassLoader for {0}.
  
  
  
  1.4       +13 -2     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/library/LibraryManager.java
  
  Index: LibraryManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/library/LibraryManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LibraryManager.java	12 May 2002 12:57:54 -0000	1.3
  +++ LibraryManager.java	13 May 2002 09:52:30 -0000	1.4
  @@ -13,14 +13,25 @@
    * Manages a set of libraries.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/12 12:57:54 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/13 09:52:30 $
    */
   public interface LibraryManager
   {
       String ROLE = LibraryManager.class.getName();
   
       /**
  +     * Returns the root library - that is, the library that is the ultimate
  +     * ancestor of all libraries created by this library manager.
  +     */
  +    Library getRootLibrary();
  +
  +    /**
        * Locates a library by name.
  +     *
  +     * @param libName The name of the library to locate.
  +     * @return The library.  Returns null if the library could not be found.
  +     *         Returns the newest library if there is more than one library
  +     *         with the name.
        */
       Library getLibrary( String libName ) throws Exception;
   
  @@ -35,7 +46,7 @@
       Library createLibrary( ClassLoader classLoader ) throws Exception;
   
       /**
  -     * Creates a library for a set of files, locating any extensions required
  +     * Creates a library for a set of files, locating any libraries required
        * by the files.
        *
        * <p>The ancestors of the library ClassLoader will include the ClassLoader
  
  
  

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