Search in sources :

Example 1 with Lifecycle

use of com.adeptj.runtime.common.Lifecycle in project adeptj-runtime by AdeptJ.

the class Launcher method main.

/**
 * Entry point for initializing the AdeptJ Runtime.
 * <p>
 * It does the following tasks in order.
 * <p>
 * 1. Initializes the Logback logging framework.
 * 2. Does the deployment to embedded UNDERTOW.
 * 3. Starts the OSGi Framework.
 * 4. Starts the Undertow server.
 * 5. Registers the runtime ShutdownHook.
 *
 * @param args command line arguments for the Launcher.
 */
public static void main(String[] args) {
    Thread.currentThread().setName("AdeptJ Launcher");
    long startTime = System.nanoTime();
    Logger logger = LoggerFactory.getLogger(Launcher.class);
    Launcher launcher = new Launcher();
    try {
        logger.info("JRE: [{}], Version: [{}]", JAVA_RUNTIME_NAME, JAVA_RUNTIME_VERSION);
        Lifecycle lifecycle = new Server();
        lifecycle.start(args);
        Runtime.getRuntime().addShutdownHook(new ShutdownHook(lifecycle, SERVER_STOP_THREAD_NAME));
        logger.info("AdeptJ Runtime initialized in [{}] ms!!", Times.elapsedMillis(startTime));
    } catch (Throwable th) {
        // NOSONAR
        logger.error("Exception while initializing AdeptJ Runtime!!", th);
        launcher.cleanup(logger);
    }
}
Also used : Server(com.adeptj.runtime.server.Server) Lifecycle(com.adeptj.runtime.common.Lifecycle) ShutdownHook(com.adeptj.runtime.common.ShutdownHook) Logger(org.slf4j.Logger)

Aggregations

Lifecycle (com.adeptj.runtime.common.Lifecycle)1 ShutdownHook (com.adeptj.runtime.common.ShutdownHook)1 Server (com.adeptj.runtime.server.Server)1 Logger (org.slf4j.Logger)1