/*
 * Created on 2004-10-20
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package workflow.client;

import java.util.Hashtable;

import javax.naming.NamingException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import workflow.WorkflowException;
import workflow.client.factory.WorkflowClientFactory;
import workflow.client.listener.Constants;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class WorkflowClientRegistry
{
	public static WorkflowClient retrive(Hashtable env,ServletContext servletContext,HttpSession session)
		throws WorkflowException, NamingException
	{
		WorkflowClientFactory factory =
			(WorkflowClientFactory) servletContext.getAttribute(MatrixClient.INITIAL_CLIENT_FACTORY);
		WorkflowClient client=new InitialWorkflowClient(env, factory);
		if(session!=null)
		{
			session.setAttribute(Constants.WORKFLOW_CLIENT_SESSION,client.getSession());
		}
		return client;
	}
	
	
	public static WorkflowClient retrive(Hashtable env,ServletContext servletContext)
		throws WorkflowException, NamingException
	{
		WorkflowClientFactory factory =
			(WorkflowClientFactory) servletContext.getAttribute(MatrixClient.INITIAL_CLIENT_FACTORY);
		return new InitialWorkflowClient(env, factory);
	}
	
	public static WorkflowClient retrive(Hashtable env)
		throws WorkflowException, NamingException
	{
		return new InitialWorkflowClient(env);
	}
}
