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

be.bagofwords.application.ApplicationManager Maven / Gradle / Ivy

Go to download

Utility classes that are used in the count-db project and other bow-* projects

There is a newer version: 1.2.0
Show newest version
package be.bagofwords.application;

import be.bagofwords.ui.UI;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class ApplicationManager {

    public static void runSafely(ApplicationContextFactory applicationContextFactory) {
        AnnotationConfigApplicationContext applicationContext = null;
        try {
            applicationContext = applicationContextFactory.createApplicationContext();
            MainClass instance = applicationContext.getBean(MainClass.class);
            applicationContext.start();
            instance.run();
        } catch (Throwable exp) {
            UI.writeError("Received unexpected exception, terminating application.", exp);
        } finally {
            if (applicationContext != null) {
                applicationContext.close();
            }
        }
        UI.write("Application was terminated. Goodbye!");
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy