avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier Resources.properties SarVerifier.java
Date Tue, 14 May 2002 10:42:50 GMT
donaldp     02/05/14 03:42:50

  Modified:    src/java/org/apache/avalon/phoenix/tools/verifier
                        Resources.properties SarVerifier.java
  Log:
  Warn users if their Work interfaces implement any lifecycle interfaces.
  
  Revision  Changes    Path
  1.7       +1 -0      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier/Resources.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Resources.properties	9 Nov 2001 21:14:31 -0000	1.6
  +++ Resources.properties	14 May 2002 10:42:50 -0000	1.7
  @@ -23,3 +23,4 @@
   verify-listener-type=Verifying that the specified BlockListeners have valid types.
   
   service-interface-deprecated=Warning: The Block named "{0}" exports a service ({1}) that
extends org.apache.avalon.phoenix.Service. The Service interface is deprecated and should
not be used.
  +verifier.service-isa-lifecycle.error=The Block named "{0}" (implementation class "{1}"),
implements a service "{2}" which extends a Lifecycle interface "{3}". This violates the expected
usage patterns.
  
  
  
  1.12      +60 -6     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier/SarVerifier.java
  
  Index: SarVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/verifier/SarVerifier.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SarVerifier.java	10 May 2002 02:43:04 -0000	1.11
  +++ SarVerifier.java	14 May 2002 10:42:50 -0000	1.12
  @@ -11,7 +11,16 @@
   import java.util.Stack;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Startable;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.LogEnabled;
  +import org.apache.avalon.framework.parameters.Parameterizable;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.phoenix.Block;
   import org.apache.avalon.phoenix.BlockListener;
   import org.apache.avalon.phoenix.Service;
  @@ -49,7 +58,7 @@
    * </ul>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.11 $ $Date: 2002/05/10 02:43:04 $
  + * @version $Revision: 1.12 $ $Date: 2002/05/14 10:42:50 $
    */
   public class SarVerifier
       extends AbstractLogEnabled
  @@ -57,6 +66,19 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( SarVerifier.class );
   
  +    private static final Class[] FRAMEWORK_CLASSES = new Class[]
  +    {
  +        LogEnabled.class,
  +        Contextualizable.class,
  +        Composable.class,
  +        Serviceable.class,
  +        Configurable.class,
  +        Parameterizable.class,
  +        Initializable.class,
  +        Startable.class,
  +        Disposable.class
  +    };
  +
       /**
        * Verify the specified <code>SarMetaData</code> object.
        * The rules used to verify <code>SarMetaData</code> are specified
  @@ -391,11 +413,12 @@
           }
           catch( final Exception e )
           {
  -            final String message = REZ.getString( "bad-listener-class",
  -                                                  listener.getName(),
  -                                                  listener.getClassname(),
  -                                                  e.getMessage() );
  -            throw new VerifyException( message );
  +            final String message =
  +                REZ.getString( "bad-listener-class",
  +                               listener.getName(),
  +                               listener.getClassname(),
  +                               e.getMessage() );
  +            throw new VerifyException( message, e );
           }
   
           if( !BlockListener.class.isAssignableFrom( clazz ) )
  @@ -649,10 +672,41 @@
                   getLogger().warn( message );
                   System.err.println( message );
               }
  +
  +            checkNotFrameworkInterface( name, classname, classes[ i ] );
           }
   
           classes[ services.length ] = Block.class;
           return classes;
  +    }
  +
  +    /**
  +     * Warn the user if any of the service interfaces extend
  +     * a Lifecycle interface (a generally unrecomended approach).
  +     *
  +     * @param name the name of block
  +     * @param classname the classname of block
  +     * @param clazz the service implemented by block
  +     */
  +    private void checkNotFrameworkInterface( final String name,
  +                                             final String classname,
  +                                             final Class clazz )
  +    {
  +        for( int i = 0; i < FRAMEWORK_CLASSES.length; i++ )
  +        {
  +            final Class lifecycle = FRAMEWORK_CLASSES[ i ];
  +            if( lifecycle.isAssignableFrom( clazz ) )
  +            {
  +                final String message =
  +                    REZ.getString( "verifier.service-isa-lifecycle.error",
  +                                   name,
  +                                   classname,
  +                                   clazz.getName(),
  +                                   lifecycle.getName() );
  +                getLogger().warn( message );
  +                System.err.println( message );
  +            }
  +        }
       }
   
       /**
  
  
  

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