package de.uka.ipd.consensus.foundation;

import java.util.Properties;

import de.uka.ipd.consensus.foundation.evolution.EvolutionManager;
import de.uka.ipd.consensus.foundation.logging.LoggingManager;
import de.uka.ipd.consensus.foundation.ontology.OntologyManager;
import de.uka.ipd.consensus.foundation.rating.RatingManager;
import de.uka.ipd.consensus.foundation.rights.DynamicRightsManager;
import de.uka.ipd.consensus.foundation.scoring.IncentiveManager;
import de.uka.ipd.consensus.foundation.user.UserManager;

/**
 * An abstract superclass for the seven components (the "managers") of the ConsensusFoundation framework.
 * It offers easy access to all other components within each component that subclasses this class.
 * @author Thomas Much
 * @version 2006-06-14
 */
public abstract class AbstractConsensusFoundationModule implements ConsensusFoundationModule,ConsensusFoundationManager {

	private ConsensusFoundationManager cfm;


	/**
	 * Stores the ConsensusFoundationManager reference.
	 * <p>If you override this method be sure to call this superclass method early in the overriding method!</p>
	 */
	public void initCompleted(Properties config, ConsensusFoundationManager cfm) throws Exception {
		this.cfm = cfm;
	}

	
	public ConsensusFoundationManager getConsensusFoundationManager() {
		return cfm;
	}


	public LoggingManager getLoggingManager() {
		return getConsensusFoundationManager().getLoggingManager();
	}

	
	public UserManager getUserManager() {
		return getConsensusFoundationManager().getUserManager();
	}

	
	public OntologyManager getOntologyManager() {
		return getConsensusFoundationManager().getOntologyManager();
	}

	
	public EvolutionManager getEvolutionManager() {
		return getConsensusFoundationManager().getEvolutionManager();
	}

	
	public RatingManager getRatingManager() {
		return getConsensusFoundationManager().getRatingManager();
	}

	
	public IncentiveManager getIncentiveManager() {
		return getConsensusFoundationManager().getIncentiveManager();
	}


	public DynamicRightsManager getDynamicRightsManager() {
		return getConsensusFoundationManager().getDynamicRightsManager();
	}


	/**
	 * Calls <code>shutdown()</code> if the application forgot to do so.
	 * @see #shutdown()
	 */
	protected void finalize() throws Throwable {
		shutdown();
		super.finalize();
	}


	/**
	 * An empty implementation.
	 * <p>If you override this method make sure that the shutdown code is executed only once even if this method is called multiple times.</p>
	 */
	public void shutdown() { }
}
