//----------------------------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.script.compiler;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Static class used to preload java classes when using the
 * Java SecurityManager so that the defineClassInPackage
 * RuntimePermission does not trigger an AccessControlException.
 *
 */

public final class SecurityClassLoad
{

	private static Log log = LogFactory.getLog(SecurityClassLoad.class);

	public static void securityClassLoad(ClassLoader loader)
	{

		if (System.getSecurityManager() == null)
		{
			return;
		}

		String basePackage = "org.huihoo.workflow.rules.";
		try
		{
			loader.loadClass(basePackage + "ScriptBase");
			loader.loadClass(basePackage + "ScriptContext");
		}
		catch (ClassNotFoundException ex)
		{
			System.out.println("Rules SecurityClassLoad preload of class failed: " + ex.getMessage());
			log.error("SecurityClassLoad", ex);
		}
	}
}
