Example usage for org.springframework.boot.devtools.restart Restarter initialize

List of usage examples for org.springframework.boot.devtools.restart Restarter initialize

Introduction

In this page you can find the example usage for org.springframework.boot.devtools.restart Restarter initialize.

Prototype

public static void initialize(String[] args, boolean forceReferenceCleanup, RestartInitializer initializer,
        boolean restartOnInitialize) 

Source Link

Document

Initialize restart support for the current application.

Usage

From source file:org.springframework.boot.devtools.restart.RestartApplicationListener.java

private void onApplicationStartingEvent(ApplicationStartingEvent event) {
    // It's too early to use the Spring environment but we should still allow
    // users to disable restart using a System property.
    String enabled = System.getProperty(ENABLED_PROPERTY);
    if (enabled == null || Boolean.parseBoolean(enabled)) {
        String[] args = event.getArgs();
        DefaultRestartInitializer initializer = new DefaultRestartInitializer();
        boolean restartOnInitialize = !AgentReloader.isActive();
        if (!restartOnInitialize) {
            logger.info("Restart disabled due to an agent-based reloader being active");
        }//from   w  w w  .  j ava 2s . c om
        Restarter.initialize(args, false, initializer, restartOnInitialize);
    } else {
        logger.info("Restart disabled due to System property '" + ENABLED_PROPERTY + "' being set to false");
        Restarter.disable();
    }
}