ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type DefaultTypeFactory.java
Date Thu, 07 Feb 2002 08:57:44 GMT
donaldp     02/02/07 00:57:44

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type
                        DefaultTypeFactory.java
  Log:
  Use indirection to get ClassLoader.
  
  Make sure the ClassLoader passed in via constructor is not null - if it is throw a null
pointer exception then to help draw out source of error.
  
  Revision  Changes    Path
  1.7       +14 -4     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/DefaultTypeFactory.java
  
  Index: DefaultTypeFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/type/DefaultTypeFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultTypeFactory.java	1 Feb 2002 00:37:59 -0000	1.6
  +++ DefaultTypeFactory.java	7 Feb 2002 08:57:44 -0000	1.7
  @@ -15,7 +15,7 @@
    * Create a type instance based on name.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2002/02/01 00:37:59 $
  + * @version CVS $Revision: 1.7 $ $Date: 2002/02/07 08:57:44 $
    */
   public class DefaultTypeFactory
       implements TypeFactory
  @@ -31,6 +31,11 @@
   
       public DefaultTypeFactory( final ClassLoader classLoader )
       {
  +        if( null == classLoader )
  +        {
  +            throw new NullPointerException( "classLoader" );
  +        }
  +
           m_classLoader = classLoader;
       }
   
  @@ -50,10 +55,11 @@
           throws TypeException
       {
           final String className = getClassName( name );
  -
           try
           {
  -            return m_classLoader.loadClass( className ).newInstance();
  +            final ClassLoader classLoader = getClassLoader();
  +            final Class clazz = classLoader.loadClass( className );
  +            return clazz.newInstance();
           }
           catch( final Exception e )
           {
  @@ -66,7 +72,6 @@
           throws TypeException
       {
           final String className = (String)m_classNames.get( name );
  -
           if( null == className )
           {
               final String message = REZ.getString( "no-mapping.error", name );
  @@ -74,5 +79,10 @@
           }
   
           return className;
  +    }
  +
  +    private ClassLoader getClassLoader()
  +    {
  +        return m_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