//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE----------------------------

package org.huihoo.willow;

import java.beans.PropertyChangeListener;

import javax.naming.directory.DirContext;

import org.huihoo.willow.deploy.ApplicationParameter;

/**
 * Used to store the default configuration a Host will use
 * when creating a Context.  A Context configured in server.xml
 * can override these defaults by setting the Context attribute
 * <CODE>override="true"</CODE>.
 */

public interface DefaultContext
{

	// ------------------------------------------------------------- Properties
	/**
	 * Return descriptive information about this Container implementation and
	 * the corresponding version number, in the format
	 * <code>&lt;description&gt;/&lt;version&gt;</code>.
	 */
	public String getInfo();

	/**
	 * Return the reloadable flag for this web application.
	 */
	public boolean getReloadable();

	/**
	 * Set the reloadable flag for this web application.
	 *
	 * @param reloadable The new reloadable flag
	 */
	public void setReloadable(boolean reloadable);


	/**
	 * Set the resources DirContext object with which this Container is
	 * associated.
	 *
	 * @param resources The newly associated DirContext
	 */
	public void setResources(DirContext resources);

	/**
	 * Get the resources DirContext object with which this Container is
	 * associated.
	 *
	 * @param resources The new associated DirContext
	 */
	public DirContext getResources();

	/**
	 * Return the Loader with which this Container is associated.  If there is
	 * no associated Loader return <code>null</code>.
	 */
	public Loader getLoader();

	/**
	 * Set the Loader with which this Context is associated.
	 *
	 * @param loader The newly associated loader
	 */
	public void setLoader(Loader loader);
	

	// ------------------------------------------------------ Public Properties

	/**
	 * Return the name of this DefaultContext
	 */
	public String getName();

	/**
	 * Set the name of the default context.
	 * 
	 * @param name The new name
	 */
	public void setName(String name);

	/**
	 * Return the Container for which this Container is a child, if there is
	 * one.  If there is no defined parent, return <code>null</code>.
	 */
	public Container getParent();

	/**
	 * Set the parent Container to which this Container is being added as a
	 * child.  This Container may refuse to become attached to the specified
	 * Container by throwing an exception.
	 *
	 * @param container Container to which this Container is being added
	 *  as a child
	 *
	 * @exception IllegalArgumentException if this Container refuses to become
	 *  attached to the specified Container
	 */
	public void setParent(Container container);

	// -------------------------------------------------------- Context Methods

	/**
	 * Add a new Listener class name to the set of Listeners
	 * configured for this application.
	 *
	 * @param listener Java class name of a listener class
	 */
	public void addApplicationListener(String listener);

	/**
	 * Add a new application parameter for this application.
	 *
	 * @param parameter The new application parameter
	 */
	public void addApplicationParameter(ApplicationParameter parameter);

	/**
	 * Add a new context initialization parameter, replacing any existing
	 * value for the specified name.
	 *
	 * @param name Name of the new parameter
	 * @param value Value of the new  parameter
	 *
	 * @exception IllegalArgumentException if the name or value is missing,
	 *  or if this context initialization parameter has already been
	 *  registered
	 */
	public void addInitParameter(String name, String value);

	/**
	 * Add a property change listener to this component.
	 *
	 * @param listener The listener to add
	 */
	public void addPropertyChangeListener(PropertyChangeListener listener);


	/**
	 * Return the set of application listener class names configured
	 * for this application.
	 */
	public String[] findApplicationListeners();

	/**
	 * Return the set of application parameters for this application.
	 */
	public ApplicationParameter[] findApplicationParameters();
	
	/**
	 * Return the value for the specified context initialization
	 * parameter name, if any; otherwise return <code>null</code>.
	 *
	 * @param name Name of the parameter to return
	 */
	public String findInitParameter(String name);

	/**
	 * Return the names of all defined context initialization parameters
	 * for this Context.  If no parameters are defined, a zero-length
	 * array is returned.
	 */
	public String[] findInitParameters();


	/**
	 * Remove the specified application listener class from the set of
	 * listeners for this application.
	 *
	 * @param listener Java class name of the listener to be removed
	 */
	public void removeApplicationListener(String listener);

	/**
	 * Remove the application parameter with the specified name from
	 * the set for this application.
	 *
	 * @param name Name of the application parameter to remove
	 */
	public void removeApplicationParameter(String name);
	
	/**
	 * Remove the application parameter with the specified name from
	 * the set for this application.
	 *
	 * @param name Name of the application parameter to remove
	 */
	public void removeInitParameter(String name);
	
	/**
	 * Remove a property change listener from this component.
	 *
	 * @param listener The listener to remove
	 */
	public void removePropertyChangeListener(PropertyChangeListener listener);


	// --------------------------------------------------------- Public Methods

	/**
	 * Import the configuration from the DefaultContext into
	 * current Context.
	 *
	 * @param context current web application context
	 */
	public void importDefaultContext(Context context);

}
