Example usage for org.springframework.boot SpringApplication SpringApplication

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

Introduction

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

Prototype

public SpringApplication(Class<?>... primarySources) 

Source Link

Document

Create a new SpringApplication instance.

Usage

From source file:org.agiso.tempel.starter.Bootstrap.java

public static void main(IParamReader paramReader, String[] args) throws Exception {
    // TODO: Utworzy interfejs IMappingAnsiProcessor
    setAnsiProcessor(new IWrappingAnsiProcessor() {
        //         private static final Map<Object, Object> elementMappings;
        //         static {
        //            elementMappings = new HashMap<Object, Object>();
        //            elementMappings.put(NORMAL, org.springframework.boot.ansi.AnsiElement.NORMAL);
        //            // ...
        //         }

        @Override/*from www . ja  va 2  s  .c  o m*/
        public String ansiString(Object... elements) {
            return AnsiOutput.toString(elements);
        }
    }).withAnsiNormal(org.springframework.boot.ansi.AnsiElement.NORMAL)
            .withAnsiBold(org.springframework.boot.ansi.AnsiElement.BOLD)
            .withAnsiFaint(org.springframework.boot.ansi.AnsiElement.FAINT)
            .withAnsiItalic(org.springframework.boot.ansi.AnsiElement.ITALIC)
            .withAnsiUnderline(org.springframework.boot.ansi.AnsiElement.UNDERLINE)
            .withAnsiBlack(org.springframework.boot.ansi.AnsiElement.BLACK)
            .withAnsiRed(org.springframework.boot.ansi.AnsiElement.RED)
            .withAnsiGreen(org.springframework.boot.ansi.AnsiElement.GREEN)
            .withAnsiYellow(org.springframework.boot.ansi.AnsiElement.YELLOW)
            .withAnsiBlue(org.springframework.boot.ansi.AnsiElement.BLUE)
            .withAnsiMagenta(org.springframework.boot.ansi.AnsiElement.MAGENTA)
            .withAnsiCyan(org.springframework.boot.ansi.AnsiElement.CYAN)
            .withAnsiWhite(org.springframework.boot.ansi.AnsiElement.WHITE)
            .withAnsiDefault(org.springframework.boot.ansi.AnsiElement.DEFAULT);

    // Obsuga wywoania bezargumentowego:
    if (args.length == 0) {
        printTempelInfo();
        System.exit(0);
    }

    setParamReader(paramReader);

    SpringApplication application = new SpringApplication(Bootstrap.class);
    //      application.addInitializers(new LoggingInitializer());
    application.setShowBanner(false);
    application.run(args);
}

From source file:cf.spring.servicebroker.CatalogTest.java

@Test
public void spelCatalogCredentials() throws Exception {
    final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY,
            new UsernamePasswordCredentials(CONFIGURABLE_USERNAME, CONFIGURABLE_PASSWORD));
    final SpringApplication application = new SpringApplication(SpelServiceBrokerCatalog.class);
    try (ConfigurableApplicationContext context = application.run();
            CloseableHttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider)
                    .build();) {//  w w w . ja va2 s .  co m
        final HttpUriRequest catalogRequest = RequestBuilder.get()
                .setUri("http://localhost:8080" + Constants.CATALOG_URI).build();
        final CloseableHttpResponse response = client.execute(catalogRequest);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
    }
}

From source file:org.kurento.test.services.KurentoServicesTestHelper.java

public static ConfigurableApplicationContext startHttpServer(Object... sources) {
    appContext = new SpringApplication(sources).run("--server.port=" + getAppHttpPort());
    return appContext;
}

From source file:cf.spring.servicebroker.CatalogTest.java

@Test
public void emptyCatalog() throws Exception {
    final SpringApplication application = new SpringApplication(EmptyServiceBrokerCatalog.class);
    try (ConfigurableApplicationContext context = application.run();
            CloseableHttpClient client = buildAuthenticatingClient()) {
        JsonNode catalog = loadCatalog(client);
        assertNotNull(catalog);//from  ww w .  ja v  a 2 s . c  o m
        assertTrue(catalog.has("services"));
        final JsonNode services = catalog.get("services");
        assertTrue(services.isArray());
        assertEquals(services.size(), 0);
    }
}

From source file:fi.hsl.parkandride.Application.java

public static void main(String[] args) {
    SpringApplication app = new SpringApplication(Application.class);
    app.addListeners(new ApplicationPidListener());
    app.run(args);/*from   w  w w  .  ja v  a2  s .c om*/
}

From source file:io.github.gsteckman.doorcontroller.DoorApp.java

