leif        2003/05/30 23:52:49

  Modified:    fortress/src/tools/org/apache/avalon/fortress/tools
                        Component.java
  Log:
  Modify the error displayed to the user when a type tag is missing so that it is
  clear and obvious as to what and where the problem is.
  
  Revision  Changes    Path
  1.13      +25 -3     
avalon-excalibur/fortress/src/tools/org/apache/avalon/fortress/tools/Component.java
  
  Index: Component.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-excalibur/fortress/src/tools/org/apache/avalon/fortress/tools/Component.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Component.java    29 May 2003 20:53:24 -0000      1.12
  +++ Component.java    31 May 2003 06:52:49 -0000      1.13
  @@ -121,6 +121,13 @@
           final DocletTag[] tags = javaClass.getTagsByName( TAG_SERVICE );
           for ( int t = 0; t < tags.length; t++ )
           {
  +            if ( tags[t].getNamedParameter( Component.ATTR_TYPE ) == null )
  +            {
  +                throw new BuildException( "The \"type\" tag is missing from the "
  +                    + "\"@" + TAG_SERVICE + "\" meta tag in "
  +                    + javaClass.getName() );
  +            }
  +            
               final String serviceName = resolveClassName( 
m_javaClass.getParentSource(),
                       tags[t].getNamedParameter( Component.ATTR_TYPE ) );
               m_serviceNames.add( serviceName );
  @@ -166,6 +173,13 @@
                       DocletTag[] dependencies = methods[i].getTagsByName( 
TAG_DEPENDENCY );
                       for ( int d = 0; d < dependencies.length; d++ )
                       {
  +                        if ( dependencies[d].getNamedParameter( ATTR_TYPE ) == null 
)
  +                        {
  +                            throw new BuildException( "The \"type\" tag is missing 
from a "
  +                                + "\"@" + TAG_DEPENDENCY + "\" meta tag of the " + 
METH_SERVICE
  +                                + " method in " + fromClass.getName() );
  +                        }
  +                        
                           String type = resolveClassName( fromClass.getParentSource(),
                                   dependencies[d].getNamedParameter( ATTR_TYPE ) );
                           //String optional = 
dependencies[d].getNamedParameter("optional");
  @@ -364,8 +378,16 @@
        */
       protected String resolveClassName( final JavaSource sourceCode, final String 
serviceName )
       {
  -        if ( null == sourceCode ) return null;
  -        if ( null == serviceName ) throw new BuildException( "You must specify the 
service name with the \"type\" parameter" );
  +        if ( null == sourceCode )
  +        {
  +            return null;
  +        }
  +        if ( null == serviceName )
  +        {
  +            // This should be checked by the caller so that a message which better
  +            //  describes the problem in a given context can be given.
  +            throw new IllegalStateException( "The serviceName parameter was null." 
);
  +        }
   
           final String className = stripQuotes( serviceName );
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to