Enclosed below is the interface for a new proposed lifecycle interface.
I
want to test it out with Fortress before committing to anything yet.
However,
it would allow a component to save a working set of data and it's
current
Configuration.  It is meant for components that want to keep track of
certain
information to help them in their decision process.  I don't really have
any
abstraction for data serialization because it is very component
specific.

I think this version is better and more complete than the previous one I
had.
I am open to observations, thoughts, etc.

------------------------------------------------------------------------
---

package org.apache.avalon.framework.persistable;

import org.apache.avalon.framework.configuration.Configuration;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * <code>Persistable</code> is a interface encapsulating the ability for
a
 * Component to expose its current configuration status.  This allows
for a
 * Component that is able to change it's configuration state during
run-time,
 * and save the results to persistant storage.
 *
 * <p>
 * The contract surrounding the <code>Persistable</code> interface is
that
 * it should only be called by the Component's parent.  It may be called
any
 * time the configuration state is to be retrieved from the Component.
If a
 * <code>Persistable</code> component contains non-persistable
components, the
 * <code>Persistable</code> component must store the original
 * <code>Configuration</code> used to configure the non-persistable
component.
 * This way, a system can be restored to its full working state later.
 * </p>
 *
 * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
 */
public interface Persistable extends Configurable
{
    /**
     * Get a copy of the <code>Configuration</code> object to restore
this
     * Component to the state it is currently in.  It can be used to
provide
     * "self-healing" configuration persistence or manage sub components
     * dynamically.  "Self-healing" configuration allows you to handle a
     * deprecated configuration schema and persist with the preferred
format.
     *
     * <p>
     * NOTE: this is called before Disposable.dispose() and directly
before
     *       Persistable.writeData()
     * </p>
     * 
     * @return Configuration object
     */
    Configuration writeConfiguration();
    
    /**
     * Alow a component to load it's working set of data.  The container
     * provides an <code>InputStream</code> to load the information
from.
     * The <code>Persistable</code> component must know how to handle an
     * empty stream, initializing the working set of info if the
component
     * has never been used before.
     * 
     * <p>
     * NOTE: this is called prior to Initializable.initialize(), but
after
     *       everything else.
     * </p>
     */
    void readData(InputStream in);
    
    /**
     * Alow a component to save it's working set of data.  The container
     * provides an <code>OutputStream</code> to save the information to.
     * 
     * <p>
     * NOTE: this is called before Disposable.dispose() and right after
     *       Persistable.writeConfiguration();
     * </p>
     */
    void writeData(OutputStream out);
}


"They that give up essential liberty to obtain a little temporary safety
 deserve neither liberty nor safety."
                - Benjamin Franklin


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

Reply via email to