Search in sources :

Example 1 with IndyBootException

use of org.commonjava.indy.boot.IndyBootException in project indy by Commonjava.

the class JaxRsBooter method main.

public static void main(final String[] args) {
    Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(final Thread thread, final Throwable error) {
            if (error instanceof InvocationTargetException) {
                final InvocationTargetException ite = (InvocationTargetException) error;
                System.err.println("In: " + thread.getName() + "(" + thread.getId() + "), caught InvocationTargetException:");
                ite.getTargetException().printStackTrace();
                System.err.println("...via:");
                error.printStackTrace();
            } else {
                System.err.println("In: " + thread.getName() + "(" + thread.getId() + ") Uncaught error:");
                error.printStackTrace();
            }
        }
    });
    BootOptions boot;
    try {
        boot = BootOptions.loadFromSysprops();
    } catch (final IndyBootException e) {
        System.err.printf("ERROR: %s", e.getMessage());
        System.exit(ERR_CANT_LOAD_BOOT_OPTIONS);
        return;
    }
    try {
        if (boot.parseArgs(args)) {
            try {
                final BootInterface booter = new JaxRsBooter();
                System.out.println("Starting Indy booter: " + booter);
                final int result = booter.runAndWait(boot);
                if (result != 0) {
                    System.exit(result);
                }
            } catch (final IndyBootException e) {
                System.err.printf("ERROR INITIALIZING BOOTER: %s", e.getMessage());
                System.exit(ERR_CANT_INIT_BOOTER);
            }
        }
    } catch (final IndyBootException e) {
        System.err.printf("ERROR: %s", e.getMessage());
        System.exit(ERR_CANT_PARSE_ARGS);
    }
}
Also used : WeldBootInterface(org.commonjava.indy.boot.WeldBootInterface) BootInterface(org.commonjava.indy.boot.BootInterface) IndyBootException(org.commonjava.indy.boot.IndyBootException) UncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler) BootOptions(org.commonjava.indy.boot.BootOptions) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

UncaughtExceptionHandler (java.lang.Thread.UncaughtExceptionHandler)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BootInterface (org.commonjava.indy.boot.BootInterface)1 BootOptions (org.commonjava.indy.boot.BootOptions)1 IndyBootException (org.commonjava.indy.boot.IndyBootException)1 WeldBootInterface (org.commonjava.indy.boot.WeldBootInterface)1