avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier ComponentVerifier.java Resources.properties
Date Tue, 06 Aug 2002 06:24:17 GMT
mcconnell    2002/08/05 23:24:16

  Modified:    assembly/src/etc kernel.xml
               assembly/src/java/org/apache/excalibur/merlin/model/verifier
                        MetaDataVerifier.java Resources.properties
               assembly/src/java/org/apache/excalibur/meta/verifier
                        ComponentVerifier.java Resources.properties
  Log:
  Addition of lifecycle stage verification of a type.
  
  Revision  Changes    Path
  1.25      +4 -0      jakarta-avalon-excalibur/assembly/src/etc/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/kernel.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- kernel.xml	5 Aug 2002 12:39:37 -0000	1.24
  +++ kernel.xml	6 Aug 2002 06:24:16 -0000	1.25
  @@ -123,6 +123,10 @@
   
        <container name="sub" class="org.apache.excalibur.playground.CustomContainer">
   
  +       <categories priority="INFO">
  +         <category priority="WARN"  name="loader" />
  +       </categories>
  +
          <container name="demo">
   
            <categories priority="INFO">
  
  
  
  1.4       +45 -2     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/MetaDataVerifier.java
  
  Index: MetaDataVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/MetaDataVerifier.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MetaDataVerifier.java	29 Jul 2002 06:14:33 -0000	1.3
  +++ MetaDataVerifier.java	6 Aug 2002 06:24:16 -0000	1.4
  @@ -19,6 +19,7 @@
   import org.apache.excalibur.meta.info.ContextDescriptor;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
  +import org.apache.excalibur.meta.info.PhaseDescriptor;
   import org.apache.excalibur.meta.verifier.VerifyException;
   import org.apache.excalibur.meta.verifier.ComponentVerifier;
   
  @@ -111,8 +112,12 @@
               getServiceClasses( name,
                                  component.getType().getServices(),
                                  clazz.getClassLoader() );
  +        final Class[] phases =
  +            getPhaseClasses( name,
  +                               component.getType().getPhases(),
  +                               clazz.getClassLoader() );
   
  -        m_verifier.verifyComponent( name, clazz, interfaces );
  +        m_verifier.verifyType( name, clazz, interfaces, phases );
   
           verifyDependencyPresence( component, clazz );
           verifyContextPresence( component, clazz );
  @@ -208,6 +213,44 @@
               {
                   final String message =
                       REZ.getString( "metadata.bad-service-class.error",
  +                                   name,
  +                                   classname,
  +                                   t.toString() );
  +                throw new VerifyException( message, t );
  +            }
  +        }
  +
  +        return classes;
  +    }
  +
  +    /**
  +     * Retrieve an array of Classes for all the phases that a Component
  +     * is depenent on. 
  +     *
  +     * @param name the name of component
  +     * @param services the services the component offers
  +     * @param classLoader the classLoader
  +     * @return an array of Classes for all the services
  +     * @throws VerifyException if an error occurs
  +     */
  +    protected Class[] getPhaseClasses( final String name,
  +                                         final PhaseDescriptor[] phases,
  +                                         final ClassLoader classLoader )
  +        throws VerifyException
  +    {
  +        final Class[] classes = new Class[ phases.length ];
  +        for( int i = 0; i < phases.length; i++ )
  +        {
  +            final ReferenceDescriptor service = phases[ i ].getReference();
  +            final String classname = service.getClassname();
  +            try
  +            {
  +                classes[ i ] = classLoader.loadClass( classname );
  +            }
  +            catch( final Throwable t )
  +            {
  +                final String message =
  +                    REZ.getString( "metadata.bad-phase-class.error",
                                      name,
                                      classname,
                                      t.toString() );
  
  
  
  1.2       +1 -0      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/Resources.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Resources.properties	12 Jul 2002 12:04:56 -0000	1.1
  +++ Resources.properties	6 Aug 2002 06:24:16 -0000	1.2
  @@ -18,6 +18,7 @@
   
   #MetaData Verifier
   metadata.bad-service-class.error=Unable to load service class "{1}" for Component named
"{0}". (Reason: {2}).
  +metadata.bad-phase-class.error=Unable to load phase class "{1}" for Component named "{0}".
(Reason: {2}).
   metadata.nodeclare-deps.error=Component named "{0}" of type "{1}" is Composable or Serviceable
but does not declare any dependencies.
   metadata.declare-uneeded-deps.error=Component named "{0}" of type "{1}" is not Composable
or Serviceable but declares dependencies.
   metadata.declare-uneeded-entrys.error=Component named "{0}" of type "{1}" is not Contextualizable
but declares Context Entrys.
  
  
  
  1.3       +51 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/ComponentVerifier.java
  
  Index: ComponentVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/ComponentVerifier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ComponentVerifier.java	3 Aug 2002 09:29:06 -0000	1.2
  +++ ComponentVerifier.java	6 Aug 2002 06:24:16 -0000	1.3
  @@ -62,6 +62,25 @@
           Suspendable.class,
           Disposable.class
       };
  +    /**
  +     * Verify that the supplied implementation class
  +     * and service classes are valid for a component.
  +     *
  +     * @param name the name of component
  +     * @param implementation the implementation class of component
  +     * @param services the classes representing services
  +     * @throws VerifyException if error thrown on failure and
  +     *         component fails check
  +     */
  +    public void verifyType( final String name,
  +                                 final Class implementation,
  +                                 final Class[] services, 
  +                                 final Class[] phases )
  +        throws VerifyException
  +    {
  +        verifyComponent( name, implementation, services );
  +        verifyImplementsPhases( name, implementation, phases );
  +    }
   
       /**
        * Verify that the supplied implementation class
  @@ -83,6 +102,37 @@
           verifyServices( name, services );
           verifyImplementsServices( name, implementation, services );
       }
  +
  +    /**
  +     * Verify that the supplied implementation implements the specified
  +     * phase interfaces.
  +     *
  +     * @param name the name of component
  +     * @param implementation the class representing the component
  +     * @param phases the phase interfaces that the implementation must provide
  +     * @throws VerifyException if error thrown on failure and
  +     *         component fails check
  +     */
  +    public void verifyImplementsPhases( final String name,
  +                                          final Class implementation,
  +                                          final Class[] phases )
  +        throws VerifyException
  +    {
  +        for( int i = 0; i < phases.length; i++ )
  +        {
  +            if( !phases[ i ].isAssignableFrom( implementation ) )
  +            {
  +                final String message =
  +                    REZ.getString( "verifier.noimpl-phase.error",
  +                                   name,
  +                                   implementation.getName(),
  +                                   phases[ i ].getName() );
  +                throw new VerifyException( message );
  +            }
  +        }
  +    }
  +
  +
   
       /**
        * Verify that the supplied implementation implements the specified
  
  
  
  1.4       +1 -0      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties	12 Jul 2002 15:11:58 -0000	1.3
  +++ Resources.properties	6 Aug 2002 06:24:16 -0000	1.4
  @@ -11,3 +11,4 @@
   verifier.incompat-serviceable.error=The implementation class {1} for component named "{0}"
is both Serviceable and Composable (incompatible lifecycle interfaces).
   verifier.incompat-config.error=The implementation class {1} for component named "{0}" is
both Configurable and Parameterizable (incompatible lifecycle interfaces).
   verifier.noimpl-service.error=The implementation class {1} for component named "{0}" does
not implement the service interface {2} which it declares it supports.
  +verifier.noimpl-phase.error=The implementation class {1} for component named "{0}" does
not implement the phase interface {2} which it declares it supports.
  
  
  

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


Mime
View raw message