/**
 * Application entry point.//  w  w  w.jav a2  s. com
 * 
 * @param args
 *            Command line arguments.
 */
public static void main(String[] args) {
    GpioUtil.enableNonPrivilegedAccess();
    SpringApplication app = new SpringApplication(DoorApp.class);
    app.setBannerMode(Banner.Mode.OFF);
    app.run(args);
}

From source file:org.cbioportal.annotation.AnnotationPipeline.java

private static void launchJob(String[] args, String filename, String outputFilename, String isoformOverride,
        String errorReportLocation, boolean replace, boolean verbose) throws Exception {
    SpringApplication app = new SpringApplication(AnnotationPipeline.class);
    ConfigurableApplicationContext ctx = app.run(args);
    JobLauncher jobLauncher = ctx.getBean(JobLauncher.class);

    Job annotationJob = ctx.getBean(BatchConfiguration.ANNOTATION_JOB, Job.class);
    JobParameters jobParameters = new JobParametersBuilder().addString("filename", filename)
            .addString("outputFilename", outputFilename).addString("replace", String.valueOf(replace))
            .addString("isoformOverride", isoformOverride).addString("errorReportLocation", errorReportLocation)
            .addString("verbose", String.valueOf(verbose)).toJobParameters();
    JobExecution jobExecution = jobLauncher.run(annotationJob, jobParameters);
    if (!jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) {
        System.exit(2);//ww  w  .ja  v a 2  s .c o m
    }
}

From source file:org.flockdata.client.CommandRunner.java

public static void main(String[] args) {
    SpringApplication app;// ww w  .  j  av  a  2 s. c o  m
    //        System.out.print(ArrayUtils.toString(args));
    if (ArrayUtils.contains(args, "import")) {
        app = new SpringApplication(Importer.class);
        app.setAdditionalProfiles("fd-importer");
    } else if (ArrayUtils.contains(args, "register")) {
        app = new SpringApplication(Register.class);
        app.setAdditionalProfiles("fd-register");
    } else if (ArrayUtils.contains(args, "ping")) {
        app = new SpringApplication(PingRunner.class);
        app.setAdditionalProfiles("fd-ping");

    } else if (ArrayUtils.contains(args, "health")) {
        app = new SpringApplication(HealthRunner.class);
        app.setAdditionalProfiles("fd-health");

    } else {
        System.out.println("");
        System.out.println("Commands supported are import and register");
        System.exit(1);
        return;
    }

    app.setWebEnvironment(false);
    app.setBannerMode(Banner.Mode.OFF);

    // launch the app
    ConfigurableApplicationContext context = app.run(args);

    // finished so close the context
    context.close();
    System.exit(0);
}

From source file:org.graphwalker.studio.Application.java

private void run(String[] args) {
    Options options = new Options();
    JCommander jc = new JCommander(options);
    jc.setProgramName("java -jar graphwalker.jar");
    try {//  w  ww. j  a  v  a  2s  .c  o  m
        jc.parseWithoutValidation(args);
    } catch (Exception e) {
        // ignore
    }

    try {
        setLogLevel(options);

        if (options.help) {
            options = new Options();
            jc = new JCommander(options);
            jc.parse(args);
            jc.usage();
            return;
        } else if (options.version) {
            System.out.println(printVersionInformation());
            return;
        }

        WebSocketServer gwSocketServer = new WebSocketServer(options.wsPort);
        gwSocketServer.start();

        Properties props = System.getProperties();
        props.setProperty("server.port", String.valueOf(options.browserPort));

        SpringApplication application = new SpringApplication(Application.class);
        Environment environment = application.run(args).getEnvironment();
        logger.info("Access URLs:\n----------------------------------------------------------\n"
                + "  Local web service:          http://127.0.0.1:" + options.browserPort + "\n"
                + "  External web service:       http://" + InetAddress.getLocalHost().getHostAddress() + ":"
                + options.browserPort + "\n" + "  Local websocket service:    http://127.0.0.1:"
                + options.wsPort + "\n" + "  External websocket service: http://"
                + InetAddress.getLocalHost().getHostAddress() + ":" + options.wsPort
                + "\n----------------------------------------------------------");

    } catch (ParameterException e) {
        System.err.println("An error occurred when running command: " + StringUtils.join(args, " "));
        System.err.println(e.getMessage() + System.lineSeparator());
        if (jc.getParsedCommand() != null) {
            jc.usage(jc.getParsedCommand());
        }
    } catch (Exception e) {
        System.err.println("An error occurred when running command: " + StringUtils.join(args, " "));
        System.err.println(e.getMessage() + System.lineSeparator());
        logger.error("An error occurred when running command: " + StringUtils.join(args, " "), e);
    }
}