avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject [VOTE] MutableConfiguration interface
Date Thu, 22 Jan 2004 19:08:35 GMT
All,

I've done some experimentation with persisting a component's 
configuration. First, I started like this:

    interface Persistable {
        Configuration getConfiguration ();
    }

but then I came upon the little snag that the container may want to 
add more configuration information to the Configuration before it is 
stored. So I did this:

    interface Persistable {
        DefaultConfiguration getConfiguration ();
    }

Then this:

    interface Persistable {
        void getConfiguration (DefaultConfiguration config);
    }

which allowed the component to fill in its attributes etc.

But that's quite ugly.

So I'd like to have an interface - MutableConfiguration that will extend

Configuration, but add the mutators from DefaultConfiguration -
setAttribute, 
addChild, etc. DefaultConfiguration would then implement this interface.

I therefore propose the addition of the following interface to 
org.apache.avalon.framework.configuration, and that the
DefaultConfiguration
class shall implement it:

/**
 * A read/write extension of the Configuration interface.
 *
 * @author <a href="mailto:dev@avalon.apache.org">Avalon Development
Team</a>
 * @version CVS $Revision: 1.27 $ $Date: 2003/02/11 15:58:38 $
 */
public interface MutableConfiguration extends Configuration
{
    /**
     * Set the value of this <code>Configuration</code> object to the
specified string.
     *
     * @param value a <code>String</code> value
     */
    public void setValue( final String value );
    
    /**
     * Set the value of this <code>Configuration</code> object to the
specified int.
     *
     * @param value a <code>int</code> value
     */
    public void setValue( final int value );
    
    /**
     * Set the value of this <code>Configuration</code> object to the
specified long.
     *
     * @param value a <code>long</code> value
     */
    public void setValue( final long value );
    
    /**
     * Set the value of this <code>Configuration</code> object to the
specified boolean.
     *
     * @param value a <code>boolean</code> value
     */
    public void setValue( final boolean value );
    
    /**
     * Set the value of this <code>Configuration</code> object to the
specified float.
     *
     * @param value a <code>float</code> value
     */
    public void setValue( final float value );
    
    /**
     * Set the value of the specified attribute to the specified string.
     *
     * @param name name of the attribute to set
     * @param value a <code>String</code> value
     */
    public void setAttribute( final String name, final String value );
    
    /**
     * Set the value of the specified attribute to the specified int.
     *
     * @param name name of the attribute to set
     * @param value an <code>int</code> value
     */
    public void setAttribute( final String name, final int value );
    
    /**
     * Set the value of the specified attribute to the specified long.
     *
     * @param name name of the attribute to set
     * @param value an <code>long</code> value
     */
    public void setAttribute( final String name, final long value );
    
    /**
     * Set the value of the specified attribute to the specified
boolean.
     *
     * @param name name of the attribute to set
     * @param value an <code>boolean</code> value
     */
    public void setAttribute( final String name, final boolean value );
    
    /**
     * Set the value of the specified attribute to the specified float.
     *
     * @param name name of the attribute to set
     * @param value an <code>float</code> value
     */
    public void setAttribute( final String name, final float value );
    
    /**
     * Add an attribute to this configuration element, returning its old
     * value or <b>null</b>.
     *
     * @param name a <code>String</code> value
     * @param value a <code>String</code> value
     * @return a <code>String</code> value
     * @deprecated Use setAttribute() instead
     */
    public String addAttribute( final String name, String value );

    /**
     * Add a child <code>Configuration</code> to this configuration
element.
     * @param configuration a <code>Configuration</code> value
     */
    public void addChild( final Configuration configuration );
    
    /**
     * Add all the attributes, children and value
     * from specified configuration element to current
     * configuration element.
     *
     * @param other the {@link Configuration} element
     */
    public void addAll( final Configuration other );

    /**
     * Add all attributes from specified configuration
     * element to current configuration element.
     *
     * @param other the {@link Configuration} element
     */
    public void addAllAttributes( final Configuration other );
    
    /**
     * Add all child <code>Configuration</code> objects from specified
     * configuration element to current configuration element.
     *
     * @param other the other {@link Configuration} value
     */
    public void addAllChildren( final Configuration other );
    
    /**
     * Remove a child <code>Configuration</code> to this configuration
element.
     * @param configuration a <code>Configuration</code> value
     */
    public void removeChild( final Configuration configuration );
}


+1 from me

/LS


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


Mime
View raw message