//----------------------------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.selector;

import java.io.IOException;

import org.huihoo.workflow.server.WorkflowConfig;
import org.huihoo.workflow.server.WorkflowContext;
import org.huihoo.workflow.server.WorkflowWork;
import org.huihoo.workflow.xpdl.WorkflowTransition;

public abstract class GenericSelector implements Selector
{
	private transient WorkflowConfig config;

	public GenericSelector()
	{
	}

	public void destroy()
	{
	}

	public WorkflowConfig getWorkflowConfig()
	{
		return config;
	}

	public WorkflowContext getWorkflowContext()
	{
		return getWorkflowConfig().getWorkflowContext();
	}

	public void init(WorkflowConfig config) throws SelectorException
	{
		this.config = config;
		this.init();
	}

	public void init() throws SelectorException
	{
	}

	public void log(String msg)
	{
		getWorkflowContext().log(getSelectorName() + ": " + msg);
	}

	public void log(String message, Throwable t)
	{
		getWorkflowContext().log(getSelectorName() + ": " + message, t);
	}


	public String getSelectorName()
	{
		return this.getClass().getName();
	}
	
	public abstract boolean evalute(WorkflowWork workflowWork,WorkflowTransition workflowTransition, SelectorContext context) throws SelectorException,IOException;
}
