avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder XMLLegacyCreator.java XMLServiceCreator.java XMLTypeCreator.java
Date Tue, 26 Aug 2003 11:38:51 GMT
mcconnell    2003/08/26 04:38:51

  Modified:    meta/impl/src/java/org/apache/avalon/meta/info/builder
                        XMLLegacyCreator.java XMLServiceCreator.java
                        XMLTypeCreator.java
  Log:
  Bug hunting.
  
  Revision  Changes    Path
  1.11      +34 -29    avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLLegacyCreator.java
  
  Index: XMLLegacyCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLLegacyCreator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XMLLegacyCreator.java	31 Jul 2003 18:54:45 -0000	1.10
  +++ XMLLegacyCreator.java	26 Aug 2003 11:38:51 -0000	1.11
  @@ -119,7 +119,7 @@
        * @throws ConfigurationException if an error occurs
        */
       public Type createType( String classname, Configuration config )
  -        throws ConfigurationException
  +        throws BuildException
       {
           return build( classname, config );
       }
  @@ -131,10 +131,10 @@
        * @param classname The classname of Component
        * @param info the Type configuration
        * @return the created Type
  -     * @throws ConfigurationException if an error occurs
  +     * @throws BuildException if an error occurs
        */
       private Type build( final String classname, final Configuration info )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final String topLevelName = info.getName();
           if( !topLevelName.equals( "blockinfo" ) )
  @@ -143,7 +143,7 @@
                 REZ.getString( "builder.bad-toplevel-block-element.error",
                      classname,
                      topLevelName );
  -            throw new ConfigurationException( message );
  +            throw new BuildException( message );
           }
   
           Configuration configuration = null;
  @@ -190,7 +190,7 @@
        */
       public InfoDescriptor buildInfoDescriptor(
         final String classname, final Configuration info )
  -      throws ConfigurationException
  +      throws BuildException
       {
           final String name = 
             info.getChild( "name" ).getValue( null );
  @@ -232,7 +232,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected DependencyDescriptor[] buildBlockDependencies( final Configuration depSet
)
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Configuration[] deps = depSet.getChildren( "dependency" );
           final ArrayList dependencies = new ArrayList();
  @@ -253,10 +253,10 @@
        *
        * @param servicesSet the services configuration
        * @return the created ServiceDescriptor
  -     * @throws ConfigurationException if an error occurs
  +     * @throws BuildException if an error occurs
        */
       protected ServiceDescriptor[] buildBlockServices( final Configuration servicesSet )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Configuration[] elements = servicesSet.getChildren( "service" );
           final ArrayList services = new ArrayList();
  @@ -276,10 +276,10 @@
        *
        * @param service the service Configuration
        * @return the created ServiceDescriptor
  -     * @throws ConfigurationException if an error occurs
  +     * @throws BuildException if an error occurs
        */
       protected ServiceDescriptor buildBlockService( final Configuration service )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final ReferenceDescriptor designator = buildReferenceDescriptor( service );
           final Properties attributes =
  @@ -296,7 +296,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected ReferenceDescriptor buildReferenceDescriptor( final Configuration service
)
  -        throws ConfigurationException
  +        throws BuildException
       {
           try
           {
  @@ -310,7 +310,7 @@
               final String error =
                 "Error occured while attempting to build reference descriptor from legacy
blockinfo configuration: "
                 + ConfigurationUtil.list( service );
  -            throw new ConfigurationException( error, e );
  +            throw new BuildException( error, e );
           }
       }
   
  @@ -323,25 +323,30 @@
        * @throws ConfigurationException if an error occurs
        */
       protected DependencyDescriptor buildBlockDependency( final Configuration dependency
)
  -        throws ConfigurationException
  +        throws BuildException
       {
  -        Configuration serviceRef = dependency.getChild( "service" );
  -        final ReferenceDescriptor service =
  -            buildReferenceDescriptor( serviceRef );
  -        final boolean optional =
  -            dependency.getAttributeAsBoolean( "optional", false );
  -        final Properties attributes =
  -            buildAttributes( dependency.getChild( "attributes" ) );
  -        String role = dependency.getChild( "role" ).getValue( null );
  -
  -        // default to name of service if role unspecified
  -
  -        if( null == role )
  +        try
           {
  -            role = service.getClassname();
  +            Configuration serviceRef = dependency.getChild( "service" );
  +            final ReferenceDescriptor service =
  +              buildReferenceDescriptor( serviceRef );
  +            final boolean optional =
  +              dependency.getAttributeAsBoolean( "optional", false );
  +            final Properties attributes =
  +              buildAttributes( dependency.getChild( "attributes" ) );
  +            String role = dependency.getChild( "role" ).getValue( null );
  +
  +            // default to name of service if role unspecified
  +            if( null == role ) role = service.getClassname();
  +            return new DependencyDescriptor( role, service, optional, attributes );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error =
  +              "Error occured while attempting to build dependency descriptor from legacy
blockinfo descriptor: "
  +              + ConfigurationUtil.list( dependency );
  +            throw new BuildException( error, e );
           }
  -
  -        return new DependencyDescriptor( role, service, optional, attributes );
       }
   
   }
  
  
  
  1.4       +39 -21    avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLServiceCreator.java
  
  Index: XMLServiceCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLServiceCreator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLServiceCreator.java	26 Aug 2003 10:21:48 -0000	1.3
  +++ XMLServiceCreator.java	26 Aug 2003 11:38:51 -0000	1.4
  @@ -107,10 +107,10 @@
        * @param classname the classname of the service
        * @param info the service defintion
        * @return the created Service
  -     * @throws Exception if an error occurs
  +     * @throws BuildException if an error occurs
        */
       private Service build( final String classname, final Configuration info )
  -        throws Exception
  +        throws BuildException
       {
           final String topLevelName = info.getName();
           if( !topLevelName.equals( "service" ) )
  @@ -119,7 +119,7 @@
                   REZ.getString( "builder.bad-toplevel-service-element.error",
                                  classname,
                                  topLevelName );
  -            throw new ConfigurationException( message );
  +            throw new BuildException( message );
           }
   
           final Properties attributes =
  @@ -140,7 +140,7 @@
        * @throws ConfigurationException if an error occurs
        */
       public Properties buildAttributes( final Configuration config )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Properties attributes = new Properties();
           final Configuration[] children = config.getChildren( "attribute" );
  @@ -157,14 +157,22 @@
                   final String error =
                     "Missing 'key' attribute in 'attribute' element.\n"
                     + ConfigurationUtil.list( child );
  -                throw new ConfigurationException( error, ce );
  +                throw new BuildException( error, ce );
               }
  -            
  -            String value = child.getAttribute( "value", null );
  -            if( value == null )
  +
  +            String value = null;
  +            try
               {
  -                value = child.getValue();
  +                value = child.getAttribute( "value" );
  +            }
  +            catch( ConfigurationException ce )
  +            {
  +                final String error =
  +                  "Missing 'value' attribute in 'attribute' element.\n"
  +                  + ConfigurationUtil.list( child );
  +                throw new BuildException( error, ce );
               }
  +
               attributes.setProperty( key, value );
           }
           return attributes;
  @@ -179,7 +187,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected EntryDescriptor[] buildEntries( final Configuration[] entrySet )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final ArrayList entrys = new ArrayList();
   
  @@ -200,25 +208,35 @@
        * @throws ConfigurationException if an error occurs
        */
       protected EntryDescriptor buildEntry( final Configuration config )
  -        throws ConfigurationException
  +        throws BuildException
       {
  -        final String key = config.getAttribute( "key" );
  -        final String type = config.getAttribute( "type", "java.lang.String" );
  -        final boolean isVolatile = config.getAttributeAsBoolean( "volatile", false );
  -        final boolean optional =
  -            config.getAttributeAsBoolean( "optional", false );
  -        final String alias = config.getAttribute( "alias", null );
  -        return new EntryDescriptor( key, type, optional, isVolatile, alias );
  +        try
  +        {
  +            final String key = config.getAttribute( "key" );
  +            final String type = config.getAttribute( "type", "java.lang.String" );
  +            final boolean isVolatile = config.getAttributeAsBoolean( "volatile", false
);
  +            final boolean optional =
  +              config.getAttributeAsBoolean( "optional", false );
  +            final String alias = config.getAttribute( "alias", null );
  +            return new EntryDescriptor( key, type, optional, isVolatile, alias );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unable to build entry descriptor."
  +              + ConfigurationUtil.list( config );
  +            throw new BuildException( error, e );
  +        }
       }
   
  -
       /**
        * A utility method to parse a Version object from specified string.
        *
        * @param version the version string
        * @return the created Version object
        */
  -    protected Version buildVersion( final String version ) throws BuildException
  +    protected Version buildVersion( final String version ) 
  +      throws BuildException
       {
           try
           {
  
  
  
  1.13      +47 -35    avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLTypeCreator.java
  
  Index: XMLTypeCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/XMLTypeCreator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLTypeCreator.java	7 Aug 2003 17:23:00 -0000	1.12
  +++ XMLTypeCreator.java	26 Aug 2003 11:38:51 -0000	1.13
  @@ -122,7 +122,7 @@
        */
       public Type createType( 
           final String classname, final Configuration info, final Configuration defaults
)
  -        throws ConfigurationException
  +        throws BuildException
       {
           final String topLevelName = info.getName();
            
  @@ -137,7 +137,7 @@
                   REZ.getString( "builder.bad-toplevel-element.error",
                                  classname,
                                  topLevelName );
  -            throw new ConfigurationException( message );
  +            throw new BuildException( message );
           }
   
           Configuration configuration = null;
  @@ -184,7 +184,7 @@
        * @exception Exception if a build error occurs
        */
       protected StageDescriptor[] buildStages( Configuration config ) 
  -      throws ConfigurationException
  +      throws BuildException
       {
           ArrayList list = new ArrayList();
           Configuration[] stages = config.getChildren( "stage" );
  @@ -203,22 +203,23 @@
        * @exception Exception if a build error occurs
        */
       protected StageDescriptor buildPhase( Configuration config ) 
  -      throws ConfigurationException
  +      throws BuildException
       {
  -        String id = null;
  -        if( config.getAttribute( "type", null ) != null ) // legacy
  -        {
  -            id = config.getAttribute( "type" );
  -        }
  -        else if( config.getAttribute( "key", null ) != null ) // legacy
  -        {
  -            id = config.getAttribute( "key" );
  -        }
  -
  -        if( id == null ) id = config.getAttribute( "id" ); // standard
   
           try
           {
  +            String id = null;
  +            if( config.getAttribute( "type", null ) != null ) // legacy
  +            {
  +                id = config.getAttribute( "type" );
  +            }
  +            else if( config.getAttribute( "key", null ) != null ) // legacy
  +            {
  +               id = config.getAttribute( "key" );
  +            }
  +
  +            if( id == null ) id = config.getAttribute( "id" ); // standard
  +
               final Properties attributes =
                 buildAttributes( config.getChild( "attributes" ) );
               return new StageDescriptor( id, attributes );
  @@ -228,7 +229,7 @@
               final String error = 
                 "Unable to construct a stage descriptor from source fragment:"
                 + ConfigurationUtil.list( config );
  -            throw new ConfigurationException( error, e );
  +            throw new BuildException( error, e );
           }
       }
   
  @@ -241,7 +242,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected ReferenceDescriptor buildReferenceDescriptor( final Configuration service
)
  -        throws ConfigurationException
  +        throws BuildException
       {
           return buildReferenceDescriptor( service, null );
       }
  @@ -256,7 +257,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected ReferenceDescriptor buildReferenceDescriptor( final Configuration service,
String classname )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final String type = service.getAttribute("type", classname );
           if( type == null )
  @@ -264,13 +265,13 @@
               final String error = 
                 "Missing 'type' attribute in configuration: " 
                 + ConfigurationUtil.list( service );
  -            throw new ConfigurationException( error );
  +            throw new BuildException( error );
           }
           if( type.indexOf( ":" ) > -1 )
           {
               return createReference( type );
           }
  -        final String versionString = service.getAttribute( "version", "" );
  +        final String versionString = service.getAttribute( "version", "1.0" );
           final Version version = buildVersion( versionString );
           return new ReferenceDescriptor( type, version );
       }
  @@ -284,7 +285,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected CategoryDescriptor[] buildLoggers( final Configuration configuration )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Configuration[] elements = configuration.getChildren( "logger" );
           final ArrayList loggers = new ArrayList();
  @@ -307,7 +308,7 @@
        * @throws ConfigurationException if an error occurs
        */
       private CategoryDescriptor buildLogger( Configuration logger )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Properties attributes = buildAttributes( logger.getChild( "attributes" )
);
           final String name = logger.getAttribute( "name", "" );
  @@ -323,7 +324,7 @@
        * @throws ConfigurationException if an error occurs
        */
       public DependencyDescriptor[] buildDependencies( final Configuration configuration
)
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Configuration[] elements = configuration.getChildren( "dependency" );
           final ArrayList dependencies = new ArrayList();
  @@ -345,10 +346,10 @@
        * @param classname The classname of Component (used for logging purposes)
        * @param dependency the dependency configuration
        * @return the created DependencyDescriptor
  -     * @throws ConfigurationException if an error occurs
  +     * @throws BuildException if an error occurs
        */
       protected DependencyDescriptor buildDependency( final Configuration dependency )
  -        throws ConfigurationException
  +        throws BuildException
       {
           String role = dependency.getAttribute( "role", null ); // legacy
           if( role == null )
  @@ -384,7 +385,7 @@
        * @throws ConfigurationException if an error occurs
        */
       protected ContextDescriptor buildContext( final Configuration context )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final EntryDescriptor[] entrys =
             buildEntries( context.getChildren( "entry" ) );
  @@ -407,7 +408,7 @@
        * @throws ConfigurationException if an error occurs
        */
       public ServiceDescriptor[] buildServices( final Configuration servicesSet )
  -        throws ConfigurationException
  +        throws BuildException
       {
           final Configuration[] elements = servicesSet.getChildren( "service" );
           final ArrayList services = new ArrayList();
  @@ -430,7 +431,7 @@
        * @throws ConfigurationException if an error occurs
        */
       public ServiceDescriptor buildService( final Configuration service )
  -        throws ConfigurationException
  +        throws BuildException
       {
           ReferenceDescriptor reference = buildReferenceDescriptor( service );
           final Properties attributes =
  @@ -449,7 +450,7 @@
        */
       public InfoDescriptor buildInfoDescriptor(
         final String classname, final Configuration info )
  -      throws ConfigurationException
  +      throws BuildException
       {
           final String name = 
             info.getChild( "name" ).getValue( null );
  @@ -496,7 +497,7 @@
        * @exception Exception if a build error occurs
        */
       protected ExtensionDescriptor[] buildExtensions( Configuration config ) 
  -      throws ConfigurationException
  +      throws BuildException
       {
           ArrayList list = new ArrayList();
           Configuration[] extensions = config.getChildren( "extension" );
  @@ -514,11 +515,11 @@
        * @exception Exception if a build error occurs
        */
       protected ExtensionDescriptor buildExtension( Configuration config ) 
  -      throws ConfigurationException
  +      throws BuildException
       {
           if( config.getAttribute( "type", null ) != null ) // legacy
           {
  -            String urn = config.getAttribute( "type" );
  +            String urn = config.getAttribute( "type", null );
               final Properties attributes =
                 buildAttributes( config.getChild( "attributes" ) );
               return new ExtensionDescriptor( urn, attributes );
  @@ -528,7 +529,17 @@
               String id = config.getAttribute( "urn", null ); // legacy
               if( id == null )
               {
  -               id = config.getAttribute( "id" );
  +               try
  +               {
  +                   id = config.getAttribute( "id" );
  +               }
  +               catch( ConfigurationException e )
  +               {
  +                   final String error = 
  +                     "Missing extensions identifier 'id' attribute."
  +                     + ConfigurationUtil.list( config );
  +                   throw new BuildException( error, e );
  +               }
               }
               final Properties attributes =
                 buildAttributes( config.getChild( "attributes" ) );
  @@ -541,7 +552,8 @@
       * @param path the classname
       * @return the reference descriptor
       */
  -    public ReferenceDescriptor createReference( String path )
  +    public ReferenceDescriptor createReference( String path ) 
  +      throws BuildException
       {
           final String type;
           final Version version;
  
  
  

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


Mime
View raw message