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

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

Introduction

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

Prototype

public SpringApplicationBuilder(Class<?>... sources) 

Source Link

Usage

From source file:org.springframework.cloud.dataflow.server.local.metrics.FakeMetricsCollectorResource.java

@Override
protected void before() throws Throwable {

    originalServerPort = System.getProperty(FAKE_METRICS_COLLECTOR_PORT_PROPERTY);

    this.serverPort = SocketUtils.findAvailableTcpPort();

    LOGGER.info("Setting Fake Metrics Collector port to " + this.serverPort);

    System.setProperty(FAKE_METRICS_COLLECTOR_PORT_PROPERTY, String.valueOf(this.serverPort));

    this.application = new SpringApplicationBuilder(FakeMetricsCollector.class)
            .properties("logging.level.org.springframework.boot.autoconfigure.logging=debug").build()
            .run("--spring.config.location=classpath:/org/springframework/cloud/dataflow/server/local/metrics/fakeMetricsCollectorConfig.yml");

}

From source file:org.springframework.cloud.dataflow.server.local.security.OAuth2ServerResource.java

@Override
protected void before() throws Throwable {

    originalOAuth2Port = System.getProperty(OAUTH2_PORT_PROPERTY);

    this.oauth2ServerPort = SocketUtils.findAvailableTcpPort();

    LOGGER.info("Setting OAuth2 Server port to " + this.oauth2ServerPort);

    System.setProperty(OAUTH2_PORT_PROPERTY, String.valueOf(this.oauth2ServerPort));

    this.application = new SpringApplicationBuilder(OAuth2TestServer.class).build()
            .run("--spring.config.location=classpath:/org/springframework/cloud/dataflow/server/local/security"
                    + "/support/oauth2TestServerConfig.yml");
}

From source file:org.springframework.cloud.dataflow.server.single.security.OAuth2ServerResource.java

@Override
protected void before() throws Throwable {

    originalOAuth2Port = System.getProperty(OAUTH2_PORT_PROPERTY);

    this.oauth2ServerPort = SocketUtils.findAvailableTcpPort();

    LOGGER.info("Setting OAuth2 Server port to " + this.oauth2ServerPort);

    System.setProperty(OAUTH2_PORT_PROPERTY, String.valueOf(this.oauth2ServerPort));

    final String configurationLocation = "classpath:/org/springframework/cloud/dataflow/server/single/security/support/oauth2TestServerConfig.yml";

    final Resource resource = new PathMatchingResourcePatternResolver().getResource(configurationLocation);
    if (!resource.exists()) {
        throw new IllegalArgumentException(String
                .format("Resource 'configurationLocation' ('%s') does not exist.", configurationLocation));
    }//w  w  w .ja va  2  s  .c om

    this.application = new SpringApplicationBuilder(OAuth2TestServer.class).build().run(
            "--spring.cloud.common.security.enabled=false", "--spring.cloud.kubernetes.enabled=false",
            "--spring.config.additional-location=" + configurationLocation);
}

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

@SuppressWarnings("unchecked")
protected void initialize() {
    if (!this.initialized.compareAndSet(false, true)) {
        return;/*w  w w  .j a  v a2  s.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;
}

From source file:org.springframework.cloud.gateway.test.sse.SseIntegrationTests.java

@Before
public void setup() throws Exception {
    this.server = new ReactorHttpServer();
    this.server.setHandler(createHttpHandler());
    this.server.afterPropertiesSet();
    this.server.start();

    // Set dynamically chosen port
    this.serverPort = this.server.getPort();
    logger.info("SSE Port: " + this.serverPort);

    this.gatewayContext = new SpringApplicationBuilder(GatewayConfig.class)
            .properties("sse.server.port:" + this.serverPort, "server.port=0", "spring.jmx.enabled=false")
            .run();/*from  w  ww .j a  va  2 s. c  o  m*/

    ConfigurableEnvironment env = this.gatewayContext.getBean(ConfigurableEnvironment.class);
    this.gatewayPort = Integer.valueOf(env.getProperty("local.server.port"));

    this.webClient = WebClient.create("http://localhost:" + this.gatewayPort + "/sse");

    logger.info("Gateway Port: " + this.gatewayPort);
}

From source file:org.springframework.cloud.gateway.test.websocket.WebSocketIntegrationTests.java

@Before
public void setup() throws Exception {
    this.client = new ReactorNettyWebSocketClient();

    this.server = new ReactorHttpServer();
    this.server.setHandler(createHttpHandler());
    this.server.afterPropertiesSet();
    this.server.start();

    // Set dynamically chosen port
    this.serverPort = this.server.getPort();

    if (this.client instanceof Lifecycle) {
        ((Lifecycle) this.client).start();
    }//  ww  w .jav  a2s  . c o  m

    this.gatewayContext = new SpringApplicationBuilder(GatewayConfig.class)
            .properties("ws.server.port:" + this.serverPort, "server.port=0", "spring.jmx.enabled=false").run();

    ConfigurableEnvironment env = this.gatewayContext.getBean(ConfigurableEnvironment.class);
    this.gatewayPort = Integer.valueOf(env.getProperty("local.server.port"));
}

From source file:org.springframework.cloud.launcher.kafka.KafkaApplication.java

public static void main(String[] args) {
    new SpringApplicationBuilder(KafkaApplication.class).run(args);
}

From source file:org.springframework.cloud.netflix.zuul.FormZuulServletProxyApplicationTests.java

public static void main(String[] args) {
    new SpringApplicationBuilder(FormZuulProxyApplication.class)
            .properties("zuul.routes.simplefzspat:/zuul/simplefzspat/**",
                    "zuul.routes.direct.url:http://localhost:9999", "zuul.routes.direct.path:/zuul/direct/**",
                    "multipart.maxFileSize:4096MB", "multipart.maxRequestSize:4096MB")
            .run(args);/*from w ww . j  a  v  a 2  s. c om*/
}

From source file:org.springframework.cloud.stream.binder.test.integration.EndToEndIntegrationTests.java

private Sender createSender(String... arguments) {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(SenderApplication.class)
            .bannerMode(Banner.Mode.OFF).build()
            .run(applicationArguments(String.format(OUTPUT_DESTINATION_FORMAT, this.destination), arguments));

    startedContexts.add(context);//from   w  ww  .j  av a 2  s . c om
    return context.getBean(Sender.class);
}

From source file:org.springframework.cloud.stream.binder.test.integration.EndToEndIntegrationTests.java

private Receiver createReceiver(String... arguments) {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(ReceiverApplication.class)
            .bannerMode(Banner.Mode.OFF).build()
            .run(applicationArguments(String.format(INPUT_DESTINATION_FORMAT, this.destination), arguments));

    startedContexts.add(context);/*from   ww w  . j a  v a 2s .  c om*/
    return context.getBean(Receiver.class);
}