/*
 * Created on 2004-6-13
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package workflow.script.core;

import workflow.WorkflowException;
import workflow.script.ParameterContext;
import workflow.script.ScriptException;
import workflow.wfmc.rtm.WorkflowWork;
import workflow.wfmc.xpdl.WorkflowTransition;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public abstract class ScriptBase implements Script, java.io.Serializable
{
	private final transient static  String SCRIPT_CLASS_NAME=ScriptBase.class.getName();
	
	private transient ScriptContext scriptContext;
	
	private transient WorkflowTransition workflowTransition;
	

	protected ScriptBase()
	{
	}
	
	public void init(ScriptContext scriptContext, WorkflowTransition workflowTransition)
	throws ScriptException
	{
		this.scriptContext=scriptContext;
		this.workflowTransition=workflowTransition;
		
		_script_init();
	}		
	
	public void destroy()
	{
		_script_destroy();
	}
	
	public ScriptContext getScriptContext()
	{
		return this.scriptContext;
	}


	public WorkflowTransition getWorkflowTransition()
	{
		return this.workflowTransition;
	}

	public String getScriptClassName()
	{
		return SCRIPT_CLASS_NAME;
	}
	
	public void log(String msg)
	{
		getScriptContext().log(getScriptClassName() + ": " + msg);
	}

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

	
	public  boolean evalute(WorkflowWork workflowWork,ParameterContext paramContext) 
	throws ScriptException,WorkflowException
	{
		return _script_evalute(workflowWork,paramContext);
	}
	
//-----------------------------------------------------------------------------------
//extension blocks
//-----------------------------------------------------------------------------------	

	public void _script_init() {
	}
	
	public  void _script_destroy() 
	{
	}

	public  abstract boolean _script_evalute(WorkflowWork workflowWork,ParameterContext paramContext) 
	throws ScriptException,WorkflowException;
	
//	public  boolean _script_evalute(WorkflowWork workflowWork,ParameterContext paramContext) 
//	throws ScriptException,WorkflowException
//	{
//		return true;
//	}
}