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.icgc.dcc.release.client.ClientMain.java

private static void execute(Options options, String[] args) {
    val applicationContext = new SpringApplicationBuilder(ClientMain.class).web(false).run(args);
    val workflow = applicationContext.getBean(Workflow.class);
    val workflowContext = createWorkflowContext(options);
    log.info("{}\n", repeat("-", 100));

    workflow.execute(workflowContext);//from   w ww .  ja  v  a 2s . c  om
}

From source file:com.neoteric.starter.swagger.SwaggerAutoConfigurationIntegrationTest.java

@Test
public void shouldAddApiInfoDetails() throws Exception {
    this.wac = (ConfigurableWebApplicationContext) new SpringApplicationBuilder(SwaggerConfiguration.class)
            .properties("neostarter.swagger.license=license", "neostarter.swagger.licenseUrl=licenseUrl",
                    "neostarter.swagger.title=ApiTitle", "neostarter.swagger.description=ApiDescription",
                    "neostarter.swagger.termsOfServiceUrl=termsUrl",
                    "neostarter.swagger.contact.name=contactName",
                    "neostarter.swagger.contact.email=contactEmail",
                    "neostarter.swagger.contact.url=contactUrl", "neostarter.swagger.version=2",
                    "neostarter.swagger.basePackage=")
            .run();// w ww. j  a v a 2 s .c  o  m
    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();

    this.mockMvc.perform(get("/swagger")).andExpect(status().isOk())
            .andExpect(jsonPath("$.info.license.name").value("license"))
            .andExpect(jsonPath("$.info.license.url").value("licenseUrl"))
            .andExpect(jsonPath("$.info.title").value("ApiTitle"))
            .andExpect(jsonPath("$.info.description").value("ApiDescription"))
            .andExpect(jsonPath("$.info.termsOfService").value("termsUrl"))
            .andExpect(jsonPath("$.info.contact.name").value("contactName"))
            .andExpect(jsonPath("$.info.contact.email").value("contactEmail"))
            .andExpect(jsonPath("$.info.contact.url").value("contactUrl"))
            .andExpect(jsonPath("$.info.version").value("2"));
}

From source file:at.ac.univie.isc.asio.Asio.java

static SpringApplicationBuilder application() {
    return new SpringApplicationBuilder(Asio.class).web(true).showBanner(false)
            .listeners(new JerseyLogInitializer());
}

From source file:ninja.eivind.hotsreplayuploader.Client.java

@Override
public void init() {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Client.class);
    context = builder.headless(false).run(launchArgs);
    context.getAutowireCapableBeanFactory().autowireBean(this);

    //add a shutdown hook to be really sure, resources are closed properly
    Runtime.getRuntime().addShutdownHook(new Thread(context::close));
}

From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java

private void start() throws Exception {
    log.info("Starting...");

    final TrayIcon trayIcon = new TrayIcon(new ImageIcon(imageDisabledUrl).getImage(), "Ethereum Harmony");
    trayIcon.setImageAutoSize(true); // Auto-size icon base on space

    // doesn't work
    //        Runtime.getRuntime().addShutdownHook(new Thread(() -> closeContext()));

    executor.submit(() -> {//from  w w  w .j  ava2  s .co  m
        try {
            context = new SpringApplicationBuilder(Application.class).headless(true).web(true).run();
            serverPort = Integer.valueOf(context.getEnvironment().getProperty("local.server.port"));
            log.info("Spring context created at port " + serverPort);
            trayIcon.setImage(new ImageIcon(imageEnabledUrl).getImage());
            setTrayMenu(trayIcon, browserMenu, logsMenu, quitMenu);
            openBrowser();

        } catch (Exception e) {
            final Throwable cause = DesktopUtil.findCauseFromSpringException(e);
            showErrorWindow(cause.getMessage(),
                    "Problem running Harmony:\n\n" + ExceptionUtils.getStackTrace(cause));
        }
    });

    if (!SystemTray.isSupported()) {
        log.error("System tray is not supported");
        return;
    }

    browserMenu.addActionListener(e -> openBrowser());
    quitMenu.addActionListener(event -> {
        log.info("Quit action was requested from tray menu");
        trayIcon.setImage(new ImageIcon(imageDisabledUrl).getImage());
        setTrayMenu(trayIcon, logsMenu, quitingMenu);
        closeContext();
        System.exit(0);
    });

    logsMenu.addActionListener(event -> {
        log.info("Logs action was requested from tray menu");
        final File logsFile = new File(LOGS_PATH);
        try {
            Desktop.getDesktop().open(logsFile);
        } catch (IOException e) {
            log.error("Problem opening logs dir", e);
        }
    });

    setTrayMenu(trayIcon, loadingMenu, logsMenu, quitMenu);
}

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

@Test
public void authenticatedHttpsProxy() throws Exception {
    String repoUrl = "https://myrepo/repo.git";
    new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE)
            .properties(gitProperties(repoUrl, null, AUTHENTICATED_HTTPS_PROXY)).run();
    HttpClient httpClient = getHttpClientForUrl(repoUrl);
    this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
            hasProperty("message", containsString(AUTHENTICATED_HTTPS_PROXY.getHost()))));

    makeRequest(httpClient, "https://somehost");
}

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

@Test
public void httpsProxy() throws Exception {
    String repoUrl = "https://myrepo/repo.git";
    new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE)
            .properties(gitProperties(repoUrl, null, HTTPS_PROXY)).run();
    HttpClient httpClient = getHttpClientForUrl(repoUrl);
    this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
            hasProperty("message", containsString(HTTPS_PROXY.getHost()))));

    makeRequest(httpClient, "https://somehost");
}

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

@Test
public void httpsProxy_placeholderUrl() throws Exception {
    new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE)
            .properties(/* w  w w .  ja v a2s  .  com*/
                    gitProperties("https://myrepo/{placeholder1}/{placeholder2}-repo.git", null, HTTPS_PROXY))
            .run();
    HttpClient httpClient = getHttpClientForUrl(
            "https://myrepo/someplaceholdervalue/anotherplaceholdervalue-repo.git");
    this.expectedException.expectCause(allOf(instanceOf(UnknownHostException.class),
            hasProperty("message", containsString(HTTPS_PROXY.getHost()))));

    makeRequest(httpClient, "https://somehost");
}

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

@Test
public void httpsProxy_notCalled() throws Exception {
    String repoUrl = "https://myrepo/repo.git";
    new SpringApplicationBuilder(TestConfiguration.class).web(WebApplicationType.NONE)
            .properties(gitProperties(repoUrl, null, HTTPS_PROXY)).run();
    HttpClient httpClient = getHttpClientForUrl(repoUrl);
    this.expectedException.expectCause(
            allOf(instanceOf(UnknownHostException.class), hasProperty("message", containsString("somehost"))));

    makeRequest(httpClient, "http://somehost");
}