package de.snailshell.consensus.demo;

import javax.servlet.ServletException;
import javax.servlet.UnavailableException;

import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;

import de.uka.ipd.consensus.foundation.ConsensusFoundation;

/**
 * @author Thomas Much
 * @version 2006-06-14
 */
public class ConsensusFoundationPlugin implements PlugIn {

	private String config = ConsensusFoundation.CF_PROPERTIES;
	
	
	public void setConfig(String configFile) {
		this.config = configFile;
	}

	
	public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {

		try {
			ConsensusFoundation cf = new ConsensusFoundation( this.config );

			servlet.getServletContext().setAttribute( Constants.CONTEXT_ATTR_CONSENSUSFOUNDATION, cf );
		}
		catch (Exception e) {
			throw new UnavailableException( "Could not initialize ConsensusFoundation\n" + e );
		}
	}

	public void destroy() { }
}
