//----------------------------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.workflow.server;

import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Set;

public interface WorkflowContext
{
	/**
	 * Return the value of the specified initialization parameter, or
	 * <code>null</code> if this parameter does not exist.
	 *
	 * @param name Name of the initialization parameter to retrieve
	 */
	public String getInitParameter(final String name);

	/**
	 * Return the names of the context's initialization parameters, or an
	 * empty enumeration if the context has no initialization parameters.
	 */
	public Enumeration getInitParameterNames();

	/**
	 * Return the real path for a given virtual path, if possible; otherwise
	 * return <code>null</code>.
	 *
	 * @param path The path to the desired resource
	 */
	public String getRealPath(String path);

	/**
	* Returns a directory-like listing of all the paths to resources within the workflow application whose longest sub-path
	* matches the supplied path argument. Paths indicating subdirectory paths end with a '/'. The returned paths are all 
	* relative to the root of the workflow application and have a leading '/'. For example, for a workflow application 
	* containing<br><br>
	
	* /welcome.html<br>
	* /catalog/index.html<br>
	* /catalog/products.html<br>
	* /catalog/offers/books.html<br>
	* /catalog/offers/music.html<br>
	* /customer/login.jsp<br>
	* /WEB-INF/web.xml<br>
	* /WEB-INF/classes/com.acme.OrderServlet.class,<br><br>
	*
	* getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}<br>
	* getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}.<br>
	   
	
	
	*@param path		the partial path used to match the resources,
	*				which must start with a /
	*@return a Set containing the directory listing, or null if there are no resources in the workflow application whose path
	* begins with the supplied path.
	*/

	public Set getResourcePaths(String path);

	/**
	 * Return the URL to the resource that is mapped to a specified path.
	 * The path must begin with a "/" and is interpreted as relative to the
	 * current context root.
	 *
	 * @param path The path to the desired resource
	 *
	 * @exception MalformedURLException if the path is not given
	 *  in the correct form
	 */
	public URL getResource(String path) throws MalformedURLException;

	/**
	 * Return the requested resource as an <code>InputStream</code>.  The
	 * path must be specified according to the rules described under
	 * <code>getResource</code>.  If no such resource can be identified,
	 * return <code>null</code>.
	 *
	 * @param path The path to the desired resource.
	 */
	public InputStream getResourceAsStream(String path);

	/**
	 * Writes the specified message to a script log file.
	 *
	 * @param message Message to be written
	 */
	public void log(String message);

	/**
	 * Writes the specified message and exception to a script log file.
	 *
	 * @param message Message to be written
	 * @param throwable Exception to be reported
	 */
	public void log(String message, Throwable throwable);

	/**
	 * Return the value of the specified context attribute, if any;
	 * otherwise return <code>null</code>.
	 *
	 * @param name Name of the context attribute to return
	 */
	public Object getAttribute(String name);

	/**
	 * Return an enumeration of the names of the context attributes
	 * associated with this context.
	 */
	public Enumeration getAttributeNames();

	/**
	 *
	 * Binds an object to a given attribute name in this servlet context. If
	 * the name specified is already used for an attribute, this
	 * method will replace the attribute with the new to the new attribute.
	 * <p>If listeners are configured on the <code>ServletContext</code> the  
	 * container notifies them accordingly.
	 * <p>
	 * If a null value is passed, the effect is the same as calling 
	 * <code>removeAttribute()</code>.
	 * 
	 *
	 *
	 * @param name 	a <code>String</code> specifying the name 
	 *			of the attribute
	 *
	 * @param object 	an <code>Object</code> representing the
	 *			attribute to be bound
	 *
	 */

	public void setAttribute(String name, Object object);

	/**
	 * Remove the context attribute with the specified name, if any.
	 *
	 * @param name Name of the context attribute to be removed
	 */
	public void removeAttribute(String name);

	/**
	 * Returns the name of this workflow application corresponding to this WorkflowContext as specified in the deployment
	 * descriptor for this workflow application by the display-name element.
	 *
	 *
	 * @return	    The name of the workflow application or null if no name has been declared in the deployment descriptor.
	 */

	public String getWorkflowContextName();

}
