Example usage for org.springframework.boot DefaultApplicationArguments DefaultApplicationArguments

List of usage examples for org.springframework.boot DefaultApplicationArguments DefaultApplicationArguments

Introduction

In this page you can find the example usage for org.springframework.boot DefaultApplicationArguments DefaultApplicationArguments.

Prototype

public DefaultApplicationArguments(String... args) 

Source Link

Usage

From source file:org.springframework.boot.SpringApplication.java

private ConfigurableApplicationContext doRun(SpringApplicationRunListeners listeners, String... args) {
    ConfigurableApplicationContext context;
    // Create and configure the environment
    ConfigurableEnvironment environment = getOrCreateEnvironment();
    configureEnvironment(environment, args);
    listeners.environmentPrepared(environment);
    if (isWebEnvironment(environment) && !this.webEnvironment) {
        environment = convertToStandardEnvironment(environment);
    }//w w  w .  j a  va  2 s . com

    if (this.bannerMode != Banner.Mode.OFF) {
        printBanner(environment);
    }

    // Create, load, refresh and run the ApplicationContext
    context = createApplicationContext();
    context.setEnvironment(environment);
    postProcessApplicationContext(context);
    applyInitializers(context);
    listeners.contextPrepared(context);
    if (this.logStartupInfo) {
        logStartupInfo(context.getParent() == null);
        logStartupProfileInfo(context);
    }

    // Add boot specific singleton beans
    ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);
    context.getBeanFactory().registerSingleton("springApplicationArguments", applicationArguments);

    // Load the sources
    Set<Object> sources = getSources();
    Assert.notEmpty(sources, "Sources must not be empty");
    load(context, sources.toArray(new Object[sources.size()]));
    listeners.contextLoaded(context);

    // Refresh the context
    refresh(context);
    if (this.registerShutdownHook) {
        try {
            context.registerShutdownHook();
        } catch (AccessControlException ex) {
            // Not allowed in some environments.
        }
    }
    afterRefresh(context, applicationArguments);
    listeners.finished(context, null);
    return context;
}