You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/06/23 09:30:34 UTC

cvs commit: jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier AssemblyVerifier.java MetaDataVerifier.java

donaldp     2002/06/23 00:30:34

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/verifier
                        AssemblyVerifier.java MetaDataVerifier.java
  Log:
  Separate Assembly and MetaData Verfifiers
  
  Revision  Changes    Path
  1.23      +2 -80     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/AssemblyVerifier.java
  
  Index: AssemblyVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/AssemblyVerifier.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- AssemblyVerifier.java	18 Jun 2002 07:38:47 -0000	1.22
  +++ AssemblyVerifier.java	23 Jun 2002 07:30:34 -0000	1.23
  @@ -12,7 +12,6 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.Logger;
   import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
   import org.apache.excalibur.containerkit.metadata.DependencyMetaData;
   import org.apache.excalibur.containerkit.metainfo.ComponentInfo;
  @@ -54,51 +53,15 @@
           ResourceManager.getPackageResources( AssemblyVerifier.class );
   
       /**
  -     * The verifier for components in assembly.
  -     */
  -    private final MetaDataVerifier m_verifier;
  -
  -    /**
  -     * Create an AssemblyVerifier using base Componernt MetaDataVerifier.
  -     */
  -    public AssemblyVerifier()
  -    {
  -        this( new MetaDataVerifier() );
  -    }
  -
  -    /**
  -     * Create an AssemblyVerifier using specified MetaDataVerifier.
  -     */
  -    public AssemblyVerifier( final MetaDataVerifier verifier )
  -    {
  -        if( null == verifier )
  -        {
  -            throw new NullPointerException( "verifier" );
  -        }
  -
  -        m_verifier = verifier;
  -    }
  -
  -    public void enableLogging( final Logger logger )
  -    {
  -        super.enableLogging( logger );
  -        setupLogger( m_verifier );
  -    }
  -
  -    /**
        * Validate and Verify the specified assembly (ie organization
        * of components). See the Class Javadocs for the rules and
        * regulations of assembly.
        *
        * @param components the Components that make up assembly
  -     * @param classLoader the ClassLoader used to load types. This is used
  -     *                    to verify that specified Class objects exist and
  -     *                    implement the correct interfaces.
        * @throws VerifyException if an error occurs
        * @todo Rework method so that it does not need to accept a ClassLoader object
        */
  -    public void verifyAssembly( final ComponentMetaData[] components,
  -                                final ClassLoader classLoader )
  +    public void verifyAssembly( final ComponentMetaData[] components )
           throws VerifyException
       {
           String message = null;
  @@ -122,18 +85,6 @@
           message = REZ.getString( "assembly.nocircular-dependencies.notice" );
           getLogger().info( message );
           verifyNoCircularDependencies( components );
  -
  -        message = REZ.getString( "assembly.component-type.notice" );
  -        getLogger().info( message );
  -
  -        //Need to move the next chunk of code to a different class
  -        //MetaDataVerifier??
  -        for( int i = 0; i < components.length; i++ )
  -        {
  -            final ComponentMetaData component = components[ i ];
  -            final Class clazz = getClass( classLoader, component );
  -            m_verifier.verifyType( component, clazz );
  -        }
       }
   
       /**
  @@ -349,35 +300,6 @@
           }
   
           return null;
  -    }
  -
  -    /**
  -     * Load class object for specified ComponentMetaData.
  -     *
  -     * @param classLoader the ClassLoader to use
  -     * @param component the meta data associate with component
  -     * @return the Class object
  -     * @throws VerifyException if unable to aquire class object
  -     */
  -    private Class getClass( final ClassLoader classLoader,
  -                            final ComponentMetaData component )
  -        throws VerifyException
  -    {
  -        Class clazz = null;
  -        try
  -        {
  -            clazz = classLoader.loadClass( component.getClassname() );
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message =
  -                REZ.getString( "assembly.bad-class.error",
  -                               component.getName(),
  -                               component.getClassname(),
  -                               e.toString() );
  -            throw new VerifyException( message );
  -        }
  -        return clazz;
       }
   
       /**
  
  
  
  1.3       +46 -2     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/MetaDataVerifier.java
  
  Index: MetaDataVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/MetaDataVerifier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MetaDataVerifier.java	23 Jun 2002 07:25:22 -0000	1.2
  +++ MetaDataVerifier.java	23 Jun 2002 07:30:34 -0000	1.3
  @@ -77,6 +77,21 @@
           super.enableLogging( logger );
           setupLogger( m_verifier );
       }
  +    /**
  +     * Verfiy that specified components designate classes that implement the
  +     * advertised interfaces. And confrorm to expectations of MetaData.
  +     *
  +     * @param component the ComponentMetaData object for the components
  +     * @param classLoader the ClassLoader to load component from
  +     * @throws VerifyException if an error occurs
  +     */
  +    public void verifyType( final ComponentMetaData component,
  +                               final ClassLoader classLoader )
  +        throws VerifyException
  +    {
  +        final Class clazz = getClass( classLoader, component );
  +        verifyType( component, clazz );
  +    }
   
       /**
        * Verfiy that specified components designate classes that implement the
  @@ -85,7 +100,7 @@
        * @param component the ComponentMetaData object for the components
        * @throws VerifyException if an error occurs
        */
  -    protected void verifyType( final ComponentMetaData component,
  +    public void verifyType( final ComponentMetaData component,
                                  final Class clazz )
           throws VerifyException
       {
  @@ -198,5 +213,34 @@
           }
   
           return classes;
  +    }
  +
  +    /**
  +     * Load class object for specified ComponentMetaData.
  +     *
  +     * @param classLoader the ClassLoader to use
  +     * @param component the meta data associate with component
  +     * @return the Class object
  +     * @throws VerifyException if unable to aquire class object
  +     */
  +    private Class getClass( final ClassLoader classLoader,
  +                            final ComponentMetaData component )
  +        throws VerifyException
  +    {
  +        Class clazz = null;
  +        try
  +        {
  +            clazz = classLoader.loadClass( component.getClassname() );
  +        }
  +        catch( final Exception e )
  +        {
  +            final String message =
  +                REZ.getString( "assembly.bad-class.error",
  +                               component.getName(),
  +                               component.getClassname(),
  +                               e.toString() );
  +            throw new VerifyException( message );
  +        }
  +        return clazz;
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>