//----------------------------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 org.huihoo.willow.deploy.ApplicationParameter;
import org.huihoo.workflow.server.WorkflowContext;

public interface Context extends Container
{
	// ----------------------------------------------------- Manifest TypeConstants

	/**
	 * The LifecycleEvent type sent when a context is reloaded.
	 */
	public static final String RELOAD_EVENT = "reload";

	// ------------------------------------------------------------- Properties

	/**
	 * Return the application available flag for this Context.
	 */
	public boolean getAvailable();

	/**
	 * Set the application available flag for this Context.
	 *
	 * @param available The new application available flag
	 */
	public void setAvailable(boolean available);

	/**
	 * Return the "correctly configured" flag for this Context.
	 */
	public boolean getConfigured();

	/**
	 * Set the "correctly configured" flag for this Context.  This can be
	 * set to false by startup listeners that detect a fatal configuration
	 * error to avoid the application from being made available.
	 *
	 * @param configured The new correctly configured flag
	 */
	public void setConfigured(boolean configured);

	/**
	 * Return the display name of this Context.
	 */
	public String getDisplayName();

	/**
	 * Set the display name of this Context.
	 *
	 * @param displayName The new display name
	 */
	public void setDisplayName(String displayName);

	/**
	 * Return the document root for this workflow Context.  This can be an absolute
	 * pathname, a relative pathname
	 */
	public String getDocBase();

	/**
	 * Set the document root for this workflow Context.  This can be an absolute
	 * pathname, a relative pathname
	 *
	 * @param appBase The new document root
	 */
	public void setDocBase(String appBase);

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

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

	/**
	 * Return the override flag for this workflow application.
	 */
	public boolean getOverride();

	/**
	 * Set the override flag for this workflow application.
	 *
	 * @param override The new override flag
	 */
	public void setOverride(boolean override);

	/**
	 * Return the privileged flag for this workflow application.
	 */
	public boolean getPrivileged();

	/**
	 * Set the privileged flag for this workflow application.
	 *
	 * @param privileged The new privileged flag
	 */
	public void setPrivileged(boolean privileged);

	/**
	 * Return the value of the auto deploy flag.  If true, it indicates that 
	 * this xpdl should be discovred and automatically 
	 * deployed dynamically.
	 */
	public boolean getAutoDeploy();

	/**
	 * Set the auto deploy flag value for this context.
	 * 
	 * @param autoDeploy The new auto deploy flag
	 */
	public void setAutoDeploy(boolean autoDeploy);

	/**
	 * Return the workflow context for which this Context is a facade.
	 */
	public WorkflowContext getWorkflowContext();

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

	/**
	 * Reload this workflow application, if reloading is supported.
	 *
	 * @exception IllegalStateException if the <code>reloadable</code>
	 *  property is set to <code>false</code>.
	 */
	public void reload();

	/**
	 * Return the Java class name of the Wrapper implementation used
	 * for servlets registered in this Context.
	 */
	public String getWrapperClass();

	/**
	 * Set the Java class name of the Wrapper implementation used
	 * for servlets registered in this Context.
	 *
	 * @param wrapperClass The new wrapper class
	 */
	public void setWrapperClass(String wrapperClass);

	/**
	 * 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 the given URL pattern as a script-property-group.  This maps
	 * resources that match the given pattern so they will be passed
	 * to the Script container.  Though there are other elements in the
	 * property group, we only care about the URL pattern here.  The
	 * Script container will parse the rest.
	 *
	 * @param pattern URL pattern to be mapped 
	 */
	public void addSelectorMapping(String pattern);

	/**
		* 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
		*/
	public void addInitParameter(String name, String value);

	/**
	 * Add the classname of a LifecycleListener to be added to each
	 * Wrapper appended to this Context.
	 *
	 * @param listener Java class name of a LifecycleListener class
	 */
	public void addWrapperLifecycle(String listener);

	/**
	 * Add the classname of a ContainerListener to be added to each
	 * Wrapper appended to this Context.
	 *
	 * @param listener Java class name of a ContainerListener class
	 */
	public void addWrapperListener(String listener);


	public void addWrapper(Wrapper wrapper);

	/**
	 * Factory method to create and return a new Wrapper instance, of
	 * the Java implementation class appropriate for this Context
	 * implementation.  The constructor of the instantiated Wrapper
	 * will have been called, but no properties will have been set.
	 */
	public Wrapper createWrapper();

	/**
		* 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();

	/**
	 * Return the set of LifecycleListener classes that will be added to
	 * newly created Wrappers automatically.
	 */
	public String[] findWrapperLifecycles();

	/**
	 * Return the set of ContainerListener classes that will be added to
	 * newly created Wrappers automatically.
	 */
	public String[] findWrapperListeners();

	/**
	 * Return the Wrapper
	 */
	public Wrapper findWrapper(String name);
	
	/**
		* 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 context initialization parameter with the specified
	 * name, if it exists; otherwise, no action is taken.
	 *
	 * @param name Name of the parameter to remove
	 */
	public void removeInitParameter(String name);

	/**
	 * Remove a class name from the set of LifecycleListener classes that
	 * will be added to newly created Wrappers.
	 *
	 * @param listener Class name of a LifecycleListener class to be removed
	 */
	public void removeWrapperLifecycle(String listener);

	/**
	 * Remove a class name from the set of ContainerListener classes that
	 * will be added to newly created Wrappers.
	 *
	 * @param listener Class name of a ContainerListener class to be removed
	 */
	public void removeWrapperListener(String listener);

	/**
	 * Remove a Wrapper from the set of Wrapper 
	 *
	 * @param name  name of a Wrapper be removed
	 */
	
	public void removeWrapper(String name);
}