//----------------------------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.net.URL;

import org.huihoo.workflow.WorkflowException;
import org.huihoo.workflow.server.WorkflowXPDL;


public interface ContextDeployer
{
	// ----------------------------------------------------- Manifest TypeConstants

	/**
	 * The ContainerEvent event type sent when a new application is
	 * being installed by <code>install()</code>, before it has been
	 * started.
	 */
	public static final String PRE_INSTALL_EVENT = "pre-install";

	/**
	 * The ContainerEvent event type sent when a new application is
	 * installed by <code>install()</code>, after it has been started.
	 */
	public static final String INSTALL_EVENT = "install";

	/**
	 * The ContainerEvent event type sent when an existing application is
	 * removed by <code>remove()</code>.
	 */
	public static final String REMOVE_EVENT = "remove";

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

	/**
	 * Return the name of the Container with which this ContextDeployer is associated.
	 */
	public String getName();

	/**
	 * Install a new XPDL WORKFLOW , whose WORKFLOW XPDL archive is at the
	 * specified URL, into this container with the specified context path.
	 *
	 * @param procName The WORKFLOW XPDL name to which this application should
	 *  be installed (must be unique)
	 * @param war A URL of  type "file:" that points to an unpacked directory 
	 *  structure containing  the XPDL WORKFLOW to be installed
	 *
	 * @exception IllegalArgumentException if the specified context path
	 *  is malformed (it must be "" or start with a slash)
	 * @exception IllegalStateException if the specified XPDL archive
	 *  is already attached to an existing XPDL WORKFLOW 
	 * @exception IOException if an input/output error was encountered
	 *  during installation
	 */
	public void install(String procName,URL procURL) throws WorkflowException;
	
	/**
	 * Remove an existing XPDL WORKFLOW, attached to the specified WORKFLOW XPDL 
	 * archive.  
	 *
	 * @param procName The WORKFLOW XPDL archive of the application to be removed
	 *
	 * @exception IllegalArgumentException if the specified WORKFLOW XPDL archive
	 *  is malformed (it must be "" or start with a slash)
	 * @exception IllegalArgumentException if the specified WORKFLOW XPDL archive does
	 *  not identify a currently installed XPDL WORKFLOW
	 * @exception IOException if an input/output error occurs during
	 *  removal
	 */ 
	public void remove(String procName) throws WorkflowException;

	/**
	 * Return the Workflow for the deployed workflow that is associated
	 * with the specified WORKFLOW XPDL archive(if any); otherwise return
	 * <code>null</code>.
	 *
	 * @param procName The WORKFLOW XPDL archive of the requested workflow application
	 */	
	public WorkflowXPDL findWorkflowXPDL(String procName);
	
	
	/**
	 * Return the WORKFLOW XPDL archives of all deployed XPDL WORKFLOWs in this
	 * Container.  If there are no deployed XPDL WORKFLOWs, a zero-length
	 * array is returned.
	 */
	public String[] findWorkflowXPDLs();

}
