/* $Id: KernelFacade.java,v 1.3 2007/05/10 00:37:29 m31 Exp $
 *
 * This file is part of the project "Hilbert II" - http://www.qedeq.org
 *
 * Copyright 2000-2007,  Michael Meyling <mime@qedeq.org>.
 *
 * "Hilbert II" is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */

package org.qedeq.kernel.rel.test.text;

import java.io.IOException;

import org.qedeq.kernel.bo.load.DefaultModuleFactory;
import org.qedeq.kernel.context.KernelContext;
import org.qedeq.kernel.log.LogListenerImpl;
import org.qedeq.kernel.log.ModuleEventListenerLog;
import org.qedeq.kernel.log.ModuleEventLog;
import org.qedeq.kernel.log.QedeqLog;


/**
 * This class provides static access methods for basic informations.
 *
 * @version $Revision: 1.3 $
 * @author  Michael Meyling
 */
public final class KernelFacade {

    static {
        try {
            QedeqLog.getInstance().addLog(new LogListenerImpl());
            ModuleEventLog.getInstance().addLog(new ModuleEventListenerLog());
            KernelContext.getInstance().startup(new DefaultModuleFactory(KernelContext.getInstance()));
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        final Thread shutdown = new Thread() {
            public void run() {
                KernelContext.getInstance().shutdown();
            }
        };
        Runtime.getRuntime().addShutdownHook(shutdown);
    }

    public static KernelContext getKernelContext() {
        return KernelContext.getInstance();
    }
}
