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

/**
 * 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
{

	public static void securityClassLoad(ClassLoader loader) throws Exception
	{

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

		loadCorePackage(loader);
		loadLoaderPackage(loader);
		loadSessionPackage(loader);
		loadUtilPackage(loader);
	}

	private final static void loadCorePackage(ClassLoader loader) throws Exception
	{
		String basePackage = "org.huihoo.willow.";
		loader.loadClass(basePackage + "core.ApplicationContext");
	}

	private final static void loadLoaderPackage(ClassLoader loader) throws Exception
	{
		String basePackage = "org.apache.willow.";
		loader.loadClass(basePackage + "loader.WorkflowClassLoader$PrivilegedFindResource");
	}

	private final static void loadSessionPackage(ClassLoader loader) throws Exception
	{
		String basePackage = "org.apache.willow.";
		loader.loadClass(basePackage + "session.StandardSession");
		loader.loadClass(basePackage + "session.StandardSession$1");
		loader.loadClass(basePackage + "session.StandardManager$PrivilegedDoUnload");
	}

	private final static void loadUtilPackage(ClassLoader loader) throws Exception
	{
		String basePackage = "org.apache.willow.";
	}
}
