org.eu.gasp.core.bootstrap.BootstrapThread.java Source code

Java tutorial

Introduction

Here is the source code for org.eu.gasp.core.bootstrap.BootstrapThread.java

Source

/**
 * $Id$
 *
 * Gasp: Generic Application Service Platform
 * http://gasp.berlios.de
 * Copyright (c) 2005 Gasp team
    
 * This program 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.
    
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

package org.eu.gasp.core.bootstrap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Bootstrap thread.
 */
public class BootstrapThread extends Thread {
    private final Log log = LogFactory.getLog(getClass());
    private final Bootstrap bootstrap;

    public BootstrapThread(final Bootstrap bootstrap) {
        super("Gasp bootstrap thread");
        if (bootstrap == null) {
            throw new NullPointerException("bootstrap");
        }
        this.bootstrap = bootstrap;
    }

    @Override
    public void run() {
        try {
            bootstrap.init();
            bootstrap.start();

            synchronized (bootstrap) {
                bootstrap.wait();
            }

            bootstrap.stop();
            System.exit(0);
        } catch (Exception e) {
            log.fatal("Error while bootstrapping", e);
            System.exit(1);
        }
    }
}