You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/07/15 21:15:57 UTC

cvs commit: avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/writer TypeWriter.java

bloritsch    2003/07/15 12:15:57

  Modified:    meta/api/src/java/org/apache/avalon/meta/info Type.java
               meta/impl/src/java/org/apache/avalon/meta/info/builder
                        SerializedTypeCreator.java TypeBuilder.java
                        XMLLegacyCreator.java XMLTypeCreator.java
               meta/impl/src/java/org/apache/avalon/meta/info/writer
                        SerializedTypeWriter.java XMLTypeWriter.java
               meta/spi/src/java/org/apache/avalon/meta/info/builder
                        TypeCreator.java TypeFactory.java
               meta/spi/src/java/org/apache/avalon/meta/info/writer
                        TypeWriter.java
  Added:       meta/api/src/java/org/apache/avalon/meta/info
                        MetaInfoException.java MetaInfoLocator.java
  Log:
  add support for the MetaInfoLocator--marking it as transient
  
  Revision  Changes    Path
  1.10      +28 -33    avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Type.java
  
  Index: Type.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Type.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Type.java	12 Jul 2003 13:34:27 -0000	1.9
  +++ Type.java	15 Jul 2003 19:15:56 -0000	1.10
  @@ -84,6 +84,7 @@
       private final CategoryDescriptor[] m_loggers;
       private final StageDescriptor[] m_stages;
       private final ExtensionDescriptor[] m_extensions;
  +    private final transient MetaInfoLocator m_locator;
   
       /**
        * Creation of a new Type instance using a supplied component descriptor,
  @@ -106,7 +107,8 @@
        * @exception NullPointerException if the descriptor, loggers, context, services,
        *   dependencies, stages, or extensions argument is null
        */
  -    public Type( final InfoDescriptor descriptor,
  +    public Type( final MetaInfoLocator locator,
  +                 final InfoDescriptor descriptor,
                    final CategoryDescriptor[] loggers,
                    final ContextDescriptor context,
                    final ServiceDescriptor[] services,
  @@ -115,7 +117,7 @@
                    final ExtensionDescriptor[] extensions )
               throws NullPointerException
       {
  -        this( descriptor, loggers, context, services, dependencies, stages, extensions, null );
  +        this( locator, descriptor, loggers, context, services, dependencies, stages, extensions, null );
       }
   
       /**
  @@ -139,7 +141,8 @@
        * @exception NullPointerException if the descriptor, loggers, context, services,
        *   dependencies, stages, or extensions argument is null
        */
  -    public Type( final InfoDescriptor descriptor,
  +    public Type( final MetaInfoLocator locator,
  +                 final InfoDescriptor descriptor,
                    final CategoryDescriptor[] loggers,
                    final ContextDescriptor context,
                    final ServiceDescriptor[] services,
  @@ -149,35 +152,16 @@
                    final Configuration defaults )
               throws NullPointerException
       {
  -        if ( null == descriptor )
  -        {
  -            throw new NullPointerException( "descriptor" );
  -        }
  -        if ( null == loggers )
  -        {
  -            throw new NullPointerException( "loggers" );
  -        }
  -        if ( null == context )
  -        {
  -            throw new NullPointerException( "context" );
  -        }
  -        if ( null == services )
  -        {
  -            throw new NullPointerException( "services" );
  -        }
  -        if ( null == dependencies )
  -        {
  -            throw new NullPointerException( "dependencies" );
  -        }
  -        if ( null == stages )
  -        {
  -            throw new NullPointerException( "stages" );
  -        }
  -        if ( null == extensions )
  -        {
  -            throw new NullPointerException( "extensions" );
  -        }
  +        if ( null == locator ) throw new NullPointerException( "locator" );
  +        if ( null == descriptor ) throw new NullPointerException( "descriptor" );
  +        if ( null == loggers ) throw new NullPointerException( "loggers" );
  +        if ( null == context ) throw new NullPointerException( "context" );
  +        if ( null == services ) throw new NullPointerException( "services" );
  +        if ( null == dependencies ) throw new NullPointerException( "dependencies" );
  +        if ( null == stages ) throw new NullPointerException( "stages" );
  +        if ( null == extensions ) throw new NullPointerException( "extensions" );
   
  +        m_locator = locator;
           m_descriptor = descriptor;
           m_loggers = loggers;
           m_context = context;
  @@ -189,6 +173,17 @@
       }
   
       /**
  +     * Return the MetaInfoLocator so that extensions can load in the appropriate information
  +     * that they need as well.
  +     *
  +     * @return the required MetaInfoLocator
  +     */
  +    public MetaInfoLocator getLocator()
  +    {
  +        return m_locator;
  +    }
  +
  +    /**
        * Return the Component descriptor.
        *
        * @return the Component descriptor.
  @@ -420,7 +415,7 @@
           hash ^= m_context.hashCode();
           hash >>>= 13;
           if( m_configuration != null )
  -        { 
  +        {
               hash ^= m_context.hashCode();
               hash >>>= 13;
           }
  
  
  
  1.1                  avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/MetaInfoException.java
  
  Index: MetaInfoException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.avalon.meta.info;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * MetaInfoException signifies an exception dealing with obtaining or
   * reading the meta info.
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class MetaInfoException extends CascadingException
  {
      /**
       * A typical MetaInfoException with a supplied message.
       *
       * @param message  The message for the exception.
       */
      public MetaInfoException( String message )
      {
          super( message );
      }
  
      /**
       * Create a MetaInfoException with a supplied message and the parent exception.
       *
       * @param message    The message for the exception.
       * @param throwable  The parent exception that caused this one.
       */
      public MetaInfoException( String message, Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  1.1                  avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/MetaInfoLocator.java
  
  Index: MetaInfoLocator.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.avalon.meta.info;
  
  import java.io.InputStream;
  import java.io.OutputStream;
  
  /**
   * MetaInfoLocator provides an interface for the readers and writers to
   * get the proper stream for the type of information.  This approach allows
   * MetaInfo readers and writers to handle multiple types of information.
   *
   * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $
   */
  public interface MetaInfoLocator
  {
      /**
       * Get the resource class name that the meta info represents.
       *
       * @return the class name
       */
      String getClassName();
  
      /**
       * Get the required stream based on extension.  The extension is the "type" of
       * meta info, but it also matches the last part of the filename after the last
       * period (aka the extension).
       *
       * @param extension  The extension of the stream (i.e. "info" for "XXX.info")
       * @return the InputStream necessary
       * @throws MetaInfoException if the stream does not exist or there is a problem obtaining it.
       */
      InputStream getInputStream(String extension) throws MetaInfoException;
  
      /**
       * Get the required stream based on extension.  The extension is the "type" of
       * meta info, but it also matches the last part of the filename after the last
       * period (aka the extension).
       *
       * @param extension  The extension of the stream (i.e. "info" for "XXX.info")
       * @return the OutnputStream necessary
       * @throws MetaInfoException if there is a problem obtaining it.
       */
      OutputStream getOutputStream(String extension) throws MetaInfoException;
  }
  
  
  
  1.2       +5 -7      avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/SerializedTypeCreator.java
  
  Index: SerializedTypeCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/SerializedTypeCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SerializedTypeCreator.java	10 Jul 2003 12:10:04 -0000	1.1
  +++ SerializedTypeCreator.java	15 Jul 2003 19:15:56 -0000	1.2
  @@ -51,9 +51,9 @@
   
   package org.apache.avalon.meta.info.builder;
   
  -import java.io.InputStream;
   import java.io.ObjectInputStream;
   import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.MetaInfoLocator;
   
   /**
    * Create {@link Type} from stream made up of
  @@ -68,16 +68,14 @@
   
       /**
        * Create of a type instance from a serialized form.
  -     * @param key not-used
  -     * @param inputStream the input stream
  +     * @param locator   the MetaInfoLocator for the type
        * @return the meta-info instance that describes the component type
        * @exception Exception if an error occurs
        */
  -    public Type createType( final String key,
  -                            final InputStream inputStream )
  +    public Type createType( final MetaInfoLocator locator )
           throws Exception
       {
  -        final ObjectInputStream ois = new ObjectInputStream( inputStream );
  +        final ObjectInputStream ois = new ObjectInputStream( locator.getInputStream(".ztype") );
           return (Type)ois.readObject();
       }
   
  
  
  
  1.3       +50 -17    avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/TypeBuilder.java
  
  Index: TypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/builder/TypeBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeBuilder.java	12 Jul 2003 14:12:52 -0000	1.2
  +++ TypeBuilder.java	15 Jul 2003 19:15:56 -0000	1.3
  @@ -51,14 +51,17 @@
   package org.apache.avalon.meta.info.builder;
   
   import java.io.InputStream;
  +import java.io.OutputStream;
  +
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.MetaInfoLocator;
  +import org.apache.avalon.meta.info.MetaInfoException;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.meta.ConfigurationBuilder;
  -import org.apache.excalibur.configuration.ConfigurationUtil;
   import org.xml.sax.InputSource;
   
   /**
  @@ -109,15 +112,14 @@
       /**
        * Build Type from the XML descriptor format.
        *
  -     * @param classname The classname of Component
  -     * @param classLoader the ClassLoader to load info from
  +     * @param clazz The class of the Component
        * @return the created Type
        * @throws Exception if an error occurs
        */
       private Type buildFromSerDescriptor( final Class clazz )
           throws Exception
       {
  -        Type type = buildFromSerDescriptor( clazz, ".ztype" ); 
  +        Type type = buildFromSerDescriptor( clazz, ".ztype" );
           if( type != null )
           {
               return type;
  @@ -140,20 +142,19 @@
           {
               return null;
           }
  -        return m_serialTypeCreator.createType( classname, stream );
  +        return m_serialTypeCreator.createType( getMetaInfoLocator(clazz) );
       }
   
       /**
        * Build Type from the XML descriptor format.  The implementation
        * will attempt to locate a &lt;classname&gt;.xtype resource.  If
  -     * not found, the implementation will attempt to locate 
  +     * not found, the implementation will attempt to locate
        * a &lt;classname&gt;.info resource.  Once a resource is established
        * the type will be resolved relative to the root element.  Normally
  -     * the root element is a &lttype&gt;, however the implementation 
  -     * also recognises the legacy &lt;blockinfo&gt; schema. 
  -     * 
  -     * @param classname The classname of Component
  -     * @param classLoader the ClassLoader to load info from
  +     * the root element is a &lttype&gt;, however the implementation
  +     * also recognises the legacy &lt;blockinfo&gt; schema.
  +     *
  +     * @param clazz The class of Component
        * @return the created Type
        * @throws Exception if an error occurs
        */
  @@ -201,7 +202,7 @@
           if( defaultsStream != null )
           {
               final InputSource defaultsSource = new InputSource( defaultsStream );
  -            defaults = resolveConfiguration( 
  +            defaults = resolveConfiguration(
                 classLoader, ConfigurationBuilder.build( defaultsSource ) );
           }
           else
  @@ -213,10 +214,42 @@
           // build the type
           //
   
  -        return xmlTypeFactory.createType( classname, xinfo, defaults );
  +        return xmlTypeFactory.createType( getMetaInfoLocator(clazz), xinfo, defaults );
  +    }
  +
  +    private MetaInfoLocator getMetaInfoLocator( Class clazz )
  +    {
  +        return new ClassLoaderMetaInfoLocator(clazz);
  +    }
  +
  +    private final static class ClassLoaderMetaInfoLocator implements MetaInfoLocator
  +    {
  +        private final Class m_class;
  +        private final String m_basePath;
  +
  +        private ClassLoaderMetaInfoLocator( final Class clazz )
  +        {
  +            m_class = clazz;
  +            m_basePath = m_class.getName().replace('.', '/') + ".";
  +        }
  +
  +        public String getClassName()
  +        {
  +            return m_class.getName();
  +        }
  +
  +        public InputStream getInputStream( String extension ) throws MetaInfoException
  +        {
  +            return m_class.getClassLoader().getResourceAsStream( m_basePath + extension );
  +        }
  +
  +        public OutputStream getOutputStream( String extension ) throws MetaInfoException
  +        {
  +            throw new MetaInfoException("This particular locator cannot write");
  +        }
       }
   
  -    private Configuration resolveConfiguration( ClassLoader classloader, Configuration config ) 
  +    private Configuration resolveConfiguration( ClassLoader classloader, Configuration config )
         throws Exception
       {
           if( config == null )
  @@ -242,14 +275,14 @@
                       throw new ConfigurationException( error );
                   }
                   final InputSource source = new InputSource( stream );
  -                return resolveConfiguration( 
  +                return resolveConfiguration(
                     classloader, ConfigurationBuilder.build( source ) );
               }
               else
               {
                   try
                   {
  -                    return resolveConfiguration( 
  +                    return resolveConfiguration(
                         classloader, ConfigurationBuilder.build( src ) );
                   }
                   catch( Throwable e )
  
  
  
  1.4       +24 -36    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLLegacyCreator.java	11 Jul 2003 04:49:33 -0000	1.3
  +++ XMLLegacyCreator.java	15 Jul 2003 19:15:56 -0000	1.4
  @@ -59,16 +59,7 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.meta.ConfigurationBuilder;
  -import org.apache.avalon.meta.info.InfoDescriptor;
  -import org.apache.avalon.meta.info.ContextDescriptor;
  -import org.apache.avalon.meta.info.EntryDescriptor;
  -import org.apache.avalon.meta.info.DependencyDescriptor;
  -import org.apache.avalon.meta.info.ExtensionDescriptor;
  -import org.apache.avalon.meta.info.CategoryDescriptor;
  -import org.apache.avalon.meta.info.ReferenceDescriptor;
  -import org.apache.avalon.meta.info.ServiceDescriptor;
  -import org.apache.avalon.meta.info.StageDescriptor;
  -import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.*;
   import org.apache.excalibur.configuration.ConfigurationUtil;
   import org.xml.sax.InputSource;
   
  @@ -90,50 +81,47 @@
        * Create a {@link Type} object for specified
        * classname, loaded from specified {@link InputStream}.
        *
  -     * @param implementationKey The classname of Component
  -     * @param inputStream the InputStream to load Type from
  +     * @param locator the MetaInfoLocator to load Type from
        * @return the created Type
        * @throws Exception if an error occurs
        */
  -    public Type createType( String implementationKey,
  -                            InputStream inputStream )
  +    public Type createType( MetaInfoLocator locator )
           throws Exception
       {
  -        if( inputStream == null )
  +        if( locator == null )
           {
  -            throw new NullPointerException( "input" );
  +            throw new NullPointerException( "locator" );
           }
  -        final InputSource input = new InputSource( inputStream );
  -        final String classname = implementationKey;
  +        final InputSource input = new InputSource( locator.getInputStream(".xinfo") );
           final Configuration xinfo = ConfigurationBuilder.build( input );
  -        return build( classname, xinfo );
  +        return build( locator, xinfo );
       }
   
       /**
        * Create a {@link Type} object for specified
        * classname and configuration.
        *
  -     * @param classname The classname of the component
  +     * @param locator The MetaInfoLocator of the component
        * @param config the meta info configuration fragment
        * @return the created Type
        * @throws ConfigurationException if an error occurs
        */
  -    public Type createType( String classname, Configuration config )
  +    public Type createType( MetaInfoLocator locator, Configuration config )
           throws ConfigurationException
       {
  -        return build( classname, config );
  +        return build( locator, config );
       }
   
       /**
        * Create a {@link Type} object for specified classname from
        * specified configuration data.
        *
  -     * @param classname The classname of Component
  +     * @param locator The locator of Component
        * @param info the Type configuration
        * @return the created Type
        * @throws ConfigurationException if an error occurs
        */
  -    private Type build( final String classname, final Configuration info )
  +    private Type build( final MetaInfoLocator locator, final Configuration info )
           throws ConfigurationException
       {
           final String topLevelName = info.getName();
  @@ -141,7 +129,7 @@
           {
               final String message =
                 REZ.getString( "builder.bad-toplevel-block-element.error",
  -                   classname,
  +                   locator.getClassName(),
                      topLevelName );
               throw new ConfigurationException( message );
           }
  @@ -150,7 +138,7 @@
   
           configuration = info.getChild( "block" );
           final InfoDescriptor descriptor =
  -            buildInfoDescriptor( classname, configuration );
  +            buildInfoDescriptor( locator.getClassName(), configuration );
   
           configuration = info.getChild( "loggers" );
           final CategoryDescriptor[] loggers = new CategoryDescriptor[0];
  @@ -168,7 +156,7 @@
           configuration = info.getChild( "extensions" );
           final ExtensionDescriptor[] extensions = buildExtensions( configuration );
   
  -        return new Type(
  +        return new Type( locator,
               descriptor, loggers, context, services, dependencies, phases, extensions );
       }
   
  @@ -185,9 +173,9 @@
         final String classname, final Configuration info )
         throws ConfigurationException
       {
  -        final String name = 
  +        final String name =
             info.getChild( "name" ).getValue( null );
  -        final Version version = 
  +        final Version version =
             buildVersion( info.getChild( "version" ).getValue( "1.0" ) );
           final Properties attributes =
               buildAttributes( info.getChild( "attributes" ) );
  @@ -197,15 +185,15 @@
   
       private ContextDescriptor buildPhoenixContext()
       {
  -        ReferenceDescriptor reference = 
  +        ReferenceDescriptor reference =
              createReference( "org.apache.avalon.framework.context.Context" );
  -        EntryDescriptor name = 
  +        EntryDescriptor name =
             new EntryDescriptor( "urn:avalon:name", "java.lang.String", false, false, "block.name" );
  -        EntryDescriptor partition = 
  +        EntryDescriptor partition =
             new EntryDescriptor( "urn:avalon:partition", "java.lang.String", false, false, "app.name" );
  -        EntryDescriptor home = 
  +        EntryDescriptor home =
             new EntryDescriptor( "urn:avalon:home", "java.io.File", false, false, "app.home" );
  -        return new ContextDescriptor( 
  +        return new ContextDescriptor(
             reference, new EntryDescriptor[]{ name, partition, home }, null );
       }
   
  @@ -213,7 +201,7 @@
        * A utility method to build an array of {@link ServiceDescriptor}
        * objects from specified configuraiton.
        *
  -     * @param servicesSet the services configuration
  +     * @param depSet the dependencies configuration
        * @return the created ServiceDescriptor
        * @throws ConfigurationException if an error occurs
        */
  
  
  
  1.4       +38 -50    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLTypeCreator.java	12 Jul 2003 14:12:52 -0000	1.3
  +++ XMLTypeCreator.java	15 Jul 2003 19:15:56 -0000	1.4
  @@ -60,16 +60,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.meta.ConfigurationBuilder;
  -import org.apache.avalon.meta.info.InfoDescriptor;
  -import org.apache.avalon.meta.info.ContextDescriptor;
  -import org.apache.avalon.meta.info.DependencyDescriptor;
  -import org.apache.avalon.meta.info.EntryDescriptor;
  -import org.apache.avalon.meta.info.ExtensionDescriptor;
  -import org.apache.avalon.meta.info.CategoryDescriptor;
  -import org.apache.avalon.meta.info.ReferenceDescriptor;
  -import org.apache.avalon.meta.info.ServiceDescriptor;
  -import org.apache.avalon.meta.info.StageDescriptor;
  -import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.*;
   import org.apache.excalibur.configuration.ConfigurationUtil;
   import org.xml.sax.InputSource;
   
  @@ -91,51 +82,49 @@
        * Create a {@link Type} object for specified
        * classname, loaded from specified {@link InputStream}.
        *
  -     * @param classname The classname of Component
  -     * @param inputStream the InputStream to load Type from
  +     * @param locator the MetaInfoLocator to load Type from
        * @return the created Type
        * @throws Exception if an error occurs
        */
  -    public Type createType( String classname,
  -                            InputStream inputStream )
  +    public Type createType( MetaInfoLocator locator )
           throws Exception
       {
  -        if( inputStream == null )
  +        if( locator == null )
           {
  -            throw new NullPointerException( "input" );
  +            throw new NullPointerException( "locator" );
           }
   
  -        final InputSource input = new InputSource( inputStream );
  +        final InputSource input = new InputSource( locator.getInputStream(".xtype") );
           final Configuration xinfo = ConfigurationBuilder.build( input );
  -        return createType( classname, xinfo, (Configuration) null );
  +        return createType( locator, xinfo, (Configuration) null );
       }
   
       /**
        * Create an {@link Type} object for a specified classname from
        * specified configuration data.
        *
  -     * @param classname The classname of Component
  +     * @param locator The classname of Component
        * @param info the Type configuration
        * @param defaults the default configuration
        * @return the created Type
        * @throws Exception if an error occurs
        */
  -    public Type createType( 
  -        final String classname, final Configuration info, final Configuration defaults )
  -        throws ConfigurationException
  +    public Type createType(
  +        final MetaInfoLocator locator, final Configuration info, final Configuration defaults )
  +        throws Exception
       {
           final String topLevelName = info.getName();
  -         
  +
           if( topLevelName.equals( "blockinfo" ) )
           {
  -            return new XMLLegacyCreator().createType( classname, info );
  +            return new XMLLegacyCreator().createType( locator, info );
           }
   
           if( !topLevelName.equals( "type" ) )
           {
               final String message =
                   REZ.getString( "builder.bad-toplevel-element.error",
  -                               classname,
  +                        locator.getClassName(),
                                  topLevelName );
               throw new ConfigurationException( message );
           }
  @@ -151,7 +140,7 @@
           configuration = info.getChild( "info", false );
   
           final InfoDescriptor descriptor =
  -            buildInfoDescriptor( classname, configuration );
  +            buildInfoDescriptor( locator.getClassName(), configuration );
   
           configuration = info.getChild( "loggers" );
           final CategoryDescriptor[] loggers = buildLoggers( configuration );
  @@ -163,7 +152,7 @@
           final ServiceDescriptor[] services = buildServices( configuration );
   
           configuration = info.getChild( "dependencies" );
  -        final DependencyDescriptor[] dependencies = 
  +        final DependencyDescriptor[] dependencies =
              buildDependencies( configuration );
   
           configuration = info.getChild( "stages" );
  @@ -172,8 +161,8 @@
           configuration = info.getChild( "extensions" );
           final ExtensionDescriptor[] extensions = buildExtensions( configuration );
   
  -        return new Type(
  -          descriptor, loggers, context, services, dependencies, phases, 
  +        return new Type( locator,
  +          descriptor, loggers, context, services, dependencies, phases,
             extensions, defaults );
       }
   
  @@ -181,9 +170,9 @@
        * Utility function to create a set of phase descriptor from a configuration.
        * @param config a configuration containing 0..n phase elements
        * @return an array of phase descriptors
  -     * @exception Exception if a build error occurs
  +     * @exception ConfigurationException if a build error occurs
        */
  -    protected StageDescriptor[] buildPhases( Configuration config ) 
  +    protected StageDescriptor[] buildPhases( Configuration config )
         throws ConfigurationException
       {
           ArrayList list = new ArrayList();
  @@ -200,9 +189,9 @@
        * Utility function to create a set of phase descriptor from a configuration.
        * @param config a configuration containing 0..n phase elements
        * @return an array of phase descriptors
  -     * @exception Exception if a build error occurs
  +     * @exception ConfigurationException if a build error occurs
        */
  -    protected StageDescriptor buildPhase( Configuration config ) 
  +    protected StageDescriptor buildPhase( Configuration config )
         throws ConfigurationException
       {
           ReferenceDescriptor reference = buildReferenceDescriptor( config );
  @@ -241,8 +230,8 @@
           final String type = service.getAttribute("type", classname );
           if( type == null )
           {
  -            final String error = 
  -              "Missing 'type' attribute in configuration: " 
  +            final String error =
  +              "Missing 'type' attribute in configuration: "
                 + ConfigurationUtil.list( service );
               throw new ConfigurationException( error );
           }
  @@ -322,7 +311,6 @@
        * A utility method to build a {@link DependencyDescriptor}
        * object from specified configuraiton.
        *
  -     * @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
  @@ -335,9 +323,9 @@
           {
               role = dependency.getAttribute( "key", null );
           }
  -        ReferenceDescriptor reference = 
  +        ReferenceDescriptor reference =
             buildReferenceDescriptor( dependency );
  -        
  +
           final boolean optional =
              dependency.getAttributeAsBoolean( "optional", false );
           final Properties attributes =
  @@ -372,7 +360,7 @@
           final Properties attributes =
             buildAttributes( context.getChild( "attributes" ) );
   
  -        ReferenceDescriptor reference = 
  +        ReferenceDescriptor reference =
             buildReferenceDescriptor( context, Context.class.getName() );
   
           return new ContextDescriptor( reference, entrys, attributes );
  @@ -432,20 +420,20 @@
         final String classname, final Configuration info )
         throws ConfigurationException
       {
  -        final String name = 
  +        final String name =
             info.getChild( "name" ).getValue( null );
  -        final Version version = 
  +        final Version version =
             buildVersion( info.getChild( "version" ).getValue( "1.0" ) );
           final Properties attributes =
               buildAttributes( info.getChild( "attributes" ) );
  -        final String lifestyle = 
  +        final String lifestyle =
             buildLifestyle( info, attributes );
           return new InfoDescriptor( name, classname, version, lifestyle, attributes );
       }
   
      /**
  -    * Handle the resolution of the component lifestyle.  Normally this is 
  -    * resolved by retrieving the &lt;lifestyle&gt; element value, however, for 
  +    * Handle the resolution of the component lifestyle.  Normally this is
  +    * resolved by retrieving the &lt;lifestyle&gt; element value, however, for
       * backward compatability - if the lifecycle element is not present, we will
       * attempt to resolve the lifestyle using the attribute value relative to the
       * key urn:avalon:lifestyle.
  @@ -471,9 +459,9 @@
        * Utility function to create a set of phase descriptor from a configuration.
        * @param config a configuration containing 0..n phase elements
        * @return an array of phase descriptors
  -     * @exception Exception if a build error occurs
  +     * @exception ConfigurationException if a build error occurs
        */
  -    protected ExtensionDescriptor[] buildExtensions( Configuration config ) 
  +    protected ExtensionDescriptor[] buildExtensions( Configuration config )
         throws ConfigurationException
       {
           ArrayList list = new ArrayList();
  @@ -489,12 +477,12 @@
        * Utility function to create an extension descriptor from a configuration.
        * @param config a configuration containing the extension definition
        * @return the extension descriptor
  -     * @exception Exception if a build error occurs
  +     * @exception ConfigurationException if a build error occurs
        */
  -    protected ExtensionDescriptor buildExtension( Configuration config ) 
  +    protected ExtensionDescriptor buildExtension( Configuration config )
         throws ConfigurationException
       {
  -        ReferenceDescriptor reference = 
  +        ReferenceDescriptor reference =
             buildReferenceDescriptor( config );
           final Properties attributes =
             buildAttributes( config.getChild( "attributes" ) );
  
  
  
  1.2       +3 -4      avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/writer/SerializedTypeWriter.java
  
  Index: SerializedTypeWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/writer/SerializedTypeWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SerializedTypeWriter.java	10 Jul 2003 12:10:17 -0000	1.1
  +++ SerializedTypeWriter.java	15 Jul 2003 19:15:57 -0000	1.2
  @@ -67,14 +67,13 @@
        * Write a {@link Type} to a stream
        *
        * @param type the meta info Type instance
  -     * @param stream the destination stream
        * @throws Exception if an error occurs while writting to the stream
        */
  -    public void writeType( final Type type, final OutputStream stream )
  +    public void writeType( final Type type )
           throws Exception
       {
           final ObjectOutputStream output =
  -          new ObjectOutputStream( stream );
  +          new ObjectOutputStream( type.getLocator().getOutputStream("ztype") );
           output.writeObject( type );
           output.flush();
       }
  
  
  
  1.6       +3 -5      avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/writer/XMLTypeWriter.java
  
  Index: XMLTypeWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/impl/src/java/org/apache/avalon/meta/info/writer/XMLTypeWriter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLTypeWriter.java	15 Jul 2003 19:05:44 -0000	1.5
  +++ XMLTypeWriter.java	15 Jul 2003 19:15:57 -0000	1.6
  @@ -82,14 +82,12 @@
        * Write out type representation to xml.
        *
        * @param type the type object
  -     * @param outputStream the stream to write to
        * @throws Exception if unable to write xml
        */
  -    public void writeType( final Type type,
  -                                    final OutputStream outputStream )
  +    public void writeType( final Type type )
           throws Exception
       {
  -        final Writer writer = new OutputStreamWriter( outputStream );
  +        final Writer writer = new OutputStreamWriter( type.getLocator().getOutputStream("xtype") );
           writeHeader( writer );
           writeDoctype( writer, "type" );
           writer.write( "\n\n<type>" );
  
  
  
  1.2       +3 -5      avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/builder/TypeCreator.java
  
  Index: TypeCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/builder/TypeCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeCreator.java	10 Jul 2003 20:38:48 -0000	1.1
  +++ TypeCreator.java	15 Jul 2003 19:15:57 -0000	1.2
  @@ -50,8 +50,8 @@
   
   package org.apache.avalon.meta.info.builder;
   
  -import java.io.InputStream;
   import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.MetaInfoLocator;
   
   /**
    * Simple interface used to create {@link Type}
  @@ -67,12 +67,10 @@
       /**
        * Create a {@link Type} from stream
        *
  -     * @param key the name of component type that we are looking up
        * @param input the input stream that the resource is loaded from
        * @return the newly created {@link Type}
        * @exception Exception if an error occurs
        */
  -    Type createType( String key, InputStream input )
  +    Type createType( MetaInfoLocator input )
           throws Exception;
  -
   }
  
  
  
  1.2       +5 -4      avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/builder/TypeFactory.java
  
  Index: TypeFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/builder/TypeFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeFactory.java	10 Jul 2003 20:38:48 -0000	1.1
  +++ TypeFactory.java	15 Jul 2003 19:15:57 -0000	1.2
  @@ -51,6 +51,7 @@
   package org.apache.avalon.meta.info.builder;
   
   import org.apache.avalon.meta.info.Type;
  +import org.apache.avalon.meta.info.MetaInfoLocator;
   import org.apache.avalon.framework.configuration.Configuration;
   
   /**
  @@ -66,15 +67,15 @@
   {
   
       /**
  -     * Create a {@link Type} using a supplied type configuration and default configuration 
  +     * Create a {@link Type} using a supplied type configuration and default configuration
        *
  -     * @param path the class resource name of component type that we are looking up
  +     * @param locator the class resource name of component type that we are looking up
        * @param xinfo the configuration fragment for the type
        * @param defaults the configuration fragment for the default configuration
        * @return the newly created {@link Type}
        * @exception Exception if an error occurs
        */
  -    Type createType( String path, Configuration xinfo, Configuration defaults )
  +    Type createType( MetaInfoLocator locator, Configuration xinfo, Configuration defaults )
           throws Exception;
   
   }
  
  
  
  1.2       +2 -5      avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/writer/TypeWriter.java
  
  Index: TypeWriter.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/writer/TypeWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeWriter.java	10 Jul 2003 20:38:48 -0000	1.1
  +++ TypeWriter.java	15 Jul 2003 19:15:57 -0000	1.2
  @@ -49,8 +49,6 @@
   
   package org.apache.avalon.meta.info.writer;
   
  -import java.io.OutputStream;
  -
   import org.apache.avalon.meta.info.Type;
   
   /**
  @@ -66,9 +64,8 @@
        * Write a {@link Type} to a stream
        *
        * @param type the meta info Type instance
  -     * @param stream the destination stream
        * @throws Exception if an error occurs while writting to the stream
        */
  -    void writeType( Type type, OutputStream stream )
  +    void writeType( Type type )
           throws Exception;
   }
  
  
  

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