/*
 * Created on 2004-6-12
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.huihoo.willow.startup;

import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSetBase;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */

public class EngineRuleSet extends RuleSetBase
{

	// ----------------------------------------------------- Instance Variables

	/**
	 * The matching pattern prefix to use for recognizing our elements.
	 */
	protected String prefix = null;

	// ------------------------------------------------------------ Constructor

	/**
	 * Construct an instance of this <code>RuleSet</code> with the default
	 * matching pattern prefix.
	 */
	public EngineRuleSet()
	{

		this("");

	}

	/**
	 * Construct an instance of this <code>RuleSet</code> with the specified
	 * matching pattern prefix.
	 *
	 * @param prefix Prefix for matching pattern rules (including the
	 *  trailing slash character)
	 */
	public EngineRuleSet(String prefix)
	{

		super();
		this.namespaceURI = null;
		this.prefix = prefix;

	}

	// --------------------------------------------------------- Public Methods

	/**
	 * <p>Add the set of Rule instances defined in this RuleSet to the
	 * specified <code>Digester</code> instance, associating them with
	 * our namespace URI (if any).  This method should only be called
	 * by a Digester instance.</p>
	 *
	 * @param digester Digester instance to which the new Rule instances
	 *  should be added.
	 */
	public void addRuleInstances(Digester digester)
	{
		digester.addObjectCreate(
			prefix + "Engine",
			"org.huihoo.willow.core.StandardEngine",
			"className");
		digester.addSetProperties(prefix + "Engine");
		digester.addRule(
			prefix + "Engine",
			new LifecycleListenerRule(
				digester,
				"org.huihoo.willow.startup.EngineConfig",
				"engineConfigClass"));
		digester.addSetNext(prefix + "Engine", "setContainer", "org.huihoo.willow.Container");

		digester.addObjectCreate(prefix + "Engine/Listener", null,"className");
		digester.addSetProperties(prefix + "Engine/Listener");
		digester.addSetNext(
			prefix + "Engine/Listener",
			"addLifecycleListener",
			"org.huihoo.willow.LifecycleListener");

		digester.addObjectCreate(prefix + "Engine/RealmDatabase", null, "className");
		//digester.addSetProperties(prefix + "Engine/RealmDatabase");
		digester.addSetNext(prefix + "Engine/RealmDatabase", "setRealmDatabase", "workflow.store.RealmDatabase");

		digester.addObjectCreate(prefix + "Engine/Logger", null, "className");
		digester.addSetProperties(prefix + "Engine/Logger");
		digester.addSetNext(prefix + "Engine/Logger", "setLogger", "org.huihoo.willow.Logger");

	}

}