Example usage for org.springframework.boot.builder SpringApplicationBuilder web

List of usage examples for org.springframework.boot.builder SpringApplicationBuilder web

Introduction

In this page you can find the example usage for org.springframework.boot.builder SpringApplicationBuilder web.

Prototype

public SpringApplicationBuilder web(WebApplicationType webApplicationType) 

Source Link

Document

Flag to explicitly request a specific type of web application.

Usage

From source file:com.coherentlogic.treasurydirect.client.applications.MainApplication.java

public static void main(String[] unused) throws InterruptedException {

    try {/*from   ww w .  j  av a  2s  .c o  m*/

        SpringApplicationBuilder builder = new SpringApplicationBuilder(MainApplication.class);

        builder.web(false).headless(false).registerShutdownHook(true).run(unused);

    } catch (Throwable thrown) {
        log.error("ExampleApplication.main caught an exception.", thrown);
    }

    Thread.sleep(Long.MAX_VALUE);

    System.exit(-9999);
}

From source file:com.erudika.scoold.ScooldServer.java

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder app) {
    initConfig();/*ww  w  .ja va 2  s. c o m*/
    app.profiles(Config.ENVIRONMENT);
    app.web(WebApplicationType.SERVLET);
    return app.sources(ScooldServer.class);
}

From source file:org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.java

@Override
public Environment findOne(String config, String profile, String label) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(PropertyPlaceholderAutoConfiguration.class);
    ConfigurableEnvironment environment = getEnvironment(profile);
    builder.environment(environment);/*from w w  w .j a  v a2s  .c  o m*/
    builder.web(false).bannerMode(Mode.OFF);
    if (!logger.isDebugEnabled()) {
        // Make the mini-application startup less verbose
        builder.logStartupInfo(false);
    }
    String[] args = getArgs(config, profile, label);
    // Explicitly set the listeners (to exclude logging listener which would change
    // log levels in the caller)
    builder.application().setListeners(Arrays.asList(new ConfigFileApplicationListener()));
    ConfigurableApplicationContext context = builder.run(args);
    environment.getPropertySources().remove("profiles");
    try {
        return clean(new PassthruEnvironmentRepository(environment).findOne(config, profile, label));
    } finally {
        context.close();
    }
}

From source file:org.springframework.cloud.config.server.NativeEnvironmentRepository.java

@Override
public Environment findOne(String config, String profile, String label) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(PropertyPlaceholderAutoConfiguration.class);
    ConfigurableEnvironment environment = getEnvironment(profile);
    builder.environment(environment);/*from www. ja v a2s  .c o  m*/
    builder.web(false).showBanner(false);
    String[] args = getArgs(config, label);
    // Explicitly set the listeners (to exclude logging listener which would change
    // log levels in the caller)
    builder.application().setListeners(Collections.singletonList(new ConfigFileApplicationListener()));
    ConfigurableApplicationContext context = builder.run(args);
    environment.getPropertySources().remove("profiles");
    try {
        return clean(new PassthruEnvironmentRepository(environment).findOne(config, profile, label));
    } finally {
        context.close();
    }
}

From source file:org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer.java

@SuppressWarnings("unchecked")
protected void initialize() {
    if (!this.initialized.compareAndSet(false, true)) {
        return;/*  www .j av  a  2s.  c o  m*/
    }
    logger.info("Initializing: " + configurationClass);
    SpringApplicationBuilder builder = new SpringApplicationBuilder(configurationClass);
    ConfigurableApplicationContext context = builder.web(false).run();
    context.getAutowireCapableBeanFactory().autowireBean(this);
    String name = context.getEnvironment().getProperty("function.name");
    boolean defaultName = false;
    if (name == null) {
        name = "function";
        defaultName = true;
    }
    if (this.catalog == null) {
        this.function = context.getBean(name, Function.class);
    } else {
        this.function = this.catalog.lookupFunction(name);
        this.name = name;
        if (this.function == null) {
            if (defaultName) {
                name = "consumer";
            }
            this.consumer = this.catalog.lookupConsumer(name);
            this.name = name;
            if (this.consumer == null) {
                if (defaultName) {
                    name = "supplier";
                }
                this.supplier = this.catalog.lookupSupplier(name);
                this.name = name;
            }
        }
    }
    this.context = context;
}