All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yamcs.EventCrashHandler Maven / Gradle / Ivy

There is a newer version: 5.10.7
Show newest version
package org.yamcs;

import org.yamcs.events.EventProducer;
import org.yamcs.events.EventProducerFactory;

/**
 * Crash handler that reports events via an event producer
 * 
 * Created by msc on 28/11/16.
 */
public class EventCrashHandler implements CrashHandler {

    private EventProducer eventProducer;
    private boolean sendingError;

    public EventCrashHandler(String instanceName) {
        eventProducer = EventProducerFactory.getEventProducer(instanceName);
        eventProducer.setSource("CrashHandler");
    }

    @Override
    public synchronized void handleCrash(String type, String msg) {
        if (sendingError) {
            return;
        }
        try {
            sendingError = true;
            eventProducer.sendSevere(type, msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        sendingError = false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy