donaldp 2002/09/13 22:58:39
Modified: containerkit/src/java/org/apache/excalibur/containerkit/verifier
MetaDataVerifier.java
Log:
Decouple verifier from MetaData
Revision Changes Path
1.19 +47 -39
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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- MetaDataVerifier.java 13 Sep 2002 15:43:17 -0000 1.18
+++ MetaDataVerifier.java 14 Sep 2002 05:58:39 -0000 1.19
@@ -19,7 +19,6 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.tools.verifier.VerifyException;
import org.apache.avalon.framework.tools.verifier.ComponentVerifier;
-import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
/**
* This Class verifies that an implementation is valid wrt the
@@ -80,69 +79,74 @@
/**
* Verfiy that specified components designate classes that implement the
- * advertised interfaces. And confrorm to expectations of [EMAIL
PROTECTED] ComponentMetaData}.
+ * advertised interfaces. And confrorm to expectations of [EMAIL
PROTECTED] ComponentInfo}.
*
- * @param metaData the [EMAIL PROTECTED] ComponentMetaData} object for
the components
+ * @param name the name of component
+ * @param implementationKey the implementationKey of component
* @param classLoader the ClassLoader to load component from
* @throws VerifyException if an error occurs
*/
- public void verifyType( final ComponentMetaData metaData,
+ public void verifyType( final String name,
+ final String implementationKey,
final ComponentInfo info,
final ClassLoader classLoader )
throws VerifyException
{
- final Class clazz = getClass( classLoader, metaData );
- verifyType( metaData, info, clazz );
+ final Class clazz = getClass( classLoader, name, implementationKey );
+ verifyType( name, implementationKey, info, clazz );
}
/**
* Verfiy that specified components designate classes that implement the
- * advertised interfaces. And confrorm to expectations of [EMAIL
PROTECTED] ComponentMetaData}.
+ * advertised interfaces. And confrorm to expectations of [EMAIL
PROTECTED] ComponentInfo}.
*
- * @param component the [EMAIL PROTECTED] ComponentMetaData} object for
the components
+ * @param name the name of component
+ * @param implementationKey the implementationKey of component
* @throws VerifyException if an error occurs
*/
- public void verifyType( final ComponentMetaData component,
+ public void verifyType( final String name,
+ final String implementationKey,
final ComponentInfo info,
- final Class clazz )
+ final Class implementation )
throws VerifyException
{
- final String name = component.getName();
final Class[] interfaces =
getServiceClasses( name,
info.getServices(),
- clazz.getClassLoader() );
+ implementation.getClassLoader() );
- m_verifier.verifyComponent( name, clazz, interfaces );
+ m_verifier.verifyComponent( name, implementation, interfaces );
- verifyDependencyPresence( component, clazz );
- verifyContextPresence( component, info, clazz );
+ verifyDependencyPresence( name, implementationKey, info,
implementation );
+ verifyContextPresence( name, implementationKey, info, implementation
);
}
/**
* Verify that the if the component is not Contextualizable that it
* does not declare Context Entrys.
*
- * @param metaData the [EMAIL PROTECTED] ComponentMetaData}
- * @param clazz the class implementing component
+ * @param name the name of component
+ * @param implementationKey the implementationKey of component
+ * @param implementation the class implementing component
* @throws VerifyException if fails verification check
*/
- protected void verifyContextPresence( final ComponentMetaData metaData,
+ protected void verifyContextPresence( final String name,
+ final String implementationKey,
final ComponentInfo info,
- final Class clazz )
+ final Class implementation )
throws VerifyException
{
final ContextDescriptor context = info.getContextDescriptor();
final int count = context.getEntrys().length;
- if( !Contextualizable.class.isAssignableFrom( clazz ) )
+ if( !Contextualizable.class.isAssignableFrom( implementation ) )
{
if( 0 != count )
{
final String message =
REZ.getString( "metadata.declare-uneeded-entrys.error",
- metaData.getName(),
- metaData.getImplementationKey() );
+ name,
+ implementationKey );
throw new VerifyException( message );
}
}
@@ -155,26 +159,29 @@
* <p>or</p>
* <p>Is Composable/Serviceable and does declare dependencys</p>
*
- * @param metaData the [EMAIL PROTECTED] ComponentMetaData}
- * @param clazz the class implementing component
+ * @param name the name of component
+ * @param implementationKey the implementationKey of component
+ * @param implementation the class implementing component
* @throws VerifyException if fails verification check
*/
- protected void verifyDependencyPresence( final ComponentMetaData
metaData,
- final Class clazz )
+ protected void verifyDependencyPresence( final String name,
+ final String implementationKey,
+ final ComponentInfo info,
+ final Class implementation )
throws VerifyException
{
- final int count = metaData.getDependencies().length;
+ final int count = info.getDependencies().length;
final boolean aquiresServices =
- Composable.class.isAssignableFrom( clazz ) ||
- Serviceable.class.isAssignableFrom( clazz );
+ Composable.class.isAssignableFrom( implementation ) ||
+ Serviceable.class.isAssignableFrom( implementation );
if( !aquiresServices )
{
if( 0 != count )
{
final String message =
REZ.getString( "metadata.declare-uneeded-deps.error",
- metaData.getName(),
- metaData.getImplementationKey() );
+ name,
+ implementationKey );
throw new VerifyException( message );
}
}
@@ -219,29 +226,30 @@
}
/**
- * Load class object for specified [EMAIL PROTECTED] ComponentMetaData}.
+ * Load class object for specified component.
*
* @param classLoader the ClassLoader to use
- * @param component the meta data associate with component
+ * @param name the name of component
+ * @param implementationKey the implementationKey of component
* @return the Class object
* @throws VerifyException if unable to aquire class object
*/
private Class getClass( final ClassLoader classLoader,
- final ComponentMetaData component )
+ final String name,
+ final String implementationKey )
throws VerifyException
{
- final String classname = component.getImplementationKey();
Class clazz = null;
try
{
- clazz = classLoader.loadClass( classname );
+ clazz = classLoader.loadClass( implementationKey );
}
catch( final Exception e )
{
final String message =
REZ.getString( "assembly.bad-class.error",
- component.getName(),
- classname,
+ name,
+ implementationKey,
e.toString() );
throw new VerifyException( message );
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>